typescript 4.7.0-dev.20220419 → 4.7.0-dev.20220422
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +149 -81
- package/lib/tsserver.js +197 -98
- package/lib/tsserverlibrary.d.ts +3 -1
- package/lib/tsserverlibrary.js +197 -98
- package/lib/typescript.d.ts +3 -1
- package/lib/typescript.js +197 -98
- package/lib/typescriptServices.d.ts +3 -1
- package/lib/typescriptServices.js +197 -98
- package/lib/typingsInstaller.js +169 -95
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220422";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -18487,10 +18487,10 @@ var ts;
|
|
|
18487
18487
|
return ts.combinePaths(newDirPath, sourceFilePath);
|
|
18488
18488
|
}
|
|
18489
18489
|
ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
|
|
18490
|
-
function writeFile(host, diagnostics, fileName,
|
|
18491
|
-
host.writeFile(fileName,
|
|
18490
|
+
function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
|
|
18491
|
+
host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) {
|
|
18492
18492
|
diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
|
|
18493
|
-
}, sourceFiles);
|
|
18493
|
+
}, sourceFiles, data);
|
|
18494
18494
|
}
|
|
18495
18495
|
ts.writeFile = writeFile;
|
|
18496
18496
|
function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
|
|
@@ -73626,6 +73626,7 @@ var ts;
|
|
|
73626
73626
|
}
|
|
73627
73627
|
}
|
|
73628
73628
|
else {
|
|
73629
|
+
error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
|
|
73629
73630
|
typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
|
|
73630
73631
|
}
|
|
73631
73632
|
}
|
|
@@ -74456,10 +74457,15 @@ var ts;
|
|
|
74456
74457
|
prop = getPropertyOfType(apparentType, right.escapedText);
|
|
74457
74458
|
}
|
|
74458
74459
|
// In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums.
|
|
74460
|
+
// `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined
|
|
74461
|
+
// here even if `Foo` is not a const enum.
|
|
74462
|
+
//
|
|
74459
74463
|
// The exceptions are:
|
|
74460
74464
|
// 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and
|
|
74461
74465
|
// 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`.
|
|
74462
|
-
if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
|
|
74466
|
+
if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
|
|
74467
|
+
!(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && node.parent.kind === 299 /* EnumMember */)) ||
|
|
74468
|
+
ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
|
|
74463
74469
|
markAliasReferenced(parentSymbol, node);
|
|
74464
74470
|
}
|
|
74465
74471
|
var propType;
|
|
@@ -86194,15 +86200,20 @@ var ts;
|
|
|
86194
86200
|
return propertyDeclaration;
|
|
86195
86201
|
}
|
|
86196
86202
|
}
|
|
86197
|
-
else if (ts.isMetaProperty(parent)) {
|
|
86198
|
-
|
|
86199
|
-
|
|
86200
|
-
if (propertyDeclaration) {
|
|
86201
|
-
return propertyDeclaration;
|
|
86202
|
-
}
|
|
86203
|
-
if (parent.keywordToken === 103 /* NewKeyword */) {
|
|
86203
|
+
else if (ts.isMetaProperty(parent) && parent.name === node) {
|
|
86204
|
+
if (parent.keywordToken === 103 /* NewKeyword */ && ts.idText(node) === "target") {
|
|
86205
|
+
// `target` in `new.target`
|
|
86204
86206
|
return checkNewTargetMetaProperty(parent).symbol;
|
|
86205
86207
|
}
|
|
86208
|
+
// The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but
|
|
86209
|
+
// we have a fake expression type made for other reasons already, whose transient `meta`
|
|
86210
|
+
// member should more exactly be the kind of (declarationless) symbol we want.
|
|
86211
|
+
// (See #44364 and #45031 for relevant implementation PRs)
|
|
86212
|
+
if (parent.keywordToken === 100 /* ImportKeyword */ && ts.idText(node) === "meta") {
|
|
86213
|
+
return getGlobalImportMetaExpressionType().members.get("meta");
|
|
86214
|
+
}
|
|
86215
|
+
// no other meta properties are valid syntax, thus no others should have symbols
|
|
86216
|
+
return undefined;
|
|
86206
86217
|
}
|
|
86207
86218
|
}
|
|
86208
86219
|
switch (node.kind) {
|
|
@@ -94880,7 +94891,7 @@ var ts;
|
|
|
94880
94891
|
}
|
|
94881
94892
|
resumeLexicalEnvironment();
|
|
94882
94893
|
var needsSyntheticConstructor = !constructor && isDerivedClass;
|
|
94883
|
-
var
|
|
94894
|
+
var indexOfFirstStatementAfterSuperAndPrologue = 0;
|
|
94884
94895
|
var prologueStatementCount = 0;
|
|
94885
94896
|
var superStatementIndex = -1;
|
|
94886
94897
|
var statements = [];
|
|
@@ -94889,8 +94900,11 @@ var ts;
|
|
|
94889
94900
|
superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
|
|
94890
94901
|
// If there was a super call, visit existing statements up to and including it
|
|
94891
94902
|
if (superStatementIndex >= 0) {
|
|
94892
|
-
|
|
94893
|
-
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount,
|
|
94903
|
+
indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
|
|
94904
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
|
|
94905
|
+
}
|
|
94906
|
+
else if (prologueStatementCount >= 0) {
|
|
94907
|
+
indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
|
|
94894
94908
|
}
|
|
94895
94909
|
}
|
|
94896
94910
|
if (needsSyntheticConstructor) {
|
|
@@ -94926,22 +94940,20 @@ var ts;
|
|
|
94926
94940
|
}
|
|
94927
94941
|
}
|
|
94928
94942
|
if (parameterPropertyDeclarationCount > 0) {
|
|
94929
|
-
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement,
|
|
94943
|
+
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
|
|
94930
94944
|
// If there was a super() call found, add parameter properties immediately after it
|
|
94931
94945
|
if (superStatementIndex >= 0) {
|
|
94932
94946
|
ts.addRange(statements, parameterProperties);
|
|
94933
94947
|
}
|
|
94934
|
-
// If a synthetic super() call was added, add them just after it
|
|
94935
|
-
else if (needsSyntheticConstructor) {
|
|
94936
|
-
statements = __spreadArray(__spreadArray([
|
|
94937
|
-
statements[0]
|
|
94938
|
-
], parameterProperties, true), statements.slice(1), true);
|
|
94939
|
-
}
|
|
94940
|
-
// Since there wasn't a super() call, add them to the top of the constructor
|
|
94941
94948
|
else {
|
|
94942
|
-
|
|
94949
|
+
// Add add parameter properties to the top of the constructor after the prologue
|
|
94950
|
+
var superAndPrologueStatementCount = prologueStatementCount;
|
|
94951
|
+
// If a synthetic super() call was added, need to account for that
|
|
94952
|
+
if (needsSyntheticConstructor)
|
|
94953
|
+
superAndPrologueStatementCount++;
|
|
94954
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
|
|
94943
94955
|
}
|
|
94944
|
-
|
|
94956
|
+
indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
|
|
94945
94957
|
}
|
|
94946
94958
|
}
|
|
94947
94959
|
}
|
|
@@ -94951,7 +94963,7 @@ var ts;
|
|
|
94951
94963
|
addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
|
|
94952
94964
|
// Add existing statements after the initial prologues and super call
|
|
94953
94965
|
if (constructor) {
|
|
94954
|
-
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement,
|
|
94966
|
+
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
|
|
94955
94967
|
}
|
|
94956
94968
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
94957
94969
|
return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
|
|
@@ -98992,7 +99004,7 @@ var ts;
|
|
|
98992
99004
|
// ```
|
|
98993
99005
|
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
98994
99006
|
}
|
|
98995
|
-
var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)),
|
|
99007
|
+
var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), true), statements, true)),
|
|
98996
99008
|
/*location*/ constructor.body.statements),
|
|
98997
99009
|
/*multiLine*/ true);
|
|
98998
99010
|
ts.setTextRange(body, constructor.body);
|
|
@@ -110149,6 +110161,7 @@ var ts;
|
|
|
110149
110161
|
else {
|
|
110150
110162
|
printer.writeFile(sourceFile, writer, sourceMapGenerator);
|
|
110151
110163
|
}
|
|
110164
|
+
var sourceMapUrlPos;
|
|
110152
110165
|
if (sourceMapGenerator) {
|
|
110153
110166
|
if (sourceMapDataList) {
|
|
110154
110167
|
sourceMapDataList.push({
|
|
@@ -110160,6 +110173,7 @@ var ts;
|
|
|
110160
110173
|
if (sourceMappingURL) {
|
|
110161
110174
|
if (!writer.isAtStartOfLine())
|
|
110162
110175
|
writer.rawWrite(newLine);
|
|
110176
|
+
sourceMapUrlPos = writer.getTextPos();
|
|
110163
110177
|
writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment
|
|
110164
110178
|
}
|
|
110165
110179
|
// Write the source map
|
|
@@ -110172,7 +110186,7 @@ var ts;
|
|
|
110172
110186
|
writer.writeLine();
|
|
110173
110187
|
}
|
|
110174
110188
|
// Write the output file
|
|
110175
|
-
ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
|
|
110189
|
+
ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
|
|
110176
110190
|
// Reset state
|
|
110177
110191
|
writer.clear();
|
|
110178
110192
|
}
|
|
@@ -115639,7 +115653,11 @@ var ts;
|
|
|
115639
115653
|
return newValue;
|
|
115640
115654
|
};
|
|
115641
115655
|
if (originalWriteFile) {
|
|
115642
|
-
host.writeFile = function (fileName, data
|
|
115656
|
+
host.writeFile = function (fileName, data) {
|
|
115657
|
+
var rest = [];
|
|
115658
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
115659
|
+
rest[_i - 2] = arguments[_i];
|
|
115660
|
+
}
|
|
115643
115661
|
var key = toPath(fileName);
|
|
115644
115662
|
fileExistsCache.delete(key);
|
|
115645
115663
|
var value = readFileCache.get(key);
|
|
@@ -115653,7 +115671,7 @@ var ts;
|
|
|
115653
115671
|
sourceFileCache.delete(key);
|
|
115654
115672
|
}
|
|
115655
115673
|
}
|
|
115656
|
-
originalWriteFile.call(host, fileName, data,
|
|
115674
|
+
originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
|
|
115657
115675
|
};
|
|
115658
115676
|
}
|
|
115659
115677
|
// directoryExists
|
|
@@ -116586,6 +116604,7 @@ var ts;
|
|
|
116586
116604
|
useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
|
|
116587
116605
|
getFileIncludeReasons: function () { return fileReasons; },
|
|
116588
116606
|
structureIsReused: structureIsReused,
|
|
116607
|
+
writeFile: writeFile,
|
|
116589
116608
|
};
|
|
116590
116609
|
onProgramCreateComplete();
|
|
116591
116610
|
// Add file processingDiagnostics
|
|
@@ -117083,7 +117102,7 @@ var ts;
|
|
|
117083
117102
|
getProjectReferenceRedirect: getProjectReferenceRedirect,
|
|
117084
117103
|
isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
|
|
117085
117104
|
getSymlinkCache: getSymlinkCache,
|
|
117086
|
-
writeFile: writeFileCallback ||
|
|
117105
|
+
writeFile: writeFileCallback || writeFile,
|
|
117087
117106
|
isEmitBlocked: isEmitBlocked,
|
|
117088
117107
|
readFile: function (f) { return host.readFile(f); },
|
|
117089
117108
|
fileExists: function (f) {
|
|
@@ -117103,6 +117122,9 @@ var ts;
|
|
|
117103
117122
|
getFileIncludeReasons: program.getFileIncludeReasons,
|
|
117104
117123
|
};
|
|
117105
117124
|
}
|
|
117125
|
+
function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
|
|
117126
|
+
host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
|
|
117127
|
+
}
|
|
117106
117128
|
function emitBuildInfo(writeFileCallback) {
|
|
117107
117129
|
ts.Debug.assert(!ts.outFile(options));
|
|
117108
117130
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
|
|
@@ -119545,6 +119567,7 @@ var ts;
|
|
|
119545
119567
|
}
|
|
119546
119568
|
}
|
|
119547
119569
|
}
|
|
119570
|
+
BuilderState.updateExportedModules = updateExportedModules;
|
|
119548
119571
|
/**
|
|
119549
119572
|
* Updates the exported modules from cache into state's exported modules map
|
|
119550
119573
|
* This should be called whenever it is safe to commit the state of the builder
|
|
@@ -119968,6 +119991,18 @@ var ts;
|
|
|
119968
119991
|
}
|
|
119969
119992
|
return undefined;
|
|
119970
119993
|
}
|
|
119994
|
+
function removeDiagnosticsOfLibraryFiles(state) {
|
|
119995
|
+
if (!state.cleanedDiagnosticsOfLibFiles) {
|
|
119996
|
+
state.cleanedDiagnosticsOfLibFiles = true;
|
|
119997
|
+
var program_1 = ts.Debug.checkDefined(state.program);
|
|
119998
|
+
var options_2 = program_1.getCompilerOptions();
|
|
119999
|
+
ts.forEach(program_1.getSourceFiles(), function (f) {
|
|
120000
|
+
return program_1.isSourceFileDefaultLibrary(f) &&
|
|
120001
|
+
!ts.skipTypeChecking(f, options_2, program_1) &&
|
|
120002
|
+
removeSemanticDiagnosticsOf(state, f.resolvedPath);
|
|
120003
|
+
});
|
|
120004
|
+
}
|
|
120005
|
+
}
|
|
119971
120006
|
/**
|
|
119972
120007
|
* Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
|
|
119973
120008
|
* This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
|
|
@@ -119977,28 +120012,17 @@ var ts;
|
|
|
119977
120012
|
removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
|
|
119978
120013
|
// If affected files is everything except default library, then nothing more to do
|
|
119979
120014
|
if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
|
|
119980
|
-
|
|
119981
|
-
state.cleanedDiagnosticsOfLibFiles = true;
|
|
119982
|
-
var program_1 = ts.Debug.checkDefined(state.program);
|
|
119983
|
-
var options_2 = program_1.getCompilerOptions();
|
|
119984
|
-
ts.forEach(program_1.getSourceFiles(), function (f) {
|
|
119985
|
-
return program_1.isSourceFileDefaultLibrary(f) &&
|
|
119986
|
-
!ts.skipTypeChecking(f, options_2, program_1) &&
|
|
119987
|
-
removeSemanticDiagnosticsOf(state, f.resolvedPath);
|
|
119988
|
-
});
|
|
119989
|
-
}
|
|
120015
|
+
removeDiagnosticsOfLibraryFiles(state);
|
|
119990
120016
|
// When a change affects the global scope, all files are considered to be affected without updating their signature
|
|
119991
120017
|
// That means when affected file is handled, its signature can be out of date
|
|
119992
120018
|
// To avoid this, ensure that we update the signature for any affected file in this scenario.
|
|
119993
120019
|
ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
|
|
119994
120020
|
return;
|
|
119995
120021
|
}
|
|
119996
|
-
|
|
119997
|
-
|
|
119998
|
-
|
|
119999
|
-
|
|
120000
|
-
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
|
|
120001
|
-
}
|
|
120022
|
+
ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
|
|
120023
|
+
if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
|
|
120024
|
+
return;
|
|
120025
|
+
handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
|
|
120002
120026
|
}
|
|
120003
120027
|
/**
|
|
120004
120028
|
* Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
|
|
@@ -120040,16 +120064,41 @@ var ts;
|
|
|
120040
120064
|
var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
|
|
120041
120065
|
return newSignature !== oldSignature;
|
|
120042
120066
|
}
|
|
120067
|
+
function forEachKeyOfExportedModulesMap(state, filePath, fn) {
|
|
120068
|
+
// Go through exported modules from cache first
|
|
120069
|
+
var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
|
|
120070
|
+
var result = keys && ts.forEachKey(keys, fn);
|
|
120071
|
+
if (result)
|
|
120072
|
+
return result;
|
|
120073
|
+
// If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
|
|
120074
|
+
keys = state.exportedModulesMap.getKeys(filePath);
|
|
120075
|
+
return keys && ts.forEachKey(keys, function (exportedFromPath) {
|
|
120076
|
+
var _a;
|
|
120077
|
+
// If the cache had an updated value, skip
|
|
120078
|
+
return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
|
|
120079
|
+
!((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
|
|
120080
|
+
fn(exportedFromPath) :
|
|
120081
|
+
undefined;
|
|
120082
|
+
});
|
|
120083
|
+
}
|
|
120084
|
+
function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
|
|
120085
|
+
var _a;
|
|
120086
|
+
if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
|
|
120087
|
+
return false;
|
|
120088
|
+
// Every file needs to be handled
|
|
120089
|
+
ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
|
|
120090
|
+
.forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
|
|
120091
|
+
removeDiagnosticsOfLibraryFiles(state);
|
|
120092
|
+
return true;
|
|
120093
|
+
}
|
|
120043
120094
|
/**
|
|
120044
|
-
* Iterate on referencing modules that export entities from affected file
|
|
120095
|
+
* Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
|
|
120045
120096
|
*/
|
|
120046
|
-
function
|
|
120047
|
-
var _a, _b;
|
|
120097
|
+
function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
|
|
120048
120098
|
// If there was change in signature (dts output) for the changed file,
|
|
120049
120099
|
// then only we need to handle pending file emit
|
|
120050
|
-
if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
|
|
120100
|
+
if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
|
|
120051
120101
|
return;
|
|
120052
|
-
}
|
|
120053
120102
|
if (!isChangedSignature(state, affectedFile.resolvedPath))
|
|
120054
120103
|
return;
|
|
120055
120104
|
// Since isolated modules dont change js files, files affected by change in signature is itself
|
|
@@ -120062,7 +120111,9 @@ var ts;
|
|
|
120062
120111
|
var currentPath = queue.pop();
|
|
120063
120112
|
if (!seenFileNamesMap.has(currentPath)) {
|
|
120064
120113
|
seenFileNamesMap.set(currentPath, true);
|
|
120065
|
-
|
|
120114
|
+
if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
|
|
120115
|
+
return;
|
|
120116
|
+
handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
|
|
120066
120117
|
if (isChangedSignature(state, currentPath)) {
|
|
120067
120118
|
var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
|
|
120068
120119
|
queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
|
|
@@ -120074,56 +120125,38 @@ var ts;
|
|
|
120074
120125
|
var seenFileAndExportsOfFile = new ts.Set();
|
|
120075
120126
|
// Go through exported modules from cache first
|
|
120076
120127
|
// If exported modules has path, all files referencing file exported from are affected
|
|
120077
|
-
(
|
|
120078
|
-
|
|
120079
|
-
|
|
120080
|
-
|
|
120081
|
-
|
|
120082
|
-
|
|
120083
|
-
|
|
120084
|
-
return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
|
|
120085
|
-
!((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
|
|
120086
|
-
forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
|
|
120128
|
+
forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
|
|
120129
|
+
if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
|
|
120130
|
+
return true;
|
|
120131
|
+
var references = state.referencedMap.getKeys(exportedFromPath);
|
|
120132
|
+
return references && ts.forEachKey(references, function (filePath) {
|
|
120133
|
+
return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
|
|
120134
|
+
});
|
|
120087
120135
|
});
|
|
120088
120136
|
}
|
|
120089
120137
|
/**
|
|
120090
|
-
*
|
|
120138
|
+
* handle dts and semantic diagnostics on file and iterate on anything that exports this file
|
|
120139
|
+
* return true when all work is done and we can exit handling dts emit and semantic diagnostics
|
|
120091
120140
|
*/
|
|
120092
|
-
function
|
|
120141
|
+
function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
|
|
120093
120142
|
var _a;
|
|
120094
|
-
|
|
120095
|
-
return
|
|
120096
|
-
|
|
120097
|
-
|
|
120098
|
-
|
|
120099
|
-
* fn on file and iterate on anything that exports this file
|
|
120100
|
-
*/
|
|
120101
|
-
function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
|
|
120102
|
-
var _a, _b, _c;
|
|
120103
|
-
if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
|
|
120104
|
-
return;
|
|
120105
|
-
}
|
|
120106
|
-
fn(state, filePath);
|
|
120143
|
+
if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
|
|
120144
|
+
return undefined;
|
|
120145
|
+
if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
|
|
120146
|
+
return true;
|
|
120147
|
+
handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
|
|
120107
120148
|
ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
|
|
120108
|
-
// Go through exported modules from cache first
|
|
120109
120149
|
// If exported modules has path, all files referencing file exported from are affected
|
|
120110
|
-
(
|
|
120111
|
-
return
|
|
120112
|
-
});
|
|
120113
|
-
// If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
|
|
120114
|
-
(_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
|
|
120115
|
-
var _a;
|
|
120116
|
-
// If the cache had an updated value, skip
|
|
120117
|
-
return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
|
|
120118
|
-
!((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
|
|
120119
|
-
forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
|
|
120150
|
+
forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
|
|
120151
|
+
return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
|
|
120120
120152
|
});
|
|
120121
120153
|
// Remove diagnostics of files that import this file (without going to exports of referencing files)
|
|
120122
|
-
(
|
|
120154
|
+
(_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
|
|
120123
120155
|
return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
|
|
120124
|
-
|
|
120125
|
-
|
|
120126
|
-
);
|
|
120156
|
+
handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
|
|
120157
|
+
state, referencingFilePath, cancellationToken, computeHash, host);
|
|
120158
|
+
});
|
|
120159
|
+
return undefined;
|
|
120127
120160
|
}
|
|
120128
120161
|
/**
|
|
120129
120162
|
* This is called after completing operation on the next affected file.
|
|
@@ -120499,7 +120532,43 @@ var ts;
|
|
|
120499
120532
|
return toAffectedFileEmitResult(state,
|
|
120500
120533
|
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
|
|
120501
120534
|
// Otherwise just affected file
|
|
120502
|
-
ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected,
|
|
120535
|
+
ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
|
|
120536
|
+
getWriteFileUpdatingSignatureCallback(writeFile) :
|
|
120537
|
+
writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
|
|
120538
|
+
}
|
|
120539
|
+
function getWriteFileUpdatingSignatureCallback(writeFile) {
|
|
120540
|
+
return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
|
|
120541
|
+
var _a;
|
|
120542
|
+
if (ts.isDeclarationFileName(fileName)) {
|
|
120543
|
+
ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
|
|
120544
|
+
var file = sourceFiles[0];
|
|
120545
|
+
var info = state.fileInfos.get(file.resolvedPath);
|
|
120546
|
+
var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
|
|
120547
|
+
if (signature === file.version) {
|
|
120548
|
+
var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
|
|
120549
|
+
if (newSignature !== file.version) { // Update it
|
|
120550
|
+
if (host.storeFilesChangingSignatureDuringEmit)
|
|
120551
|
+
(state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
|
|
120552
|
+
if (state.exportedModulesMap)
|
|
120553
|
+
ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
|
|
120554
|
+
if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
|
|
120555
|
+
state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
|
|
120556
|
+
}
|
|
120557
|
+
else {
|
|
120558
|
+
info.signature = newSignature;
|
|
120559
|
+
if (state.exportedModulesMap)
|
|
120560
|
+
ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
|
|
120561
|
+
}
|
|
120562
|
+
}
|
|
120563
|
+
}
|
|
120564
|
+
}
|
|
120565
|
+
if (writeFile)
|
|
120566
|
+
writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
|
|
120567
|
+
else if (host.writeFile)
|
|
120568
|
+
host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
|
|
120569
|
+
else
|
|
120570
|
+
state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
|
|
120571
|
+
};
|
|
120503
120572
|
}
|
|
120504
120573
|
/**
|
|
120505
120574
|
* Emits the JavaScript and declaration files.
|
|
@@ -120556,7 +120625,9 @@ var ts;
|
|
|
120556
120625
|
}
|
|
120557
120626
|
}
|
|
120558
120627
|
}
|
|
120559
|
-
return ts.Debug.checkDefined(state.program).emit(targetSourceFile,
|
|
120628
|
+
return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
|
|
120629
|
+
getWriteFileUpdatingSignatureCallback(writeFile) :
|
|
120630
|
+
writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
120560
120631
|
}
|
|
120561
120632
|
/**
|
|
120562
120633
|
* Return the semantic diagnostics for the next affected file or undefined if iteration is complete
|
|
@@ -122748,6 +122819,7 @@ var ts;
|
|
|
122748
122819
|
createHash: ts.maybeBind(host, host.createHash),
|
|
122749
122820
|
readDirectory: ts.maybeBind(host, host.readDirectory),
|
|
122750
122821
|
disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
|
|
122822
|
+
storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
|
|
122751
122823
|
};
|
|
122752
122824
|
function writeFile(fileName, text, writeByteOrderMark, onError) {
|
|
122753
122825
|
try {
|
|
@@ -122807,6 +122879,7 @@ var ts;
|
|
|
122807
122879
|
createHash: ts.maybeBind(system, system.createHash),
|
|
122808
122880
|
createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
|
|
122809
122881
|
disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
|
|
122882
|
+
storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
|
|
122810
122883
|
};
|
|
122811
122884
|
}
|
|
122812
122885
|
ts.createProgramHost = createProgramHost;
|
|
@@ -122895,6 +122968,7 @@ var ts;
|
|
|
122895
122968
|
var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system);
|
|
122896
122969
|
host.createHash = ts.maybeBind(system, system.createHash);
|
|
122897
122970
|
host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
|
|
122971
|
+
host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
|
|
122898
122972
|
ts.setGetSourceFileAsHashVersioned(host, system);
|
|
122899
122973
|
ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
|
|
122900
122974
|
return host;
|
|
@@ -132380,22 +132454,44 @@ var ts;
|
|
|
132380
132454
|
}
|
|
132381
132455
|
}
|
|
132382
132456
|
function createSnippetPrinter(printerOptions) {
|
|
132457
|
+
var escapes;
|
|
132383
132458
|
var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
|
|
132384
132459
|
var printer = ts.createPrinter(printerOptions, baseWriter);
|
|
132385
|
-
var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(
|
|
132460
|
+
var writer = __assign(__assign({}, baseWriter), { write: function (s) { return escapingWrite(s, function () { return baseWriter.write(s); }); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeLiteral(s); }); }, writeStringLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeStringLiteral(s); }); }, writeSymbol: function (s, symbol) { return escapingWrite(s, function () { return baseWriter.writeSymbol(s, symbol); }); }, writeParameter: function (s) { return escapingWrite(s, function () { return baseWriter.writeParameter(s); }); }, writeComment: function (s) { return escapingWrite(s, function () { return baseWriter.writeComment(s); }); }, writeProperty: function (s) { return escapingWrite(s, function () { return baseWriter.writeProperty(s); }); } });
|
|
132386
132461
|
return {
|
|
132387
132462
|
printSnippetList: printSnippetList,
|
|
132388
132463
|
printAndFormatSnippetList: printAndFormatSnippetList,
|
|
132389
132464
|
};
|
|
132465
|
+
// The formatter/scanner will have issues with snippet-escaped text,
|
|
132466
|
+
// so instead of writing the escaped text directly to the writer,
|
|
132467
|
+
// generate a set of changes that can be applied to the unescaped text
|
|
132468
|
+
// to escape it post-formatting.
|
|
132469
|
+
function escapingWrite(s, write) {
|
|
132470
|
+
var escaped = ts.escapeSnippetText(s);
|
|
132471
|
+
if (escaped !== s) {
|
|
132472
|
+
var start = baseWriter.getTextPos();
|
|
132473
|
+
write();
|
|
132474
|
+
var end = baseWriter.getTextPos();
|
|
132475
|
+
escapes = ts.append(escapes || (escapes = []), { newText: escaped, span: { start: start, length: end - start } });
|
|
132476
|
+
}
|
|
132477
|
+
else {
|
|
132478
|
+
write();
|
|
132479
|
+
}
|
|
132480
|
+
}
|
|
132390
132481
|
/* Snippet-escaping version of `printer.printList`. */
|
|
132391
132482
|
function printSnippetList(format, list, sourceFile) {
|
|
132483
|
+
var unescaped = printUnescapedSnippetList(format, list, sourceFile);
|
|
132484
|
+
return escapes ? ts.textChanges.applyChanges(unescaped, escapes) : unescaped;
|
|
132485
|
+
}
|
|
132486
|
+
function printUnescapedSnippetList(format, list, sourceFile) {
|
|
132487
|
+
escapes = undefined;
|
|
132392
132488
|
writer.clear();
|
|
132393
132489
|
printer.writeList(format, list, sourceFile, writer);
|
|
132394
132490
|
return writer.getText();
|
|
132395
132491
|
}
|
|
132396
132492
|
function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
|
|
132397
132493
|
var syntheticFile = {
|
|
132398
|
-
text:
|
|
132494
|
+
text: printUnescapedSnippetList(format, list, sourceFile),
|
|
132399
132495
|
getLineAndCharacterOfPosition: function (pos) {
|
|
132400
132496
|
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
132401
132497
|
},
|
|
@@ -132407,7 +132503,10 @@ var ts;
|
|
|
132407
132503
|
/* indentation */ 0,
|
|
132408
132504
|
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
|
|
132409
132505
|
});
|
|
132410
|
-
|
|
132506
|
+
var allChanges = escapes
|
|
132507
|
+
? ts.stableSort(ts.concatenate(changes, escapes), function (a, b) { return ts.compareTextSpans(a.span, b.span); })
|
|
132508
|
+
: changes;
|
|
132509
|
+
return ts.textChanges.applyChanges(syntheticFile.text, allChanges);
|
|
132411
132510
|
}
|
|
132412
132511
|
}
|
|
132413
132512
|
function originToCompletionEntryData(origin) {
|
|
@@ -2172,7 +2172,9 @@ declare namespace ts {
|
|
|
2172
2172
|
export type ResolvedConfigFileName = string & {
|
|
2173
2173
|
_isResolvedConfigFileName: never;
|
|
2174
2174
|
};
|
|
2175
|
-
export
|
|
2175
|
+
export interface WriteFileCallbackData {
|
|
2176
|
+
}
|
|
2177
|
+
export type WriteFileCallback = (fileName: string, text: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[], data?: WriteFileCallbackData) => void;
|
|
2176
2178
|
export class OperationCanceledException {
|
|
2177
2179
|
}
|
|
2178
2180
|
export interface CancellationToken {
|