Skip to content

Invalid diagnostics produced #15666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
felixfbecker opened this issue May 8, 2017 · 3 comments
Closed

Invalid diagnostics produced #15666

felixfbecker opened this issue May 8, 2017 · 3 comments
Labels
API Relates to the public API for TypeScript Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@felixfbecker
Copy link
Contributor

TypeScript Version: 2.3.1

TS produces Diagnostics with undefined file field here: https://github.com/Microsoft/TypeScript/blob/2150a7796b0dfe83c5286755410e0fd1646ed86c/src/compiler/core.ts#L1235-L1251

But Diagnostic.file is declared as non-optional.

This causes unexpected "Cannot read property x of undefined" errors, even with strict null checks on.

@mhegazy
Copy link
Contributor

mhegazy commented May 8, 2017

A PR to update the declaration to SourceFile | undefined would be appreciated.

@mhegazy mhegazy added Help Wanted You can do this API Relates to the public API for TypeScript Bug A bug in TypeScript labels May 8, 2017
@felixfbecker
Copy link
Contributor Author

Btw, are you planning to adopt strictNullChecks into the TS codebase? It would probably prevent issues like this and many more in the future

@mhegazy
Copy link
Contributor

mhegazy commented May 8, 2017

It is on our list of work items.

HerringtonDarkholme added a commit to HerringtonDarkholme/TypeScript that referenced this issue May 10, 2017
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label May 10, 2017
@mhegazy mhegazy added this to the TypeScript 2.4 milestone May 10, 2017
mhegazy added a commit that referenced this issue May 10, 2017
fix #15666: mark file as optional in Diagnostic
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API Relates to the public API for TypeScript Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

2 participants