API: incorrect declarations in types.ts
See original GitHub issueThe --strictNullChecks
PR changed some declarations in types.ts
to avoid frequent assertions in the compiler’s code. Unfortunately these changes make it really unsafe for API users because they no longer contain the actually nullable types: https://github.com/Microsoft/TypeScript/pull/22088#discussion_r184149465 https://github.com/Microsoft/TypeScript/pull/22088#discussion_r184155027
ts.Node#parent
is no longer optional (which is definitely wrong forSourceFile
)ts.Symbol#declarations
andts.Symbol.valueDeclaration
are no longer optional, but can still be undefinedts.Type#symbol
is no longer optional, but I guess this comment is still up to date:// Symbol associated with type (if any)
These changes should either be reverted or replaced in the published declaration files. /cc @andy-ms @weswigham
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Documentation - Type Declarations - TypeScript
TypeScript includes declaration files for all of the standardized built-in APIs available in JavaScript runtimes. This includes things like ...
Read more >Error: 'types' can only be used in a .ts file - Visual Studio Code ...
I'm using flow with vscode but had the same problem. I solved it with these steps: Install the extension Flow Language Support.
Read more >TypeScript errors and how to fix them
error TS2352: Conversion of type ' { name: string; age: number; } ' to type ' Person ' may be a mistake because...
Read more >ts-node - npm
See Missing types for details. Default: false. Environment: TS_NODE_FILES. ignoreDiagnostics. ts-node -D <code,code> ...
Read more >Incorrect error: "TS2307: Cannot find module or its ... - YouTrack
Incorrect error: "TS2307: Cannot find module or its corresponding type declarations" from TS service.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We just ran into this bug in
@typescript-eslint
. One of our rules assumed the typing was correct, causing a bug for an end user. As an API consumer, we rely on the types to help us ensure we catch bugs at compile time, and it’s counter-intuitive to handle cases that are contrary to the types.Related issues: https://github.com/typescript-eslint/typescript-eslint/issues/498 https://github.com/typescript-eslint/typescript-eslint/issues/496
repro case for
ts.Symbol.valueDeclaration
being undefinedResult: of
node analyze.js