Skip to content

Commit 1d34778

Browse files
committed
Merge branch 'master' into no-did-you-mean-to-call-error-on-casts
2 parents 214ef0c + e72c015 commit 1d34778

File tree

561 files changed

+5187
-7818
lines changed

Some content is hidden

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

561 files changed

+5187
-7818
lines changed

package-lock.json

Lines changed: 149 additions & 203 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript",
33
"author": "Microsoft Corp.",
44
"homepage": "https://www.typescriptlang.org/",
5-
"version": "4.2.0",
5+
"version": "4.3.0",
66
"license": "Apache-2.0",
77
"description": "TypeScript is a language for application scale JavaScript development",
88
"keywords": [
@@ -127,5 +127,8 @@
127127
"source-map-support": false,
128128
"inspector": false
129129
},
130+
"volta": {
131+
"node": "14.15.5"
132+
},
130133
"dependencies": {}
131134
}

src/compiler/binder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,14 @@ namespace ts {
174174
const binder = createBinder();
175175

176176
export function bindSourceFile(file: SourceFile, options: CompilerOptions) {
177-
tracing.push(tracing.Phase.Bind, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
177+
tracing?.push(tracing.Phase.Bind, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
178178
performance.mark("beforeBind");
179179
perfLogger.logStartBindFile("" + file.fileName);
180180
binder(file, options);
181181
perfLogger.logStopBindFile();
182182
performance.mark("afterBind");
183183
performance.measure("Bind", "beforeBind", "afterBind");
184-
tracing.pop();
184+
tracing?.pop();
185185
}
186186

187187
function createBinder(): (file: SourceFile, options: CompilerOptions) => void {

src/compiler/checker.ts

Lines changed: 136 additions & 145 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,14 +2617,17 @@ namespace ts {
26172617
if (ownConfig.extendedConfigPath) {
26182618
// copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios.
26192619
resolutionStack = resolutionStack.concat([resolvedPath]);
2620-
const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache);
2620+
const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, resolutionStack, errors, extendedConfigCache);
26212621
if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
26222622
const baseRaw = extendedConfig.raw;
26232623
const raw = ownConfig.raw;
2624+
let relativeDifference: string | undefined ;
26242625
const setPropertyInRawIfNotUndefined = (propertyName: string) => {
2625-
const value = raw[propertyName] || baseRaw[propertyName];
2626-
if (value) {
2627-
raw[propertyName] = value;
2626+
if (!raw[propertyName] && baseRaw[propertyName]) {
2627+
raw[propertyName] = map(baseRaw[propertyName], (path: string) => isRootedDiskPath(path) ? path : combinePaths(
2628+
relativeDifference ||= convertToRelativePath(getDirectoryPath(ownConfig.extendedConfigPath!), basePath, createGetCanonicalFileName(host.useCaseSensitiveFileNames)),
2629+
path
2630+
));
26282631
}
26292632
};
26302633
setPropertyInRawIfNotUndefined("include");
@@ -2786,7 +2789,6 @@ namespace ts {
27862789
sourceFile: TsConfigSourceFile | undefined,
27872790
extendedConfigPath: string,
27882791
host: ParseConfigHost,
2789-
basePath: string,
27902792
resolutionStack: string[],
27912793
errors: Push<Diagnostic>,
27922794
extendedConfigCache?: ESMap<string, ExtendedConfigCacheEntry>
@@ -2801,25 +2803,8 @@ namespace ts {
28012803
else {
28022804
extendedResult = readJsonConfigFile(extendedConfigPath, path => host.readFile(path));
28032805
if (!extendedResult.parseDiagnostics.length) {
2804-
const extendedDirname = getDirectoryPath(extendedConfigPath);
2805-
extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname,
2806+
extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, getDirectoryPath(extendedConfigPath),
28062807
getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache);
2807-
2808-
if (isSuccessfulParsedTsconfig(extendedConfig)) {
2809-
// Update the paths to reflect base path
2810-
const relativeDifference = convertToRelativePath(extendedDirname, basePath, identity);
2811-
const updatePath = (path: string) => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path);
2812-
const mapPropertiesInRawIfNotUndefined = (propertyName: string) => {
2813-
if (raw[propertyName]) {
2814-
raw[propertyName] = map(raw[propertyName], updatePath);
2815-
}
2816-
};
2817-
2818-
const { raw } = extendedConfig;
2819-
mapPropertiesInRawIfNotUndefined("include");
2820-
mapPropertiesInRawIfNotUndefined("exclude");
2821-
mapPropertiesInRawIfNotUndefined("files");
2822-
}
28232808
}
28242809
if (extendedConfigCache) {
28252810
extendedConfigCache.set(path, { extendedResult, extendedConfig });

src/compiler/corePublic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace ts {
22
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
33
// If changing the text in this section, be sure to test `configurePrerelease` too.
4-
export const versionMajorMinor = "4.2";
4+
export const versionMajorMinor = "4.3";
55
// The following is baselined as a literal template type without intervention
66
/** The version of the TypeScript compiler release */
77
// eslint-disable-next-line @typescript-eslint/no-inferrable-types

src/compiler/emitter.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,17 @@ namespace ts {
340340
sourceFiles: sourceFileOrBundle.sourceFiles.map(file => relativeToBuildInfo(getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())))
341341
};
342342
}
343-
tracing.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
343+
tracing?.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
344344
emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
345-
tracing.pop();
345+
tracing?.pop();
346346

347-
tracing.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
347+
tracing?.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
348348
emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
349-
tracing.pop();
349+
tracing?.pop();
350350

351-
tracing.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
351+
tracing?.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
352352
emitBuildInfo(bundleBuildInfo, buildInfoPath);
353-
tracing.pop();
353+
tracing?.pop();
354354

355355
if (!emitSkipped && emittedFilesList) {
356356
if (!emitOnlyDtsFiles) {

src/compiler/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ namespace ts {
607607
}
608608

609609
export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false, scriptKind?: ScriptKind): SourceFile {
610-
tracing.push(tracing.Phase.Parse, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
610+
tracing?.push(tracing.Phase.Parse, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
611611
performance.mark("beforeParse");
612612
let result: SourceFile;
613613

@@ -622,7 +622,7 @@ namespace ts {
622622

623623
performance.mark("afterParse");
624624
performance.measure("Parse", "beforeParse", "afterParse");
625-
tracing.pop();
625+
tracing?.pop();
626626
return result;
627627
}
628628

src/compiler/program.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ namespace ts {
407407
const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
408408
let lineContent = file.text.slice(lineStart, lineEnd);
409409
lineContent = lineContent.replace(/\s+$/g, ""); // trim from end
410-
lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces
410+
lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces
411411

412412
// Output the gutter and the actual contents of the line.
413413
context += indent + formatColorAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
@@ -833,7 +833,7 @@ namespace ts {
833833
// Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
834834
const sourceFilesFoundSearchingNodeModules = new Map<string, boolean>();
835835

836-
tracing.push(tracing.Phase.Program, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true);
836+
tracing?.push(tracing.Phase.Program, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true);
837837
performance.mark("beforeProgram");
838838

839839
const host = createProgramOptions.host || createCompilerHost(options);
@@ -919,15 +919,15 @@ namespace ts {
919919
forEachResolvedProjectReference
920920
});
921921

922-
tracing.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
922+
tracing?.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
923923
const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
924-
tracing.pop();
924+
tracing?.pop();
925925
// We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks
926926
// `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`.
927927
let structureIsReused: StructureIsReused;
928-
tracing.push(tracing.Phase.Program, "tryReuseStructureFromOldProgram", {});
928+
tracing?.push(tracing.Phase.Program, "tryReuseStructureFromOldProgram", {});
929929
structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const
930-
tracing.pop();
930+
tracing?.pop();
931931
if (structureIsReused !== StructureIsReused.Completely) {
932932
processingDefaultLibFiles = [];
933933
processingOtherFiles = [];
@@ -964,23 +964,23 @@ namespace ts {
964964
}
965965
}
966966

967-
tracing.push(tracing.Phase.Program, "processRootFiles", { count: rootNames.length });
967+
tracing?.push(tracing.Phase.Program, "processRootFiles", { count: rootNames.length });
968968
forEach(rootNames, (name, index) => processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: FileIncludeKind.RootFile, index }));
969-
tracing.pop();
969+
tracing?.pop();
970970

971971
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
972972
const typeReferences: string[] = rootNames.length ? getAutomaticTypeDirectiveNames(options, host) : emptyArray;
973973

974974
if (typeReferences.length) {
975-
tracing.push(tracing.Phase.Program, "processTypeReferences", { count: typeReferences.length });
975+
tracing?.push(tracing.Phase.Program, "processTypeReferences", { count: typeReferences.length });
976976
// This containingFilename needs to match with the one used in managed-side
977977
const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
978978
const containingFilename = combinePaths(containingDirectory, inferredTypesContainingFile);
979979
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
980980
for (let i = 0; i < typeReferences.length; i++) {
981981
processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: resolutions[i]?.packageId });
982982
}
983-
tracing.pop();
983+
tracing?.pop();
984984
}
985985

986986
// Do not process the default library if:
@@ -1108,33 +1108,33 @@ namespace ts {
11081108
verifyCompilerOptions();
11091109
performance.mark("afterProgram");
11101110
performance.measure("Program", "beforeProgram", "afterProgram");
1111-
tracing.pop();
1111+
tracing?.pop();
11121112

11131113
return program;
11141114

11151115
function resolveModuleNamesWorker(moduleNames: string[], containingFile: SourceFile, reusedNames: string[] | undefined): readonly ResolvedModuleFull[] {
11161116
if (!moduleNames.length) return emptyArray;
11171117
const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
11181118
const redirectedReference = getRedirectReferenceForResolution(containingFile);
1119-
tracing.push(tracing.Phase.Program, "resolveModuleNamesWorker", { containingFileName });
1119+
tracing?.push(tracing.Phase.Program, "resolveModuleNamesWorker", { containingFileName });
11201120
performance.mark("beforeResolveModule");
11211121
const result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
11221122
performance.mark("afterResolveModule");
11231123
performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
1124-
tracing.pop();
1124+
tracing?.pop();
11251125
return result;
11261126
}
11271127

11281128
function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames: string[], containingFile: string | SourceFile): readonly (ResolvedTypeReferenceDirective | undefined)[] {
11291129
if (!typeDirectiveNames.length) return [];
11301130
const containingFileName = !isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
11311131
const redirectedReference = !isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
1132-
tracing.push(tracing.Phase.Program, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName });
1132+
tracing?.push(tracing.Phase.Program, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName });
11331133
performance.mark("beforeResolveTypeReference");
11341134
const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
11351135
performance.mark("afterResolveTypeReference");
11361136
performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
1137-
tracing.pop();
1137+
tracing?.pop();
11381138
return result;
11391139
}
11401140

@@ -1655,7 +1655,7 @@ namespace ts {
16551655

16561656
function emitBuildInfo(writeFileCallback?: WriteFileCallback): EmitResult {
16571657
Debug.assert(!outFile(options));
1658-
tracing.push(tracing.Phase.Emit, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
1658+
tracing?.push(tracing.Phase.Emit, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
16591659
performance.mark("beforeEmit");
16601660
const emitResult = emitFiles(
16611661
notImplementedResolver,
@@ -1668,7 +1668,7 @@ namespace ts {
16681668

16691669
performance.mark("afterEmit");
16701670
performance.measure("Emit", "beforeEmit", "afterEmit");
1671-
tracing.pop();
1671+
tracing?.pop();
16721672
return emitResult;
16731673
}
16741674

@@ -1729,9 +1729,9 @@ namespace ts {
17291729
}
17301730

17311731
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, transformers?: CustomTransformers, forceDtsEmit?: boolean): EmitResult {
1732-
tracing.push(tracing.Phase.Emit, "emit", { path: sourceFile?.path }, /*separateBeginAndEnd*/ true);
1732+
tracing?.push(tracing.Phase.Emit, "emit", { path: sourceFile?.path }, /*separateBeginAndEnd*/ true);
17331733
const result = runWithCancellationToken(() => emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit));
1734-
tracing.pop();
1734+
tracing?.pop();
17351735
return result;
17361736
}
17371737

@@ -2485,13 +2485,13 @@ namespace ts {
24852485

24862486
// Get source file from normalized fileName
24872487
function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, ignoreNoDefaultLib: boolean, reason: FileIncludeReason, packageId: PackageId | undefined): SourceFile | undefined {
2488-
tracing.push(tracing.Phase.Program, "findSourceFile", {
2488+
tracing?.push(tracing.Phase.Program, "findSourceFile", {
24892489
fileName,
24902490
isDefaultLib: isDefaultLib || undefined,
24912491
fileIncludeKind: (FileIncludeKind as any)[reason.kind],
24922492
});
24932493
const result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId);
2494-
tracing.pop();
2494+
tracing?.pop();
24952495
return result;
24962496
}
24972497

@@ -2792,9 +2792,9 @@ namespace ts {
27922792
resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined,
27932793
reason: FileIncludeReason
27942794
): void {
2795-
tracing.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
2795+
tracing?.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
27962796
processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
2797-
tracing.pop();
2797+
tracing?.pop();
27982798
}
27992799

28002800
function processTypeReferenceDirectiveWorker(

src/compiler/sys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ namespace ts {
15601560
return event === "rename" &&
15611561
(!relativeName ||
15621562
relativeName === lastDirectoryPart ||
1563-
relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator!) === relativeName.length - lastDirectoryPartWithDirectorySeparator!.length) &&
1563+
(relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator!) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator!) === relativeName.length - lastDirectoryPartWithDirectorySeparator!.length)) &&
15641564
!fileSystemEntryExists(fileOrDirectory, entryKind) ?
15651565
invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
15661566
callback(event, relativeName);

0 commit comments

Comments
 (0)