You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggestion: Offer us some frequent JS class types and functions #1174
It seems that we now have turple, string, number……But it would be better if we could have List, Stack, Queue,Dictionary<K,V> and other very useful and frequent class types like those in C#, I hope Microsoft can offer us such class types packaged in the install exe file directly, so that when we upgraded to the latest version, we can use them instead of writing them again and again.
Also it would be better if Microsoft can offer us some frequent libraries to be downloaded with many useful functions, something like:
Serialization/Deserialization functions:
function Serialize(object:T):string
{
return JSON.stringify(object);
}
function Deserialize(JsonString:string):T
{
var object:T = JSON.parse(JsonString);
return object;
}
The codes below are ONLY samples, so Microsoft can invent a compatible way to cope with almost all kinds of browsers such as from IE7……
Logger: It should include three levels (Error, Warning, Info) with different kinds of colors (Red, Yellow, Blue), for browser's scripts' debugging and do some special logging. And what's more, the Logger should have some global settings that allow us whether to show these logs or not according to the levels' setting.
It is not useful to focus our resources on something like this when you can just tap into the existing JavaScript/TypeScript ecosystem. If you need to support older browsers, use one of the many available polyfills.
A JavaScript array can easily behave as a list. The built in methods allow for things like pushing onto the list while built in functions and combinators from libraries like underscore let you do the various find/take/indexOf type operations.
A JavaScript object is already a dictionary.
varx={};x["myKey"]="myValue";
With a TypeScript interface for safety (underscore.d.ts has this sort of definition):
Tuples are simply array literals with a tuple type annotation, there's no need for an additional type definition:
varx: [string,number]=["hello",1];
There're numerous existing JS libraries for logging to suit a variety of different purposes. There's not some unique value we can deliver by shipping our own implementation.
Activity
DanielRosenwasser commentedon Nov 16, 2014
It is not useful to focus our resources on something like this when you can just tap into the existing JavaScript/TypeScript ecosystem. If you need to support older browsers, use one of the many available polyfills.
danquirk commentedon Nov 17, 2014
As an example, you could try the highly popular http://underscorejs.org/ and its associated .d.ts https://github.com/borisyankov/DefinitelyTyped/blob/master/underscore/underscore.d.ts
danquirk commentedon Nov 19, 2014
A JavaScript array can easily behave as a list. The built in methods allow for things like pushing onto the list while built in functions and combinators from libraries like underscore let you do the various find/take/indexOf type operations.
A JavaScript object is already a dictionary.
With a TypeScript interface for safety (underscore.d.ts has this sort of definition):
Tuples are simply array literals with a tuple type annotation, there's no need for an additional type definition:
There're numerous existing JS libraries for logging to suit a variety of different purposes. There's not some unique value we can deliver by shipping our own implementation.
danquirk commentedon Nov 24, 2014
Correct, because JavaScript doesn't lack fully featured libraries but it does lack the properties associated with stronger typing.