Skip to content

Commit acc653a

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint
2 parents 0e7c9e8 + 3c42760 commit acc653a

29 files changed

+309
-126
lines changed

src/compiler/checker.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22875,24 +22875,29 @@ namespace ts {
2287522875

2287622876
// If the symbol of the node has members, treat it like a constructor.
2287722877
const symbol = getSymbolOfNode(func);
22878-
return !!symbol && symbol.members !== undefined;
22878+
return !!symbol && hasEntries(symbol.members);
2287922879
}
2288022880
return false;
2288122881
}
2288222882

2288322883
function mergeJSSymbols(target: Symbol, source: Symbol | undefined) {
2288422884
if (source && (hasEntries(source.exports) || hasEntries(source.members))) {
22885-
target = cloneSymbol(target);
22886-
if (hasEntries(source.exports)) {
22887-
target.exports = target.exports || createSymbolTable();
22888-
mergeSymbolTable(target.exports, source.exports);
22889-
}
22890-
if (hasEntries(source.members)) {
22891-
target.members = target.members || createSymbolTable();
22892-
mergeSymbolTable(target.members, source.members);
22893-
}
22894-
target.flags |= source.flags & SymbolFlags.Class;
22895-
return target as TransientSymbol;
22885+
const links = getSymbolLinks(source);
22886+
if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) {
22887+
const inferred = isTransientSymbol(target) ? target : cloneSymbol(target) as TransientSymbol;
22888+
inferred.exports = inferred.exports || createSymbolTable();
22889+
inferred.members = inferred.members || createSymbolTable();
22890+
inferred.flags |= source.flags & SymbolFlags.Class;
22891+
if (hasEntries(source.exports)) {
22892+
mergeSymbolTable(inferred.exports, source.exports);
22893+
}
22894+
if (hasEntries(source.members)) {
22895+
mergeSymbolTable(inferred.members, source.members);
22896+
}
22897+
(links.inferredClassSymbol || (links.inferredClassSymbol = createMap<TransientSymbol>())).set("" + getSymbolId(inferred), inferred);
22898+
return inferred;
22899+
}
22900+
return links.inferredClassSymbol.get("" + getSymbolId(target));
2289622901
}
2289722902
}
2289822903

