Hacker News new | past | comments | ask | show | jobs | submit login

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.



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


Most development setups have a way to do a regex search through a codebase; You'd be looking for declare type.*any


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


Probably best to put all the any type aliases in one place then you know what they are all.


Common prefix or suffix? I know in the RxJS community it's not uncommon to suffix an Observable variable like `fooBar$`


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;


Heh, sure does bring memories of the C64 BASIC where string-typed variables and functions were marked with a $ suffix :)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: