@@ -4612,8 +4612,8 @@ namespace ts {
4612
4612
// the modifiers type is T. Otherwise, the modifiers type is {}.
4613
4613
const declaredType = <MappedType>getTypeFromMappedTypeNode(type.declaration);
4614
4614
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;
4617
4617
}
4618
4618
}
4619
4619
return type.modifiersType;
@@ -6645,7 +6645,7 @@ namespace ts {
6645
6645
// Starting with the parent of the symbol's declaration, check if the mapper maps any of
6646
6646
// the type parameters introduced by enclosing declarations. We just pick the first
6647
6647
// 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];
6649
6649
while (node) {
6650
6650
switch (node.kind) {
6651
6651
case SyntaxKind.FunctionType:
@@ -6665,7 +6665,7 @@ namespace ts {
6665
6665
case SyntaxKind.ClassExpression:
6666
6666
case SyntaxKind.InterfaceDeclaration:
6667
6667
case SyntaxKind.TypeAliasDeclaration:
6668
- const declaration = <DeclarationWithTypeParameters> node;
6668
+ const declaration = node as DeclarationWithTypeParameters ;
6669
6669
if (declaration.typeParameters) {
6670
6670
for (const d of declaration.typeParameters) {
6671
6671
if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) {
@@ -6680,6 +6680,14 @@ namespace ts {
6680
6680
}
6681
6681
}
6682
6682
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;
6683
6691
case SyntaxKind.ModuleDeclaration:
6684
6692
case SyntaxKind.SourceFile:
6685
6693
return false;
@@ -7730,8 +7738,11 @@ namespace ts {
7730
7738
}
7731
7739
}
7732
7740
}
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
+ }
7735
7746
}
7736
7747
return Ternary.False;
7737
7748
}
@@ -16888,7 +16899,7 @@ namespace ts {
16888
16899
if (!local.isReferenced && !local.exportSymbol) {
16889
16900
for (const declaration of local.declarations) {
16890
16901
if (!isAmbientModule(declaration)) {
16891
- error (declaration.name, Diagnostics._0_is_declared_but_never_used , local.name);
16902
+ errorUnusedLocal (declaration.name, local.name);
16892
16903
}
16893
16904
}
16894
16905
}
@@ -21845,8 +21856,19 @@ namespace ts {
21845
21856
21846
21857
function checkGrammarNumericLiteral(node: NumericLiteral): boolean {
21847
21858
// 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
+ }
21850
21872
}
21851
21873
}
21852
21874
0 commit comments