src/compiler/types.ts

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3792,30 +3792,31 @@ namespace ts {
37923792

37933793
/* @internal */
37943794
export interface SymbolLinks {
3795-
immediateTarget?: Symbol; // Immediate target of an alias. May be another alias. Do not access directly, use `checker.getImmediateAliasedSymbol` instead.
3796-
target?: Symbol; // Resolved (non-alias) target of an alias
3797-
type?: Type; // Type of value symbol
3798-
uniqueESSymbolType?: Type; // UniqueESSymbol type for a symbol
3799-
declaredType?: Type; // Type of class, interface, enum, type alias, or type parameter
3800-
resolvedJSDocType?: Type; // Resolved type of a JSDoc type reference
3801-
typeParameters?: TypeParameter[]; // Type parameters of type alias (undefined if non-generic)
3802-
outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type
3803-
instantiations?: Map<Type>; // Instantiations of generic type alias (undefined if non-generic)
3804-
mapper?: TypeMapper; // Type mapper for instantiation alias
3805-
referenced?: boolean; // True if alias symbol has been referenced as a value
3806-
containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property
3807-
leftSpread?: Symbol; // Left source for synthetic spread property
3808-
rightSpread?: Symbol; // Right source for synthetic spread property
3809-
syntheticOrigin?: Symbol; // For a property on a mapped or spread type, points back to the original property
3810-
isDiscriminantProperty?: boolean; // True if discriminant synthetic property
3811-
resolvedExports?: SymbolTable; // Resolved exports of module or combined early- and late-bound static members of a class.
3812-
resolvedMembers?: SymbolTable; // Combined early- and late-bound members of a symbol
3813-
exportsChecked?: boolean; // True if exports of external module have been checked
3814-
typeParametersChecked?: boolean; // True if type parameters of merged class and interface declarations have been checked.
3795+
immediateTarget?: Symbol; // Immediate target of an alias. May be another alias. Do not access directly, use `checker.getImmediateAliasedSymbol` instead.
3796+
target?: Symbol; // Resolved (non-alias) target of an alias
3797+
type?: Type; // Type of value symbol
3798+
uniqueESSymbolType?: Type; // UniqueESSymbol type for a symbol
3799+
declaredType?: Type; // Type of class, interface, enum, type alias, or type parameter
3800+
resolvedJSDocType?: Type; // Resolved type of a JSDoc type reference
3801+
typeParameters?: TypeParameter[]; // Type parameters of type alias (undefined if non-generic)
3802+
outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type
3803+
instantiations?: Map<Type>; // Instantiations of generic type alias (undefined if non-generic)
3804+
inferredClassSymbol?: Map<TransientSymbol>; // Symbol of an inferred ES5 constructor function
3805+
mapper?: TypeMapper; // Type mapper for instantiation alias
3806+
referenced?: boolean; // True if alias symbol has been referenced as a value
3807+
containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property
3808+
leftSpread?: Symbol; // Left source for synthetic spread property
3809+
rightSpread?: Symbol; // Right source for synthetic spread property
3810+
syntheticOrigin?: Symbol; // For a property on a mapped or spread type, points back to the original property
3811+
isDiscriminantProperty?: boolean; // True if discriminant synthetic property
3812+
resolvedExports?: SymbolTable; // Resolved exports of module or combined early- and late-bound static members of a class.
3813+
resolvedMembers?: SymbolTable; // Combined early- and late-bound members of a symbol
3814+
exportsChecked?: boolean; // True if exports of external module have been checked
3815+
typeParametersChecked?: boolean; // True if type parameters of merged class and interface declarations have been checked.
38153816
isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration
3816-
bindingElement?: BindingElement; // Binding element associated with property symbol
3817-
exportsSomeValue?: boolean; // True if module exports some value (not just types)
3818-
enumKind?: EnumKind; // Enum declaration classification
3817+
bindingElement?: BindingElement; // Binding element associated with property symbol
3818+
exportsSomeValue?: boolean; // True if module exports some value (not just types)
3819+
enumKind?: EnumKind; // Enum declaration classification
38193820
originatingImport?: ImportDeclaration | ImportCall; // Import declaration which produced the symbol, present if the symbol is marked as uncallable but had call signatures in `resolveESModuleSymbol`
38203821
lateSymbol?: Symbol; // Late-bound symbol for a computed property
38213822
specifierCache?: Map<string>; // For symbols corresponding to external modules, a cache of incoming path -> module specifier name mappings

src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,7 @@
25772577
<Str Cat="Text">
25782578
<Val><![CDATA[Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.]]></Val>
25792579
<Tgt Cat="Text" Stat="Loc" Orig="New">
2580-
<Val><![CDATA[Znaleziono sprzeczne definicje dla „{0}” w „{1}” i „{2}”. Rozważ zainstalowanie konkretnej wersji tej biblioteki, aby rozwiązać problem.]]></Val>
2580+
<Val><![CDATA[Znaleziono definicje będące w konflikcie dla „{0}” w „{1}” i „{2}”. Rozważ zainstalowanie konkretnej wersji tej biblioteki, aby rozwiązać problem.]]></Val>
25812581
</Tgt>
25822582
</Str>
25832583
<Disp Icon="Str" />

src/services/codefixes/addConvertToUnknownForNonOverlappingTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace ts.codefix {
1414

1515
function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number) {
1616
const token = getTokenAtPosition(sourceFile, pos);
17-
const assertion = Debug.assertDefined(findAncestor(token, (n): n is AsExpression | TypeAssertion => isAsExpression(n) || isTypeAssertion(n)));
17+
const assertion = Debug.assertDefined(findAncestor(token, (n): n is AsExpression | TypeAssertion => isAsExpression(n) || isTypeAssertion(n)), "Expected to find an assertion expression");
1818
const replacement = isAsExpression(assertion)
1919
? createAsExpression(assertion.expression, createKeywordTypeNode(SyntaxKind.UnknownKeyword))
2020
: createTypeAssertion(createKeywordTypeNode(SyntaxKind.UnknownKeyword), assertion.expression);

src/services/codefixes/annotateWithTypeFromJSDoc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ namespace ts.codefix {
6060
}
6161
}
6262
else {
63-
const jsdocType = Debug.assertDefined(getJSDocType(decl)); // If not defined, shouldn't have been an error to fix
64-
Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix.
63+
const jsdocType = Debug.assertDefined(getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix
64+
Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix.
6565
changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType));
6666
}
6767
}

