diff --git a/lib/tsc.js b/lib/tsc.js index ca474fc5f0656..447e451186c39 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -67,7 +67,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook var ts; (function (ts) { ts.versionMajorMinor = "3.6"; - ts.version = ts.versionMajorMinor + ".3"; + ts.version = ts.versionMajorMinor + ".4"; })(ts || (ts = {})); (function (ts) { ts.emptyArray = []; @@ -7282,7 +7282,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -10525,8 +10525,8 @@ var ts; } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 158; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92) && parent.kind === 158; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -25150,7 +25150,7 @@ var ts; else { declareSymbolAndAddToSymbolTable(node, 1, 111551); } - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 16777216 : 0), 0); } @@ -33247,8 +33247,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; @@ -33424,11 +33423,11 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); @@ -33592,7 +33591,16 @@ var ts; var meaning = 788968; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 111551; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -46510,7 +46518,7 @@ var ts; if (member.kind === 158) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { addName(instanceNames, param.name, param.name.escapedText, 3); } } @@ -47816,7 +47824,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -49050,10 +49058,8 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } var sourceDefault = source.default && getTypeFromTypeNode(source.default); var targetDefault = getDefaultFromTypeParameter(target); @@ -59445,7 +59451,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -59989,7 +59995,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -60859,7 +60865,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -68314,7 +68320,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; diff --git a/lib/tsserver.js b/lib/tsserver.js index d23682342368d..be5166a94b4bc 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -94,7 +94,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.6"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".3"; + ts.version = ts.versionMajorMinor + ".4"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -9711,7 +9711,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -13420,8 +13420,8 @@ var ts; } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 158 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -30762,7 +30762,7 @@ var ts; } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } @@ -40120,8 +40120,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; @@ -40329,11 +40328,11 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. @@ -40508,7 +40507,16 @@ var ts; var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 111551 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -41311,6 +41319,7 @@ var ts; break; } } + // tslint:disable no-unnecessary-type-assertion return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { @@ -55528,7 +55537,7 @@ var ts; if (member.kind === 158 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } @@ -57100,7 +57109,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -58670,11 +58679,10 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - // relax check if later interface augmentation has no constraint - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + // relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with + // a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill) + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } // If the type parameter node has a default and it is not identical to the default // for the type parameter at this position, we report an error. @@ -62089,6 +62097,7 @@ var ts; } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { + // tslint:disable no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { @@ -70708,7 +70717,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -71555,7 +71564,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -72883,7 +72892,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -84035,7 +84044,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -106223,7 +106232,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -106894,7 +106903,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -108214,7 +108223,7 @@ var ts; // Parameter properties are children of the class, not the constructor. for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } @@ -123026,7 +123035,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -123105,7 +123114,7 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 768399664828e..5869f3641c858 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -3264,7 +3264,7 @@ declare namespace ts { parent: ConstructorDeclaration; name: Identifier; }; - function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; + function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index c4825d9da0460..8df15d7214cbe 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -93,7 +93,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.6"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".3"; + ts.version = ts.versionMajorMinor + ".4"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -9710,7 +9710,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -13419,8 +13419,8 @@ var ts; } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 158 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -30761,7 +30761,7 @@ var ts; } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } @@ -40119,8 +40119,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; @@ -40328,11 +40327,11 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. @@ -40507,7 +40506,16 @@ var ts; var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 111551 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -41310,6 +41318,7 @@ var ts; break; } } + // tslint:disable no-unnecessary-type-assertion return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { @@ -55527,7 +55536,7 @@ var ts; if (member.kind === 158 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } @@ -57099,7 +57108,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -58669,11 +58678,10 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - // relax check if later interface augmentation has no constraint - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + // relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with + // a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill) + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } // If the type parameter node has a default and it is not identical to the default // for the type parameter at this position, we report an error. @@ -62088,6 +62096,7 @@ var ts; } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { + // tslint:disable no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { @@ -70707,7 +70716,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -71554,7 +71563,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -72882,7 +72891,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -84034,7 +84043,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -106586,7 +106595,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -107257,7 +107266,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -108577,7 +108586,7 @@ var ts; // Parameter properties are children of the class, not the constructor. for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } @@ -123389,7 +123398,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -123468,7 +123477,7 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 811f3b3507c53..48bfe8b34724f 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -3264,7 +3264,7 @@ declare namespace ts { parent: ConstructorDeclaration; name: Identifier; }; - function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; + function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; diff --git a/lib/typescript.js b/lib/typescript.js index d078259e4ed81..fd7aaa5b59f0a 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -82,7 +82,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.6"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".3"; + ts.version = ts.versionMajorMinor + ".4"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -9699,7 +9699,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -13408,8 +13408,8 @@ var ts; } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 158 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -30750,7 +30750,7 @@ var ts; } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } @@ -40108,8 +40108,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; @@ -40317,11 +40316,11 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. @@ -40496,7 +40495,16 @@ var ts; var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 111551 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -41299,6 +41307,7 @@ var ts; break; } } + // tslint:disable no-unnecessary-type-assertion return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { @@ -55516,7 +55525,7 @@ var ts; if (member.kind === 158 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } @@ -57088,7 +57097,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -58658,11 +58667,10 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - // relax check if later interface augmentation has no constraint - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + // relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with + // a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill) + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } // If the type parameter node has a default and it is not identical to the default // for the type parameter at this position, we report an error. @@ -62077,6 +62085,7 @@ var ts; } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { + // tslint:disable no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { @@ -70696,7 +70705,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -71543,7 +71552,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -72871,7 +72880,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -84023,7 +84032,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -106575,7 +106584,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -107246,7 +107255,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -108566,7 +108575,7 @@ var ts; // Parameter properties are children of the class, not the constructor. for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } @@ -123378,7 +123387,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -123457,7 +123466,7 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 828a2d4732644..c98678ae30232 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -3264,7 +3264,7 @@ declare namespace ts { parent: ConstructorDeclaration; name: Identifier; }; - function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; + function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 467b2716b4326..d41325d6b5b56 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -82,7 +82,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.6"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".3"; + ts.version = ts.versionMajorMinor + ".4"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -9699,7 +9699,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -13408,8 +13408,8 @@ var ts; } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 158 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -30750,7 +30750,7 @@ var ts; } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } @@ -40108,8 +40108,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; @@ -40317,11 +40316,11 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. @@ -40496,7 +40495,16 @@ var ts; var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 111551 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -41299,6 +41307,7 @@ var ts; break; } } + // tslint:disable no-unnecessary-type-assertion return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { @@ -55516,7 +55525,7 @@ var ts; if (member.kind === 158 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } @@ -57088,7 +57097,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -58658,11 +58667,10 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - // relax check if later interface augmentation has no constraint - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + // relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with + // a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill) + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } // If the type parameter node has a default and it is not identical to the default // for the type parameter at this position, we report an error. @@ -62077,6 +62085,7 @@ var ts; } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { + // tslint:disable no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { @@ -70696,7 +70705,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -71543,7 +71552,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -72871,7 +72880,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -84023,7 +84032,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -106575,7 +106584,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -107246,7 +107255,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -108566,7 +108575,7 @@ var ts; // Parameter properties are children of the class, not the constructor. for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } @@ -123378,7 +123387,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -123457,7 +123466,7 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 13642ef70ad95..d8bd3fffc950b 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -83,7 +83,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.6"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".3"; + ts.version = ts.versionMajorMinor + ".4"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -9700,7 +9700,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -13409,8 +13409,8 @@ var ts; } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 158 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -30751,7 +30751,7 @@ var ts; } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } @@ -40109,8 +40109,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; @@ -40318,11 +40317,11 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. @@ -40497,7 +40496,16 @@ var ts; var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 111551 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -41300,6 +41308,7 @@ var ts; break; } } + // tslint:disable no-unnecessary-type-assertion return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { @@ -55517,7 +55526,7 @@ var ts; if (member.kind === 158 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } @@ -57089,7 +57098,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -58659,11 +58668,10 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - // relax check if later interface augmentation has no constraint - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + // relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with + // a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill) + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } // If the type parameter node has a default and it is not identical to the default // for the type parameter at this position, we report an error. @@ -62078,6 +62086,7 @@ var ts; } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { + // tslint:disable no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { @@ -70697,7 +70706,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -71544,7 +71553,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -72872,7 +72881,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -84024,7 +84033,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError;