Skip to content

Commit f82d295

Browse files
committed
25002 - Resolved merge conflict
2 parents 2f0cc53 + cb4cb7a commit f82d295

File tree

247 files changed

+4296
-1331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+4296
-1331
lines changed

src/compiler/checker.ts

+197-71
Large diffs are not rendered by default.

src/compiler/diagnosticMessages.json

+20-4
Original file line numberDiff line numberDiff line change
@@ -2397,6 +2397,10 @@
23972397
"category": "Error",
23982398
"code": 2727
23992399
},
2400+
"'{0}' was declared here.": {
2401+
"category": "Error",
2402+
"code": 2728
2403+
},
24002404
"The respective 'set' accessor has the type '{0}'.": {
24012405
"category": "Error",
24022406
"code": 2730
@@ -3607,6 +3611,22 @@
36073611
"code": 6199,
36083612
"reportsUnnecessary": true
36093613
},
3614+
"Definitions of the following identifiers conflict with those in another file: {0}": {
3615+
"category": "Error",
3616+
"code": 6200
3617+
},
3618+
"Conflicts are in this file.": {
3619+
"category": "Message",
3620+
"code": 6201
3621+
},
3622+
"'{0}' was also declared here.": {
3623+
"category": "Message",
3624+
"code": 6203
3625+
},
3626+
"and here.": {
3627+
"category": "Message",
3628+
"code": 6204
3629+
},
36103630

36113631
"Projects to reference": {
36123632
"category": "Message",
@@ -4454,9 +4474,5 @@
44544474
"Add missing enum member '{0}'": {
44554475
"category": "Message",
44564476
"code": 95063
4457-
},
4458-
"Add all missing enum members": {
4459-
"category": "Message",
4460-
"code": 95064
44614477
}
44624478
}

src/compiler/factory.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -1531,13 +1531,6 @@ namespace ts {
15311531
return block;
15321532
}
15331533

1534-
/* @internal */
1535-
export function createExpressionStatement(expression: Expression): ExpressionStatement {
1536-
const node = <ExpressionStatement>createSynthesizedNode(SyntaxKind.ExpressionStatement);
1537-
node.expression = expression;
1538-
return node;
1539-
}
1540-
15411534
export function updateBlock(node: Block, statements: ReadonlyArray<Statement>) {
15421535
return node.statements !== statements
15431536
? updateNode(createBlock(statements, node.multiLine), node)
@@ -1563,16 +1556,23 @@ namespace ts {
15631556
return <EmptyStatement>createSynthesizedNode(SyntaxKind.EmptyStatement);
15641557
}
15651558

1566-
export function createStatement(expression: Expression) {
1567-
return createExpressionStatement(parenthesizeExpressionForExpressionStatement(expression));
1559+
export function createExpressionStatement(expression: Expression): ExpressionStatement {
1560+
const node = <ExpressionStatement>createSynthesizedNode(SyntaxKind.ExpressionStatement);
1561+
node.expression = parenthesizeExpressionForExpressionStatement(expression);
1562+
return node;
15681563
}
15691564

1570-
export function updateStatement(node: ExpressionStatement, expression: Expression) {
1565+
export function updateExpressionStatement(node: ExpressionStatement, expression: Expression) {
15711566
return node.expression !== expression
1572-
? updateNode(createStatement(expression), node)
1567+
? updateNode(createExpressionStatement(expression), node)
15731568
: node;
15741569
}
15751570

1571+
/** @deprecated Use `createExpressionStatement` instead. */
1572+
export const createStatement = createExpressionStatement;
1573+
/** @deprecated Use `updateExpressionStatement` instead. */
1574+
export const updateStatement = updateExpressionStatement;
1575+
15761576
export function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement) {
15771577
const node = <IfStatement>createSynthesizedNode(SyntaxKind.IfStatement);
15781578
node.expression = expression;

src/compiler/moduleSpecifiers.ts

+10-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace ts.moduleSpecifiers {
99
export function getModuleSpecifier(
1010
compilerOptions: CompilerOptions,
1111
importingSourceFile: SourceFile,
12-
importingSourceFileName: string,
12+
importingSourceFileName: Path,
1313
toFileName: string,
1414
host: ModuleSpecifierResolutionHost,
1515
files: ReadonlyArray<SourceFile>,
@@ -18,7 +18,6 @@ namespace ts.moduleSpecifiers {
1818
const info = getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host);
1919
const modulePaths = getAllModulePaths(files, toFileName, info.getCanonicalFileName, host);
2020
return firstDefined(modulePaths, moduleFileName => getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions)) ||
21-
getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) ||
2221
first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences));
2322
}
2423

@@ -49,10 +48,10 @@ namespace ts.moduleSpecifiers {
4948
readonly moduleResolutionKind: ModuleResolutionKind;
5049
readonly addJsExtension: boolean;
5150
readonly getCanonicalFileName: GetCanonicalFileName;
52-
readonly sourceDirectory: string;
51+
readonly sourceDirectory: Path;
5352
}
5453
// importingSourceFileName is separate because getEditsForFileRename may need to specify an updated path
55-
function getInfo(compilerOptions: CompilerOptions, importingSourceFile: SourceFile, importingSourceFileName: string, host: ModuleSpecifierResolutionHost): Info {
54+
function getInfo(compilerOptions: CompilerOptions, importingSourceFile: SourceFile, importingSourceFileName: Path, host: ModuleSpecifierResolutionHost): Info {
5655
const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
5756
const addJsExtension = usesJsExtensionOnImports(importingSourceFile);
5857
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
@@ -67,19 +66,19 @@ namespace ts.moduleSpecifiers {
6766
compilerOptions: CompilerOptions,
6867
) {
6968
return tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension)
70-
|| tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory)
71-
|| compilerOptions.rootDirs && tryGetModuleNameFromRootDirs(compilerOptions.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName);
69+
|| tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory);
7270
}
7371

7472
function getLocalModuleSpecifiers(
7573
moduleFileName: string,
7674
{ moduleResolutionKind, addJsExtension, getCanonicalFileName, sourceDirectory }: Info,
7775
compilerOptions: CompilerOptions,
7876
preferences: ModuleSpecifierPreferences,
79-
) {
80-
const { baseUrl, paths } = compilerOptions;
77+
): ReadonlyArray<string> {
78+
const { baseUrl, paths, rootDirs } = compilerOptions;
8179

82-
const relativePath = removeExtensionAndIndexPostFix(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension);
80+
const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) ||
81+
removeExtensionAndIndexPostFix(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension);
8382
if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") {
8483
return [relativePath];
8584
}
@@ -272,7 +271,7 @@ namespace ts.moduleSpecifiers {
272271
moduleFileName: string,
273272
host: ModuleSpecifierResolutionHost,
274273
getCanonicalFileName: (file: string) => string,
275-
sourceDirectory: string,
274+
sourceDirectory: Path,
276275
): string | undefined {
277276
if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) {
278277
// nothing to do here
@@ -291,7 +290,7 @@ namespace ts.moduleSpecifiers {
291290
const moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName);
292291
// Get a path that's relative to node_modules or the importing file's path
293292
// if node_modules folder is in this folder or any of its parent folders, no need to keep it.
294-
if (!startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) return undefined;
293+
if (!startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined;
295294
// If the module was found in @types, get the actual Node package name
296295
return getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1));
297296

src/compiler/program.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,17 @@ namespace ts {
329329
return context;
330330
}
331331

332-
function formatLocation(file: SourceFile, start: number, host: FormatDiagnosticsHost) {
332+
/* @internal */
333+
export function formatLocation(file: SourceFile, start: number, host: FormatDiagnosticsHost, color = formatColorAndReset) {
333334
const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start); // TODO: GH#18217
334335
const relativeFileName = host ? convertToRelativePath(file.fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) : file.fileName;
335336

336337
let output = "";
337-
output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan);
338+
output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan);
338339
output += ":";
339-
output += formatColorAndReset(`${firstLine + 1}`, ForegroundColorEscapeSequences.Yellow);
340+
output += color(`${firstLine + 1}`, ForegroundColorEscapeSequences.Yellow);
340341
output += ":";
341-
output += formatColorAndReset(`${firstLineChar + 1}`, ForegroundColorEscapeSequences.Yellow);
342+
output += color(`${firstLineChar + 1}`, ForegroundColorEscapeSequences.Yellow);
342343
return output;
343344
}
344345

