JS:Treat type-annotated uninitialised vars as declarations
Currently only applies to property accesses, but maybe should apply to everything.
This commit is contained in:
parent
1d1a7d8353
commit
082802e7a8
2 changed files with 10 additions and 1 deletions
|
@ -2006,6 +2006,9 @@ namespace ts {
|
|||
if (currentFlow && isNarrowableReference(<Expression>node)) {
|
||||
node.flowNode = currentFlow;
|
||||
}
|
||||
if (isSpecialPropertyDeclaration(node as PropertyAccessExpression)) {
|
||||
bindThisPropertyAssignment(node as PropertyAccessExpression);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.BinaryExpression:
|
||||
const specialKind = getSpecialPropertyAssignmentKind(node as BinaryExpression);
|
||||
|
@ -2314,7 +2317,7 @@ namespace ts {
|
|||
declareSymbol(file.symbol.exports, file.symbol, node, SymbolFlags.Property | SymbolFlags.ExportValue | SymbolFlags.ValueModule, SymbolFlags.None);
|
||||
}
|
||||
|
||||
function bindThisPropertyAssignment(node: BinaryExpression) {
|
||||
function bindThisPropertyAssignment(node: BinaryExpression | PropertyAccessExpression) {
|
||||
Debug.assert(isInJavaScriptFile(node));
|
||||
const container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
switch (container.kind) {
|
||||
|
|
|
@ -1508,6 +1508,12 @@ namespace ts {
|
|||
return SpecialPropertyAssignmentKind.None;
|
||||
}
|
||||
|
||||
export function isSpecialPropertyDeclaration(expr: ts.PropertyAccessExpression): boolean {
|
||||
return isInJavaScriptFile(expr) &&
|
||||
expr.parent && expr.parent.kind === SyntaxKind.ExpressionStatement &&
|
||||
!!getJSDocTypeTag(expr.parent);
|
||||
}
|
||||
|
||||
export function getExternalModuleName(node: Node): Expression {
|
||||
if (node.kind === SyntaxKind.ImportDeclaration) {
|
||||
return (<ImportDeclaration>node).moduleSpecifier;
|
||||
|
|
Loading…
Reference in a new issue