Skip to content

Find-all-references: Don't crash on 'typeof import' #23448

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

Merged
2 commits merged into from
Apr 17, 2018
Merged

Conversation

ghost
Copy link

@ghost ghost commented Apr 16, 2018

Previously this was crashing because we expected a member of SourceFile.imports to be one of only a few kinds.

@ghost ghost requested review from weswigham and sheetalkamat April 16, 2018 22:23
@@ -3187,13 +3187,14 @@ namespace ts {
export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;

/* @internal */
export type AnyImportOrReExport = AnyImportSyntax | ExportDeclaration;
export type AnyImportOrReExport = AnyImportSyntax | ExportDeclaration | ImportTypeNode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, this is used as a shorthand in the definition of some other aliases which should not handle import type nodes (due to only handling statements) - those probably should be changed to not use it, since the type guards used with those aliases don't check for nonstatements.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, isAnyImportOrReExport's return type isn't accurate with this change. (The other uses within the core layer aren't so bad because they're used in a union alongside ImportTypeNode anyway)

@ghost
Copy link
Author

ghost commented Apr 17, 2018

@weswigham Could you update your review?

@ghost ghost merged commit f5101e2 into master Apr 17, 2018
@ghost ghost deleted the findAllRefsTypeofImport branch April 17, 2018 22:01
@microsoft microsoft locked and limited conversation to collaborators Jul 30, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants