7 ms·
TypeScript 2.9 is now available
- camgunz 8y agoHey I've been enjoying working with TypeScript lately, but when is this bug gonna be fixed: https://github.com/Microsoft/TypeScript/issues/11375 https://github.com/Microsoft/TypeScript/issues/11375. You basically can't implement iterators while using `strictNullChecks`, and it's been broken since at least October 2016 (!) Every time I go to use TS for a personal project I check to see if this is fixed, and for almost two years the answer is no. I am dying here. Should I not be implementing iterators? Does no one use `strictNullChecks`?
- avtar 8y ago> but when is this bug gonna be fixed: https://github.com/Microsoft/TypeScript/issues/11375 https://github.com/Microsoft/TypeScript/issues/11375 Looks like whenever 3.0 is released.
- camgunz 8y agoThey keep bumping the release marker
- smt88 8y agoIsn't there something like @ts-ignore that lets you disable the type checker on a line-by-line basis?
- tlarkworthy 8y agoYes but it doesn't apply to certain errors unfortunately
- camgunz 8y agoI don't want to ignore every iterator I build. I want it all to be null safe.
- nitinreddy88 8y agoI am assuming you are developer of Js/TS, and being open source your contribution to fix would be welcomed. We expect contributions from everyone thats the motive behind OpenSource And not just being transparent of code
- maxilulu 8y agoHe might be just a consumer not a compiler expert.
- qop 8y agoI have seen the remark you're replying to hundreds of times throughout my career. I've seen probably thousands of complaints about out-of-date exploits or bad kits or including new injections and so on... This isn't infosec, but it IS still FOSS. I've always considered the reminder that open source loves contributions to be a gentle reminder that: * Most FOSS isn't sponsored. * Most FOSS developers/maintainers aren't treated with much courtesy when things go wrong. "you broke my build!" etc. * Without FOSS, a vibrant, interesting world would not exist within our computers, and even though its easy to forget, that world requires a rather significant amount of work for it to turn. Ofc not everyone is a compiler expert. But everybody can help, and certainly everybody can TRY to help. Framing an issue like this with "hey, I'm not a compiler expert but there's this bug and I would love for it to be fixed, I wouldn't even know where to start... It's an older bug, what's the plan?" is much more courteous of the maintainers than "this shit is broke why don't u fix it?!" I'm exaggerating just to illustrate the spectrum. Better and worse examples can be found all across the fossverse. Hell in just the Linux kernel alone there's a whole village of different personalities. My point to all this: it's a very common remark, goes back ages, and I think it's a fantastic denominator to remind people the logistics of foss and human beings. Sorry to hijack your comment!
- Rapzid 8y ago> We expect contributions from everyone thats the motive behind OpenSource And not just being transparent of code This is not a very common remark however.
- huy-nguyen 8y agoI hope they will some day implement variadic types: https://github.com/Microsoft/TypeScript/issues/5453 https://github.com/Microsoft/TypeScript/issues/5453. Also, the plan for a 3.0 release looks a bit underwhelming: https://github.com/Microsoft/TypeScript/wiki/Roadmap#30-july-2018 https://github.com/Microsoft/TypeScript/wiki/Roadmap#30-july.... Why not call that 2.10?
- praxxis 8y agoSemVer - "Note that this PR is technically a breaking change since unknown becomes a reserved type name", from https://github.com/Microsoft/TypeScript/pull/24439 https://github.com/Microsoft/TypeScript/pull/24439 which is the first item in the list.
- frankpf 8y agoI don't think TypeScript follows semver. TypeScript 2.9 is not compatible with 2.8.
- deleted 8y ago[deleted]
- Scarbutt 8y agoAlso, the plan for a 3.0 release looks a bit underwhelming They have added a ton of language features and keep adding more with each release, lets hope it doesn't get bloated as scala.
- pudebe 8y agoExactly. For my taste they already added too many language features, which each time raises the mental bar to use it when you didnt use it for a couple of month.
- amzans 8y agoIMO Scala has a lot of very well thought out features that complement each other, and this is only going to get better with the move towards Dotty. For me it feels not as bloated as other languages which added features without thinking about how they fit to the existing ones. But I work a lot on Scala, so I'm probably biased since I know the language better than i.e. Typescript :)
- CrypticOne274 8y agoGreat. Got to love breaking changes.
- manigandham 8y agoThe only "breaking" change is a stricter type check for keyof, and strict type checking is the entire reason for existence of TypeScript.
- latchkey 8y ago...which broke projects that use material-ui.com [1]. [1] https://github.com/mui-org/material-ui/issues/11656 https://github.com/mui-org/material-ui/issues/11656
- manigandham 8y agoYes, breaking changes potential break things, the point being in this case Typescript is getting better at doing its job and the change is rather minor. Also it clearly states: "use --keyofStringsOnly compiler option to disable the new behavior"
- latchkey 8y agoApologies, my comment was not a complaint. I'm all for type safety and a huge fan of typescript!
- pininja 8y agoI’m a fan of the “Generic type arguments in JSX elements” - ran into a case where I needed it a few months ago. They’ve always had a workaround, but this is more concise.
- btown 8y agoSo much better than the workaround here: https://github.com/Microsoft/TypeScript/issues/3960#issuecomment-301381447 https://github.com/Microsoft/TypeScript/issues/3960#issuecom... type TemplateTypedSelect = new () => Select<Template>; const TemplateTypedSelect = Select as TemplateTypedSelect; return <TemplateTypedSelect {...props} />; Our codebase was sprinkled with these, which was both silly and error-prone. This will be a huge quality-of-life improvement, and encourage people to create type-safe React components that ensure a match between their inputs and callbacks, rather than just having them put a union of all the types they can handle in both.
- arenaninja 8y agoGotta love the sanity that TypeScript brings to web development, if not for TypeScript I'd rather write PHP over JS For good measure I recently wrote a blog post on writing your first TypeScript+React application: https://charmeleon.github.io/post/react-typescript-tic-tac-toe/ https://charmeleon.github.io/post/react-typescript-tic-tac-t...
- shabbyrobe 8y agoPHP cops a lot of heat - some deserved, but mostly not - largely based on limitations of previous versions, cosmetic issues like the crummy naming and argument ordering in the stdlib, and good old fashioned out-grouping, but it has had optional graduated type safety for many, many years. Moving from PHP to Node felt like a major step backwards in the sheer number of unit tests and argument sanitisation junk I used to not need to write. I'm so grateful for TypeScript, it's the hero JavaScript desperately needed.
- deleted 8y ago[deleted]
- stevebmark 8y ago"type hell" seems to be far worse than "dependency hell," where the open source type definitions you use can have minor inconsistencies with each other, many of which are out of your control, causing lots of useless type errors in any project with even medium complexity. This forces engineers to ignore type errors, defeating the purpose of Typescript entirely. Has anyone had a truly pleasant experience with Typescript in a medium to large project?
- eitland 8y ago> "type hell" seems to be far worse than "dependency hell," where the open source type definitions you use can have minor inconsistencies with each other, many of which are out of your control, causing lots of useless type errors in any project with even medium complexity. Tried twice to wrap my head around what you are even talking about. TypeScript is totally wonderful. It's also optionally typed. I use it on a non trivial project with multiple teams. Was introduced to it last year and it's fantastic compared to plain js.
- mediumdeviation 8y agoExample: https://imgur.com/oR3Nk8q https://imgur.com/oR3Nk8q This was generated by one line of code, simply applying the hoist-non-react-statics library as recommended by the official React docs https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over https://reactjs.org/docs/higher-order-components.html#static... JavaScript in many cases can be too dynamic to be properly typed. I'd rather have it than not - it has saved my ass a good number of times - but let's not pretend TS/Flow is totally wonderful.
- Cthulhu_ 8y agoError messages like that are pretty bad, yeah. I'm still a fan of TS myself though, the challenge is that there's some less-well-designed JS libraries that are, like you said, too dynamic to be properly typed. It's bringing OOP back from having almost been forgotten, and with it, a reminder of proper library design and data types.
- jhoh 8y agoI've been using TypeScript for around one year now in small to mid sized projects but I feel like I'm not using a lot of the language's features and best practices. Does someone know any good advanced courses (free or paid)?
- juol 8y agoYeah I'm in the same boat. I've been spending a bit of time looking into some of the big and popular Typescript projects. But something's not sinking in and I could use a intermediate/advanced guide.
- Sammi 8y agoEgghead courses are usually quite good: https://egghead.io/browse/languages/typescript https://egghead.io/browse/languages/typescript
- knocte 8y agoThe only things that put me off about typescript are: a) The lack of a proper 'is' keyword. The current behaviour around this is mental. b) The unneeded complexity that the recent releases have brought to the typing system.
- Double_a_92 8y agoTo be fair, checking objects with "is" is somewhat of an antipattern.
- Too 8y agoDo you mean instanceof? The javascript operator still works as before? Though typescript is designed around interfaces/ducktyping, which is almost the opposite of instanceof; as long as a type satisfies the interface constraints it walks like a duck and should be sufficient.
- mathw 8y agoMaybe they should have had a "quackslike" operator :)
- sime2009 8y agoTypeScript does support writing "quacksLike" functions. The feature is "type guards" and it lets you write a boolean function to test the type of an argument, and TS's flow control code understands it at compile time. const something: Animal = ... if (isDuck(something)) { someThing.quack(); // TS can OK this }
- Too 8y agoMaybe it's too early in the morning but i had a really hard time understanding the changes around keyof and mapped types and what it's good for. It felt very mathematically academic. Does anyone have real world examples where it's useful?
- edvald 8y agoI'm a pretty heavy TS user and I was pondering the same thing. I've not been able to find a motive for allowing numbers as interface keys, but Symbols actually do make sense since, turns out (I'm always learning something new), you can use them as object keys in ES6: https://www.keithcirkel.co.uk/metaprogramming-in-es6-symbols/ https://www.keithcirkel.co.uk/metaprogramming-in-es6-symbols... That post outlines a few use cases which are admittedly outside of everyday JS/TS usage but I can see them as quite powerful when, for example, building frameworks and libraries that expose an API. I'd offer real-world examples of my own but I'm still working it out for myself .)
- WorldMaker 8y agoJS allows numbers as object keys (though it's one of those weird behavioral swamps where arrays act differently from objects, and sometimes they are coerced to strings [objects] and sometimes not [arrays], depending), so this mostly seems that its just about getting better at defining the existing JS behaviors of things, modulo the "quirks" of course. A lot of this matters in "metaprogramming" like Readonly<T> and Partial<T> which use all of the existing keys in a type to produce a "new" result (none of the key can be set, and all of the keys are optional, respectively), and making sure it doesn't miss intentional keys like symbols and numbers.
- hellofunk 8y agoHow does typescript compare to ReasonML?