diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7f0fd2fb3fa..86fcc809d58 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1178,8 +1178,8 @@ namespace ts { case SyntaxKind.Identifier: return checkStrictModeIdentifier(node); case SyntaxKind.BinaryExpression: - if (isJavaScriptFile) { - let specialKind = getSpecialPropertyAssignmentKind(node); + if (isInJavaScriptFile(node)) { + const specialKind = getSpecialPropertyAssignmentKind(node); switch (specialKind) { case SpecialPropertyAssignmentKind.ExportsProperty: bindExportsPropertyAssignment(node); @@ -1378,11 +1378,11 @@ namespace ts { // This does two things: turns 'x' into a constructor function, and // adds a member 'y' to the result of that constructor function // Get 'x', the class - let classId = ((node.left).expression).expression; + const classId = ((node.left).expression).expression; // Look up the function in the local scope, since prototype assignments should immediately // follow the function declaration - let funcSymbol = container.locals[classId.text]; + const funcSymbol = container.locals[classId.text]; if (!funcSymbol) { return; } @@ -1397,7 +1397,7 @@ namespace ts { } // Get the exports of the class so we can add the method to it - let funcExports = declareSymbol(funcSymbol.exports, funcSymbol, (node.left).expression, SymbolFlags.ObjectLiteral | SymbolFlags.Property, SymbolFlags.None); + const funcExports = declareSymbol(funcSymbol.exports, funcSymbol, (node.left).expression, SymbolFlags.ObjectLiteral | SymbolFlags.Property, SymbolFlags.None); // Declare the method declareSymbol(funcExports.members, funcExports, node.left, SymbolFlags.Method, SymbolFlags.None); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 29e31a84a23..94c13fd1f3f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -123,8 +123,8 @@ namespace ts { const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - const anySignature = createSignature(undefined, undefined, emptyArray, undefined, anyType, undefined, 0, false, false); - const unknownSignature = createSignature(undefined, undefined, emptyArray, undefined, unknownType, undefined, 0, false, false); + const anySignature = createSignature(undefined, undefined, emptyArray, undefined, anyType, undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); + const unknownSignature = createSignature(undefined, undefined, emptyArray, undefined, unknownType, undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false); const globals: SymbolTable = {}; @@ -2661,7 +2661,7 @@ namespace ts { } else { // Declaration for className.prototype in inferred JS class - let type = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, undefined, undefined); + const type = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, undefined, undefined); return links.type = type; } } @@ -3930,9 +3930,9 @@ namespace ts { default: if (declaration.symbol.inferredConstructor) { kind = SignatureKind.Construct; - let members = createSymbolTable(emptyArray); + const members = createSymbolTable(emptyArray); // Collect methods declared with className.protoype.methodName = ... - let proto = declaration.symbol.exports["prototype"]; + const proto = declaration.symbol.exports["prototype"]; if (proto) { mergeSymbolTable(members, proto.members); } @@ -3954,7 +3954,7 @@ namespace ts { function getSignaturesOfSymbol(symbol: Symbol): Signature[] { if (!symbol) return emptyArray; - const result: Signature[] = []; + let result: Signature[] = []; for (let i = 0, len = symbol.declarations.length; i < len; i++) { const node = symbol.declarations[i]; switch (node.kind) { @@ -6841,7 +6841,14 @@ namespace ts { let container: Node; if (symbol.flags & SymbolFlags.Class) { // get parent of class declaration - container = getClassLikeDeclarationOfSymbol(symbol).parent; + const classDeclaration = getClassLikeDeclarationOfSymbol(symbol); + if (classDeclaration) { + container = classDeclaration.parent; + } + else { + // JS-inferred class; do nothing + return; + } } else { // nesting structure: diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 553c5bbeff0..cffc1e90a06 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1090,7 +1090,7 @@ namespace ts { } else if (lhs.expression.kind === SyntaxKind.PropertyAccessExpression) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part - let innerPropertyAccess = lhs.expression; + const innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === SyntaxKind.Identifier && innerPropertyAccess.name.text === "prototype") { return SpecialPropertyAssignmentKind.PrototypeProperty; }