News for hackers. Stuff that matters.
Re:Migrating a 10,000-line legacy JavaScript codebase to Typ... by peteretep on Friday June 17, 2016 @01:27AM (#11920842)
Ah, that's a neat idea. I wonder if there's any easy way to then scan your code for type aliases that are `any` to make sure you've caught all of those.
Re:Migrating a 10,000-line legacy JavaScript codebase to Typ... by chrismbarr on Friday June 17, 2016 @07:49AM (#11922041)
Yes! We have several 100% TypeScript applications and we've found TSLint to be invaluable for maintaining code quality - http://palantir.github.io/tslint/

You can ban the `any` type along with lots of other rules. You can also write your own custom rules, or implimnet rulesets by 3rd parties like Microsoft: https://github.com/Microsoft/tslint-microsoft-contrib and ESLint: https://github.com/buzinas/tslint-eslint-rules

Re:Migrating a 10,000-line legacy JavaScript codebase to Typ... by ghh on Friday June 17, 2016 @01:36AM (#11920865)
Most development setups have a way to do a regex search through a codebase; You'd be looking for declare type.*any
Re:Migrating a 10,000-line legacy JavaScript codebase to Typ... by wrigby on Friday June 17, 2016 @06:00PM (#11925817)
If you're IDE doesn't do it, then I highly recommend using ack[1]. It's my go-to tool for tasks like this, and I've found it a joy to use.

1: http://beyondgrep.com

Re:Migrating a 10,000-line legacy JavaScript codebase to Typ... by wvenable on Friday June 17, 2016 @01:31AM (#11920850)
Probably best to put all the any type aliases in one place then you know what they are all.
Re:Migrating a 10,000-line legacy JavaScript codebase to Typ... by wldcordeiro on Friday June 17, 2016 @02:23AM (#11920988)
Common prefix or suffix? I know in the RxJS community it's not uncommon to suffix an Observable variable like `fooBar$`
Re:Migrating a 10,000-line legacy JavaScript codebase to Typ... by smt88 on Friday June 17, 2016 @02:47AM (#11921045)
I think that would be more trouble than it's worth. Since "any" is a keyword, you wouldn't even need regex to search for it. Something like this would work:

" = any"

This would only show types that are aliases of the "any" type. As a side note, the following would create a compiler error ("cannot find name 'any'") because types are metadata and can't be used as program data.

const something = any;

Re:Migrating a 10,000-line legacy JavaScript codebase to Typ... by Sharlin on Friday June 17, 2016 @09:57AM (#11922639)
Heh, sure does bring memories of the C64 BASIC where string-typed variables and functions were marked with a $ suffix :)