@@ -4612,8 +4612,8 @@ namespace ts {
46124612 // the modifiers type is T. Otherwise, the modifiers type is {}.
46134613 const declaredType = <MappedType>getTypeFromMappedTypeNode(type.declaration);
46144614 const constraint = getConstraintTypeFromMappedType(declaredType);
4615- const extendedConstraint = constraint.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(<TypeParameter>constraint) : constraint;
4616- type.modifiersType = extendedConstraint.flags & TypeFlags.Index ? instantiateType((<IndexType>extendedConstraint).type, type.mapper || identityMapper) : emptyObjectType;
4615+ const extendedConstraint = constraint && constraint .flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(<TypeParameter>constraint) : constraint;
4616+ type.modifiersType = extendedConstraint && extendedConstraint .flags & TypeFlags.Index ? instantiateType((<IndexType>extendedConstraint).type, type.mapper || identityMapper) : emptyObjectType;
46174617 }
46184618 }
46194619 return type.modifiersType;
@@ -6645,7 +6645,7 @@ namespace ts {
66456645 // Starting with the parent of the symbol's declaration, check if the mapper maps any of
66466646 // the type parameters introduced by enclosing declarations. We just pick the first
66476647 // declaration since multiple declarations will all have the same parent anyway.
6648- let node = symbol.declarations[0].parent ;
6648+ let node: Node = symbol.declarations[0];
66496649 while (node) {
66506650 switch (node.kind) {
66516651 case SyntaxKind.FunctionType:
@@ -6665,7 +6665,7 @@ namespace ts {
66656665 case SyntaxKind.ClassExpression:
66666666 case SyntaxKind.InterfaceDeclaration:
66676667 case SyntaxKind.TypeAliasDeclaration:
6668- const declaration = <DeclarationWithTypeParameters> node;
6668+ const declaration = node as DeclarationWithTypeParameters ;
66696669 if (declaration.typeParameters) {
66706670 for (const d of declaration.typeParameters) {
66716671 if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) {
@@ -6680,6 +6680,14 @@ namespace ts {
66806680 }
66816681 }
66826682 break;
6683+ case SyntaxKind.JSDocFunctionType:
6684+ const func = node as JSDocFunctionType;
6685+ for (const p of func.parameters) {
6686+ if (contains(mappedTypes, getTypeOfNode(p))) {
6687+ return true;
6688+ }
6689+ }
6690+ break;
66836691 case SyntaxKind.ModuleDeclaration:
66846692 case SyntaxKind.SourceFile:
66856693 return false;
@@ -7730,8 +7738,11 @@ namespace ts {
77307738 }
77317739 }
77327740 }
7733- else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(<ObjectType>target))) {
7734- return Ternary.True;
7741+ else if (relation !== identityRelation) {
7742+ const resolved = resolveStructuredTypeMembers(<ObjectType>target);
7743+ if (isEmptyObjectType(resolved) || resolved.stringIndexInfo && resolved.stringIndexInfo.type.flags & TypeFlags.Any) {
7744+ return Ternary.True;
7745+ }
77357746 }
77367747 return Ternary.False;
77377748 }
@@ -16888,7 +16899,7 @@ namespace ts {
1688816899 if (!local.isReferenced && !local.exportSymbol) {
1688916900 for (const declaration of local.declarations) {
1689016901 if (!isAmbientModule(declaration)) {
16891- error (declaration.name, Diagnostics._0_is_declared_but_never_used , local.name);
16902+ errorUnusedLocal (declaration.name, local.name);
1689216903 }
1689316904 }
1689416905 }
@@ -21845,8 +21856,19 @@ namespace ts {
2184521856
2184621857 function checkGrammarNumericLiteral(node: NumericLiteral): boolean {
2184721858 // Grammar checking
21848- if (node.isOctalLiteral && languageVersion >= ScriptTarget.ES5) {
21849- return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher);
21859+ if (node.isOctalLiteral) {
21860+ let diagnosticMessage: DiagnosticMessage | undefined;
21861+ if (languageVersion >= ScriptTarget.ES5) {
21862+ diagnosticMessage = Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0;
21863+ }
21864+ else if (isChildOfLiteralType(node)) {
21865+ diagnosticMessage = Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
21866+ }
21867+ if (diagnosticMessage) {
21868+ const withMinus = isPrefixUnaryExpression(node.parent) && node.parent.operator === SyntaxKind.MinusToken;
21869+ const literal = `${withMinus ? "-" : ""}0o${node.text}`;
21870+ return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
21871+ }
2185021872 }
2185121873 }
2185221874
0 commit comments