src/services/codefixes/convertToEs6Module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ namespace ts.codefix {
178178
// `const a = require("b").c` --> `import { c as a } from "./b";
179179
return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)];
180180
default:
181-
return Debug.assertNever(name);
181+
return Debug.assertNever(name, `Convert to ES6 module got invalid syntax form ${(name as BindingName).kind}`);
182182
}
183183
}
184184

@@ -239,7 +239,7 @@ namespace ts.codefix {
239239
case SyntaxKind.MethodDeclaration:
240240
return !isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [createToken(SyntaxKind.ExportKeyword)], prop);
241241
default:
242-
Debug.assertNever(prop);
242+
Debug.assertNever(prop, `Convert to ES6 got invalid prop kind ${(prop as ObjectLiteralElementLike).kind}`);
243243
}
244244
});
245245
return statements && [statements, false];
@@ -377,7 +377,7 @@ namespace ts.codefix {
377377
case SyntaxKind.Identifier:
378378
return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference);
379379
default:
380-
return Debug.assertNever(name);
380+
return Debug.assertNever(name, `Convert to ES6 module got invalid name kind ${(name as BindingName).kind}`);
381381
}
382382
}
383383

@@ -401,7 +401,7 @@ namespace ts.codefix {
401401
const { parent } = use;
402402
if (isPropertyAccessExpression(parent)) {
403403
const { expression, name: { text: propertyName } } = parent;
404-
Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers`
404+
Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers`
405405
let idName = namedBindingsNames.get(propertyName);
406406
if (idName === undefined) {
407407
idName = makeUniqueName(propertyName, identifiers);

src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ namespace ts.codefix {
1919

2020
function getImportTypeNode(sourceFile: SourceFile, pos: number): ImportTypeNode {
2121
const token = getTokenAtPosition(sourceFile, pos);
22-
Debug.assert(token.kind === SyntaxKind.ImportKeyword);
23-
Debug.assert(token.parent.kind === SyntaxKind.ImportType);
22+
Debug.assert(token.kind === SyntaxKind.ImportKeyword, "This token should be an ImportKeyword");
23+
Debug.assert(token.parent.kind === SyntaxKind.ImportType, "Token parent should be an ImportType");
2424
return <ImportTypeNode>token.parent;
2525
}
2626

src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace ts.codefix {
3030
});
3131

3232
function getClass(sourceFile: SourceFile, pos: number): ClassLikeDeclaration {
33-
return Debug.assertDefined(getContainingClass(getTokenAtPosition(sourceFile, pos)));
33+
return Debug.assertDefined(getContainingClass(getTokenAtPosition(sourceFile, pos)), "There should be a containing class");
3434
}
3535

3636
function symbolPointsToNonPrivateMember (symbol: Symbol) {

src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace ts.codefix {
1717

1818
function getNode(sourceFile: SourceFile, pos: number): ConstructorDeclaration {
1919
const token = getTokenAtPosition(sourceFile, pos);
20-
Debug.assert(token.kind === SyntaxKind.ConstructorKeyword);
20+
Debug.assert(token.kind === SyntaxKind.ConstructorKeyword, "token should be at the constructor keyword");
2121
return token.parent as ConstructorDeclaration;
2222
}
2323

src/services/codefixes/fixSpelling.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ namespace ts.codefix {
3636

3737
let suggestion: string | undefined;
3838
if (isPropertyAccessExpression(node.parent) && node.parent.name === node) {
39-
Debug.assert(node.kind === SyntaxKind.Identifier);
39+
Debug.assert(node.kind === SyntaxKind.Identifier, "Expected an identifier for spelling (property access)");
4040
const containingType = checker.getTypeAtLocation(node.parent.expression);
4141
suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType);
4242
}
4343
else if (isImportSpecifier(node.parent) && node.parent.name === node) {
44-
Debug.assert(node.kind === SyntaxKind.Identifier);
44+
Debug.assert(node.kind === SyntaxKind.Identifier, "Expected an identifier for spelling (import)");
4545
const importDeclaration = findAncestor(node, isImportDeclaration)!;
4646
const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration);
4747
if (resolvedSourceFile && resolvedSourceFile.symbol) {

0 commit comments

Comments
 (0)