Earlier quoted context omitted.
So, then how would you explain it to a five year old?
Imagine a pipe that only fits dogs. The pipe has two ends. One side has person A pushing dogs into the pipe - the source. The other side has person B pulling dogs out of the pipe - the sink. The source can push anything into the pipe that is a dog or more specialized than a dog, ie they can push in specific dog breeds like only terriers. So the source can treat the "Pipe of Dog" as a "Pipe of Terrier". It's okay beca…
TypeScript 2.4
41–50 of 52 posts
Re: TypeScript 2.4
#42The string enums don't seem to work the same way as the number enums, there's no 2 way access. For example. enum Test { a } let a = Test.a; let b = Test[ 0 ]; // isn't available on the string ones I wonder why its like that.
If there were a reverse map like for numeric enums, there'd be no way to (at runtime) distinguish a Name from a Value. With a numeric enum you can use typeof Test[x] to figure out if x was a valid Name or valid Value, but this doesn't work for string enums because they're both typeof == 'string'.
You could have a situation where you have a string as a code, and then the display name for example, and you can't really do that as is now. This seems more useful than checking for the type (which in a numeric enum is either a number or string, so you would still need to do some work to properly validate it).
Re: TypeScript 2.4
#43Dart with dynamic js compiler (DDC) is getting better too: http://news.dartlang.org/2017/06/a-stronger-dart-for-everyon...
The problem with Dart, is that it is a pain to interact with JavaScript libraries, let's see if Dart 2 makes it better.
[1]: https://medium.com/@thebosz/creating-a-dart-to-javascript-in...
Re: TypeScript 2.4
#44Earlier quoted context omitted.
So, then how would you explain it to a five year old?
Imagine a pipe that only fits dogs. The pipe has two ends. One side has person A pushing dogs into the pipe - the source. The other side has person B pulling dogs out of the pipe - the sink. The source can push anything into the pipe that is a dog or more specialized than a dog, ie they can push in specific dog breeds like only terriers. So the source can treat the "Pipe of Dog" as a "Pipe of Terrier". It's okay beca…
Re: TypeScript 2.4
#45Earlier quoted context omitted.
The problem with Dart, is that it is a pain to interact with JavaScript libraries, let's see if Dart 2 makes it better.
Luckily, the story is getting better. Now all it takes is a "definitions" file much like @types for Typescript[1]. [1]: https://medium.com/@thebosz/creating-a-dart-to-javascript-in...
Re: TypeScript 2.4
#46Earlier quoted context omitted.
Luckily, the story is getting better. Now all it takes is a "definitions" file much like @types for Typescript[1]. [1]: https://medium.com/@thebosz/creating-a-dart-to-javascript-in...
Is it also possible to go without a definition? TS allows that and it's quite useful.
Re: TypeScript 2.4
#47Earlier quoted context omitted.
If there were a reverse map like for numeric enums, there'd be no way to (at runtime) distinguish a Name from a Value. With a numeric enum you can use typeof Test[x] to figure out if x was a valid Name or valid Value, but this doesn't work for string enums because they're both typeof == 'string'.
That seems like a much minor situation compared to not being able to reverse map. You could have a situation where you have a string as a code, and then the display name for example, and you can't really do that as is now. This seems more useful than checking for the type (which in a numeric enum is either a number or string, so you would still need to do some work to properly validate it).
Re: TypeScript 2.4
#48I only know a little bit of JavaScript, what's the best way to learn TypeScript? Read Eloquent JavaScript then some TS related stuff? Or is there a TypeScript for Dummies that don't know JS?
Re: TypeScript 2.4
#49Re: TypeScript 2.4
#50Earlier quoted context omitted.
That seems like a much minor situation compared to not being able to reverse map. You could have a situation where you have a string as a code, and then the display name for example, and you can't really do that as is now. This seems more useful than checking for the type (which in a numeric enum is either a number or string, so you would still need to do some work to properly validate it).
If you want to have the reverse map, you can trivially build it yourself. But if the reverse map did exist (rather, if the map started off as bidirectional, which is the only option on the table), it'd be impossible to properly construct the one-way map.