-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Clarify code checking for UMD exports... #9897
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17713,14 +17713,17 @@ namespace ts { | |
const parentSymbol = getParentOfSymbol(symbol); | ||
if (parentSymbol) { | ||
if (parentSymbol.flags & SymbolFlags.ValueModule && parentSymbol.valueDeclaration.kind === SyntaxKind.SourceFile) { | ||
const symbolFile = <SourceFile> parentSymbol.valueDeclaration; | ||
const referenceFile = getSourceFileOfNode(node); | ||
// If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. | ||
if (parentSymbol.valueDeclaration === getSourceFileOfNode(node)) { | ||
return <SourceFile>parentSymbol.valueDeclaration; | ||
} | ||
const symbolIsUmdExport = symbolFile !== referenceFile; | ||
return symbolIsUmdExport ? undefined : symbolFile; | ||
} | ||
for (let n = node.parent; n; n = n.parent) { | ||
if ((n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(n) === parentSymbol) { | ||
return <ModuleDeclaration | EnumDeclaration>n; | ||
else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old version of this code fell through when it shouldn't have, so as part of removing the fallthrough I turned it into an if-else. If you think the nesting is too much I'll change it back. |
||
for (let n = node.parent; n; n = n.parent) { | ||
if ((n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(n) === parentSymbol) { | ||
return <ModuleDeclaration | EnumDeclaration>n; | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitly return |
||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No space after type assertions (@weswigham can you write this rule? 😄 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could. ;)