Replies: 1 comment
-
I opened #389 to implement the rule. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Typescript has a noImplicitAny, but it for some weird reason doesn't error on code like so:
let x;
The reasoning is that type inference will pick up the type as it's used.
microsoft/TypeScript#30899
Whatever the reason, eslint typescript lacks a rule to handle this, and some weird config that leverages
no-restricted-syntax
https://typescript-eslint.io/play/#ts=4.7.4&sourceType=module&showAST=es&code=PQKgUApgzgNglgOwC4AIEHsC0AnaTtwDGSEAJplAJ7ICGAHgFwoDaYKKARBNtuthwBo2KAN7D2HKBBgRifDkw4A1GgRoAjGQBFZMVTSRx0CZgGtEpFAF4UAchlJbAXRQA+FCrWaIOwnuwGfMyIcKg2CACuMDBODBhIABTBpAB0SJQADhAAggjxBkYITgCUguKcALbQUDQA5hAKnAAKvABucKQQKDQo6VndeehIBcYcwgC+YE5gIMBgYMDAKABCNKRgDihQ6FWeAIwA3GDbu6p71nZ7AEwAzLZHJxD7F9c3RwtLAOLo6Oubj54rkwoPhELUHjsnqorhdbACaDAIhB7vNFihvr8NhBUPDsDdYfDEcj3miMX9sVtIZ4ACwXepIADK0lkhmMCWKJK+P3JOKpqgArBdcfiAPx2VoIpEAeQQyJQTFsEqJABUAO7oe5AA&eslintrc=N4KABGBEBOCuA2BTAzpAXGYBfEWg&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3QAacDUhFYASSSomyPAEEiATwphR6KQF8Q+oA
I think from a code readability point of view, enforcing type declarations on uninitialized
let
variables is a no brainer. It documents the code giving context to how it intends to be used, and prevents weirdness from happening as a result of not type being enforced at the beginning.Beta Was this translation helpful? Give feedback.
All reactions