4 ms·
> Use the —noImplicitAny flag Welcome to reality! When you do this in any decently-sized TS codebase, you want to kill yourself, because the "smart" devs that
by knocte 8y ago
> Use the —noImplicitAny flag
Welcome to reality! When you do this in any decently-sized TS codebase, you want to kill yourself, because the "smart" devs that started the project didn't do it at the beginning, and fixing it now would take you a man month, in order to be able to enforce it moving forward.
> Use the —strictNullChecks flag
My previous reply also applies to this one, plus: you can still compare against undefined when using this flag (we're talking about unreadable code... even if comparing it with undefined wouldn't make any sense in a codebase with structNullChecks enabled, it's not a compiler error).
> Or, use —strict to do both of those and more.
My gripes above would only be solved if these strict modes were the default. Otherwise shitty and unfixable (read again: man months for a normal project) typescript code keeps being written.
> what specifically is indecent about TS’s type guards?
How about you read the link I posted?
- PudgePacket 8y agoYou point out issues that are already solved. It's a people problem you have now :) no amount of configuration is going to fix that. Also strict has been the default for quite a while!
- knocte 8y ago> Also strict has been the default for quite a while! That would prevent anyone to rename a .js file to .ts and compile successfully. Which I think is not the case today. Prove otherwise please.
- PudgePacket 8y agohttps://github.com/Microsoft/TypeScript/commit/d3b7058c2999f68c04278e15cbc29c91bcc44dc5 https://github.com/Microsoft/TypeScript/commit/d3b7058c2999f... over a year.
- WorldMaker 8y agoAlso, the allowJS compiler switch became the preferred approach for in-place migrations over mass renames. It makes it easier to opt in to strict type checking on a file-by-file basis. https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html https://www.typescriptlang.org/docs/handbook/migrating-from-...
- bcherny 8y agoI’ve migrated a pretty big codebase to TS, and then again to noImplictAny. One suggestion is to turn the flag on, migrate a few files, then turn it back off. When you’ve migrated a decent number of files, turn it on everywhere. For a really large codebase, you can do what companies like FB and Google do, and turn the flag on, then codemod every error to suppress it (either with @ts-ignore, or a type assertion). Note that you’ll have to follow a similar workflow for any language-level update- it’s not at all specific to TS. Re: type guards, Daniel and everyone else in that thread gave a really reasonable response IMO. I think you might just be misunderstanding TS’s design goal of not affecting runtime behavior?