3 ms·
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.
by peteretep 10y ago
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.
- wvenable 10y agoProbably best to put all the any type aliases in one place then you know what they are all.
- ghh 10y agoMost development setups have a way to do a regex search through a codebase; You'd be looking for declare type.*any
- wrigby 10y agoIf 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 http://beyondgrep.com
- wldcordeiro 10y agoCommon prefix or suffix? I know in the RxJS community it's not uncommon to suffix an Observable variable like `fooBar$`
- smt88 10y agoI 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;
- Sharlin 10y agoHeh, sure does bring memories of the C64 BASIC where string-typed variables and functions were marked with a $ suffix :)
- chrismbarr 10y agoYes! We have several 100% TypeScript applications and we've found TSLint to be invaluable for maintaining code quality - http://palantir.github.io/tslint/ 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 https://github.com/Microsoft/tslint-microsoft-contrib and ESLint: https://github.com/buzinas/tslint-eslint-rules https://github.com/buzinas/tslint-eslint-rules