Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f2e5fa5

Browse filesBrowse files
committed
Merge branch 'master' into atTypesPrefixAndImportSuffix
2 parents 5444f3c + 78df754 commit f2e5fa5
Copy full SHA for f2e5fa5

16 files changed

+939-547Lines changed: 939 additions & 547 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+35-24Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,10 +1400,10 @@ namespace ts {
14001400
return resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias);
14011401
}
14021402

1403-
function getTargetOfExportSpecifier(node: ExportSpecifier, dontResolveAlias?: boolean): Symbol {
1404-
return (<ExportDeclaration>node.parent.parent).moduleSpecifier ?
1405-
getExternalModuleMember(<ExportDeclaration>node.parent.parent, node, dontResolveAlias) :
1406-
resolveEntityName(node.propertyName || node.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, /*ignoreErrors*/ false, dontResolveAlias);
1403+
function getTargetOfExportSpecifier(node: ExportSpecifier, meaning: SymbolFlags, dontResolveAlias?: boolean) {
1404+
return node.parent.parent.moduleSpecifier ?
1405+
getExternalModuleMember(node.parent.parent, node, dontResolveAlias) :
1406+
resolveEntityName(node.propertyName || node.name, meaning, /*ignoreErrors*/ false, dontResolveAlias);
14071407
}
14081408

14091409
function getTargetOfExportAssignment(node: ExportAssignment, dontResolveAlias: boolean): Symbol {
@@ -1421,7 +1421,7 @@ namespace ts {
14211421
case SyntaxKind.ImportSpecifier:
14221422
return getTargetOfImportSpecifier(<ImportSpecifier>node, dontRecursivelyResolve);
14231423
case SyntaxKind.ExportSpecifier:
1424-
return getTargetOfExportSpecifier(<ExportSpecifier>node, dontRecursivelyResolve);
1424+
return getTargetOfExportSpecifier(<ExportSpecifier>node, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, dontRecursivelyResolve);
14251425
case SyntaxKind.ExportAssignment:
14261426
return getTargetOfExportAssignment(<ExportAssignment>node, dontRecursivelyResolve);
14271427
case SyntaxKind.NamespaceExportDeclaration:
@@ -3721,10 +3721,7 @@ namespace ts {
37213721
exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node);
37223722
}
37233723
else if (node.parent.kind === SyntaxKind.ExportSpecifier) {
3724-
const exportSpecifier = <ExportSpecifier>node.parent;
3725-
exportSymbol = (<ExportDeclaration>exportSpecifier.parent.parent).moduleSpecifier ?
3726-
getExternalModuleMember(<ExportDeclaration>exportSpecifier.parent.parent, exportSpecifier) :
3727-
resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias);
3724+
exportSymbol = getTargetOfExportSpecifier(<ExportSpecifier>node.parent, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias);
37283725
}
37293726
const result: Node[] = [];
37303727
if (exportSymbol) {
@@ -9228,25 +9225,39 @@ namespace ts {
92289225
let result = Ternary.True;
92299226
const saveErrorInfo = errorInfo;
92309227

9231-
outer: for (const t of targetSignatures) {
9232-
// Only elaborate errors from the first failure
9233-
let shouldElaborateErrors = reportErrors;
9234-
for (const s of sourceSignatures) {
9235-
const related = signatureRelatedTo(s, t, shouldElaborateErrors);
9236-
if (related) {
9237-
result &= related;
9238-
errorInfo = saveErrorInfo;
9239-
continue outer;
9228+
if (getObjectFlags(source) & ObjectFlags.Instantiated && getObjectFlags(target) & ObjectFlags.Instantiated && source.symbol === target.symbol) {
9229+
// We instantiations of the same anonymous type (which typically will be the type of a method).
9230+
// Simply do a pairwise comparison of the signatures in the two signature lists instead of the
9231+
// much more expensive N * M comparison matrix we explore below.
9232+
for (let i = 0; i < targetSignatures.length; i++) {
9233+
const related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], reportErrors);
9234+
if (!related) {
9235+
return Ternary.False;
92409236
}
9241-
shouldElaborateErrors = false;
9237+
result &= related;
92429238
}
9239+
}
9240+
else {
9241+
outer: for (const t of targetSignatures) {
9242+
// Only elaborate errors from the first failure
9243+
let shouldElaborateErrors = reportErrors;
9244+
for (const s of sourceSignatures) {
9245+
const related = signatureRelatedTo(s, t, shouldElaborateErrors);
9246+
if (related) {
9247+
result &= related;
9248+
errorInfo = saveErrorInfo;
9249+
continue outer;
9250+
}
9251+
shouldElaborateErrors = false;
9252+
}
92439253

9244-
if (shouldElaborateErrors) {
9245-
reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1,
9246-
typeToString(source),
9247-
signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
9254+
if (shouldElaborateErrors) {
9255+
reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1,
9256+
typeToString(source),
9257+
signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
9258+
}
9259+
return Ternary.False;
92489260
}
9249-
return Ternary.False;
92509261
}
92519262
return result;
92529263
}
Collapse file

‎src/compiler/core.ts‎

Copy file name to clipboardExpand all lines: src/compiler/core.ts
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,15 @@ namespace ts {
251251
}
252252
}
253253

254+
export function zipToMap<T>(keys: string[], values: T[]): Map<T> {
255+
Debug.assert(keys.length === values.length);
256+
const map = createMap<T>();
257+
for (let i = 0; i < keys.length; ++i) {
258+
map.set(keys[i], values[i]);
259+
}
260+
return map;
261+
}
262+
254263
/**
255264
* Iterates through `array` by index and performs the callback on each element of array until the callback
256265
* returns a falsey value, then returns false.
Collapse file

‎src/compiler/diagnosticMessages.json‎

Copy file name to clipboardExpand all lines: src/compiler/diagnosticMessages.json
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,9 +3203,16 @@
32033203
},
32043204
"Scoped package detected, looking in '{0}'": {
32053205
"category": "Message",
3206-
"code": "6182"
3206+
"code": 6182
3207+
},
3208+
"Reusing resolution of module '{0}' to file '{1}' from old program.": {
3209+
"category": "Message",
3210+
"code": 6183
3211+
},
3212+
"Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program.": {
3213+
"category": "Message",
3214+
"code": 6184
32073215
},
3208-
32093216
"Variable '{0}' implicitly has an '{1}' type.": {
32103217
"category": "Error",
32113218
"code": 7005
Collapse file

‎src/compiler/factory.ts‎

Copy file name to clipboardExpand all lines: src/compiler/factory.ts
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,22 @@ namespace ts {
14621462
: node;
14631463
}
14641464

1465+
export function createTypeAliasDeclaration(name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) {
1466+
const node = <TypeAliasDeclaration>createSynthesizedNode(SyntaxKind.TypeAliasDeclaration);
1467+
node.name = asName(name);
1468+
node.typeParameters = asNodeArray(typeParameters);
1469+
node.type = type;
1470+
return node;
1471+
}
1472+
1473+
export function updateTypeAliasDeclaration(node: TypeAliasDeclaration, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) {
1474+
return node.name !== name
1475+
|| node.typeParameters !== typeParameters
1476+
|| node.type !== type
1477+
? updateNode(createTypeAliasDeclaration(name, typeParameters, type), node)
1478+
: node;
1479+
}
1480+
14651481
export function createEnumDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, members: EnumMember[]) {
14661482
const node = <EnumDeclaration>createSynthesizedNode(SyntaxKind.EnumDeclaration);
14671483
node.decorators = asNodeArray(decorators);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.