src/compiler/transformers/declarations.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ namespace ts {
6666
}
6767
}
6868

69-
function trackReferencedAmbientModule(node: ModuleDeclaration) {
69+
function trackReferencedAmbientModule(node: ModuleDeclaration, symbol: Symbol) {
70+
// If it is visible via `// <reference types="..."/>`, then we should just use that
71+
const directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, SymbolFlags.All);
72+
if (length(directives)) {
73+
return recordTypeReferenceDirectivesIfNecessary(directives);
74+
}
75+
// Otherwise we should emit a path-based reference
7076
const container = getSourceFileOfNode(node);
7177
refs.set("" + getOriginalNodeId(container), container);
7278
}

src/compiler/transformers/es2015.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ namespace ts {
855855
if (extendsClauseElement) {
856856
statements.push(
857857
setTextRange(
858-
createStatement(
858+
createExpressionStatement(
859859
createExtendsHelper(context, getInternalName(node))
860860
),
861861
/*location*/ extendsClauseElement
@@ -1280,7 +1280,7 @@ namespace ts {
12801280
else if (initializer) {
12811281
statements.push(
12821282
setEmitFlags(
1283-
createStatement(
1283+
createExpressionStatement(
12841284
createAssignment(
12851285
temp,
12861286
visitNode(initializer, visitor, isExpression)
@@ -1307,7 +1307,7 @@ namespace ts {
13071307
setEmitFlags(
13081308
setTextRange(
13091309
createBlock([
1310-
createStatement(
1310+
createExpressionStatement(
13111311
setEmitFlags(
13121312
setTextRange(
13131313
createAssignment(
@@ -1409,7 +1409,7 @@ namespace ts {
14091409
createBlock([
14101410
startOnNewLine(
14111411
setTextRange(
1412-
createStatement(
1412+
createExpressionStatement(
14131413
createAssignment(
14141414
createElementAccess(
14151415
expressionName,
@@ -1594,7 +1594,7 @@ namespace ts {
15941594
setSourceMapRange(memberFunction, sourceMapRange);
15951595

15961596
const statement = setTextRange(
1597-
createStatement(
1597+
createExpressionStatement(
15981598
createAssignment(memberName, memberFunction)
15991599
),
16001600
/*location*/ member
@@ -1619,7 +1619,7 @@ namespace ts {
16191619
* @param accessors The set of related get/set accessors.
16201620
*/
16211621
function transformAccessorsToStatement(receiver: LeftHandSideExpression, accessors: AllAccessorDeclarations, container: Node): Statement {
1622-
const statement = createStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false));
1622+
const statement = createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, /*startsOnNewLine*/ false));
16231623
// The location for the statement is used to emit source maps only.
16241624
// No comments should be emitted for this statement to align with the
16251625
// old emitter.
@@ -1949,9 +1949,9 @@ namespace ts {
19491949
// If we are here it is most likely because our expression is a destructuring assignment.
19501950
switch (node.expression.kind) {
19511951
case SyntaxKind.ParenthesizedExpression:
1952-
return updateStatement(node, visitParenthesizedExpression(<ParenthesizedExpression>node.expression, /*needsDestructuringValue*/ false));
1952+
return updateExpressionStatement(node, visitParenthesizedExpression(<ParenthesizedExpression>node.expression, /*needsDestructuringValue*/ false));
19531953
case SyntaxKind.BinaryExpression:
1954-
return updateStatement(node, visitBinaryExpression(<BinaryExpression>node.expression, /*needsDestructuringValue*/ false));
1954+
return updateExpressionStatement(node, visitBinaryExpression(<BinaryExpression>node.expression, /*needsDestructuringValue*/ false));
19551955
}
19561956
return visitEachChild(node, visitor, context);
19571957
}
@@ -2026,7 +2026,7 @@ namespace ts {
20262026
}
20272027
}
20282028
if (assignments) {
2029-
updated = setTextRange(createStatement(inlineExpressions(assignments)), node);
2029+
updated = setTextRange(createExpressionStatement(inlineExpressions(assignments)), node);
20302030
}
20312031
else {
20322032
// none of declarations has initializer - the entire variable statement can be deleted
@@ -2330,11 +2330,11 @@ namespace ts {
23302330
const assignment = createAssignment(initializer, boundValue);
23312331
if (isDestructuringAssignment(assignment)) {
23322332
aggregateTransformFlags(assignment);
2333-
statements.push(createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false)));
2333+
statements.push(createExpressionStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false)));
23342334
}
23352335
else {
23362336
assignment.end = initializer.end;
2337-
statements.push(setTextRange(createStatement(visitNode(assignment, visitor, isExpression)), moveRangeEnd(initializer, -1)));
2337+
statements.push(setTextRange(createExpressionStatement(visitNode(assignment, visitor, isExpression)), moveRangeEnd(initializer, -1)));
23382338
}
23392339
}
23402340

@@ -2483,7 +2483,7 @@ namespace ts {
24832483
createCatchClause(createVariableDeclaration(catchVariable),
24842484
setEmitFlags(
24852485
createBlock([
2486-
createStatement(
2486+
createExpressionStatement(
24872487
createAssignment(
24882488
errorRecord,
24892489
createObjectLiteral([
@@ -2512,7 +2512,7 @@ namespace ts {
25122512
createPropertyAccess(iterator, "return")
25132513
)
25142514
),
2515-
createStatement(
2515+
createExpressionStatement(
25162516
createFunctionCall(returnMethod, iterator, [])
25172517
)
25182518
),
@@ -2868,7 +2868,7 @@ namespace ts {
28682868

28692869
function copyOutParameters(outParams: LoopOutParameter[], copyDirection: CopyDirection, statements: Statement[]): void {
28702870
for (const outParam of outParams) {
2871-
statements.push(createStatement(copyOutParameter(outParam, copyDirection)));
2871+
statements.push(createExpressionStatement(copyOutParameter(outParam, copyDirection)));
28722872
}
28732873
}
28742874

@@ -2892,7 +2892,7 @@ namespace ts {
28922892
)
28932893
: call;
28942894
if (isSimpleLoop) {
2895-
statements.push(createStatement(callResult));
2895+
statements.push(createExpressionStatement(callResult));
28962896
copyOutParameters(state.loopOutParameters!, CopyDirection.ToOriginal, statements);
28972897
}
28982898
else {
@@ -3358,7 +3358,7 @@ namespace ts {
33583358

33593359
// Add the class alias following the declaration.
33603360
statements.push(
3361-
createStatement(
3361+
createExpressionStatement(
33623362
createAssignment(
33633363
aliasAssignment.left,
33643364
cast(variable.name, isIdentifier)

src/compiler/transformers/es2017.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ namespace ts {
144144
function visitVariableStatementInAsyncBody(node: VariableStatement) {
145145
if (isVariableDeclarationListWithCollidingName(node.declarationList)) {
146146
const expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, /*hasReceiver*/ false);
147-
return expression ? createStatement(expression) : undefined;
147+
return expression ? createExpressionStatement(expression) : undefined;
148148
}
149149
return visitEachChild(node, visitor, context);
150150
}

src/compiler/transformers/esnext.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ namespace ts {
446446
createVariableDeclaration(catchVariable),
447447
setEmitFlags(
448448
createBlock([
449-
createStatement(
449+
createExpressionStatement(
450450
createAssignment(
451451
errorRecord,
452452
createObjectLiteral([
@@ -473,7 +473,7 @@ namespace ts {
473473
createPropertyAccess(iterator, "return")
474474
)
475475
),
476-
createStatement(createDownlevelAwait(callReturn))
476+
createExpressionStatement(createDownlevelAwait(callReturn))
477477
),
478478
EmitFlags.SingleLine
479479
)

0 commit comments

Comments
 (0)