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/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220422";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -18293,10 +18293,10 @@ var ts;
|
|
|
18293
18293
|
return ts.combinePaths(newDirPath, sourceFilePath);
|
|
18294
18294
|
}
|
|
18295
18295
|
ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
|
|
18296
|
-
function writeFile(host, diagnostics, fileName,
|
|
18297
|
-
host.writeFile(fileName,
|
|
18296
|
+
function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
|
|
18297
|
+
host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) {
|
|
18298
18298
|
diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
|
|
18299
|
-
}, sourceFiles);
|
|
18299
|
+
}, sourceFiles, data);
|
|
18300
18300
|
}
|
|
18301
18301
|
ts.writeFile = writeFile;
|
|
18302
18302
|
function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
|
|
@@ -73432,6 +73432,7 @@ var ts;
|
|
|
73432
73432
|
}
|
|
73433
73433
|
}
|
|
73434
73434
|
else {
|
|
73435
|
+
error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
|
|
73435
73436
|
typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
|
|
73436
73437
|
}
|
|
73437
73438
|
}
|
|
@@ -74262,10 +74263,15 @@ var ts;
|
|
|
74262
74263
|
prop = getPropertyOfType(apparentType, right.escapedText);
|
|
74263
74264
|
}
|
|
74264
74265
|
// In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums.
|
|
74266
|
+
// `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined
|
|
74267
|
+
// here even if `Foo` is not a const enum.
|
|
74268
|
+
//
|
|
74265
74269
|
// The exceptions are:
|
|
74266
74270
|
// 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and
|
|
74267
74271
|
// 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`.
|
|
74268
|
-
if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
|
|
74272
|
+
if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
|
|
74273
|
+
!(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && node.parent.kind === 299 /* EnumMember */)) ||
|
|
74274
|
+
ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
|
|
74269
74275
|
markAliasReferenced(parentSymbol, node);
|
|
74270
74276
|
}
|
|
74271
74277
|
var propType;
|
|
@@ -86000,15 +86006,20 @@ var ts;
|
|
|
86000
86006
|
return propertyDeclaration;
|
|
86001
86007
|
}
|
|
86002
86008
|
}
|
|
86003
|
-
else if (ts.isMetaProperty(parent)) {
|
|
86004
|
-
|
|
86005
|
-
|
|
86006
|
-
if (propertyDeclaration) {
|
|
86007
|
-
return propertyDeclaration;
|
|
86008
|
-
}
|
|
86009
|
-
if (parent.keywordToken === 103 /* NewKeyword */) {
|
|
86009
|
+
else if (ts.isMetaProperty(parent) && parent.name === node) {
|
|
86010
|
+
if (parent.keywordToken === 103 /* NewKeyword */ && ts.idText(node) === "target") {
|
|
86011
|
+
// `target` in `new.target`
|
|
86010
86012
|
return checkNewTargetMetaProperty(parent).symbol;
|
|
86011
86013
|
}
|
|
86014
|
+
// The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but
|
|
86015
|
+
// we have a fake expression type made for other reasons already, whose transient `meta`
|
|
86016
|
+
// member should more exactly be the kind of (declarationless) symbol we want.
|
|
86017
|
+
// (See #44364 and #45031 for relevant implementation PRs)
|
|
86018
|
+
if (parent.keywordToken === 100 /* ImportKeyword */ && ts.idText(node) === "meta") {
|
|
86019
|
+
return getGlobalImportMetaExpressionType().members.get("meta");
|
|
86020
|
+
}
|
|
86021
|
+
// no other meta properties are valid syntax, thus no others should have symbols
|
|
86022
|
+
return undefined;
|
|
86012
86023
|
}
|
|
86013
86024
|
}
|
|
86014
86025
|
switch (node.kind) {
|
|
@@ -94686,7 +94697,7 @@ var ts;
|
|
|
94686
94697
|
}
|
|
94687
94698
|
resumeLexicalEnvironment();
|
|
94688
94699
|
var needsSyntheticConstructor = !constructor && isDerivedClass;
|
|
94689
|
-
var
|
|
94700
|
+
var indexOfFirstStatementAfterSuperAndPrologue = 0;
|
|
94690
94701
|
var prologueStatementCount = 0;
|
|
94691
94702
|
var superStatementIndex = -1;
|
|
94692
94703
|
var statements = [];
|
|
@@ -94695,8 +94706,11 @@ var ts;
|
|
|
94695
94706
|
superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
|
|
94696
94707
|
// If there was a super call, visit existing statements up to and including it
|
|
94697
94708
|
if (superStatementIndex >= 0) {
|
|
94698
|
-
|
|
94699
|
-
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount,
|
|
94709
|
+
indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
|
|
94710
|
+
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);
|
|
94711
|
+
}
|
|
94712
|
+
else if (prologueStatementCount >= 0) {
|
|
94713
|
+
indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
|
|
94700
94714
|
}
|
|
94701
94715
|
}
|
|
94702
94716
|
if (needsSyntheticConstructor) {
|
|
@@ -94732,22 +94746,20 @@ var ts;
|
|
|
94732
94746
|
}
|
|
94733
94747
|
}
|
|
94734
94748
|
if (parameterPropertyDeclarationCount > 0) {
|
|
94735
|
-
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement,
|
|
94749
|
+
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
|
|
94736
94750
|
// If there was a super() call found, add parameter properties immediately after it
|
|
94737
94751
|
if (superStatementIndex >= 0) {
|
|
94738
94752
|
ts.addRange(statements, parameterProperties);
|
|
94739
94753
|
}
|
|
94740
|
-
// If a synthetic super() call was added, add them just after it
|
|
94741
|
-
else if (needsSyntheticConstructor) {
|
|
94742
|
-
statements = __spreadArray(__spreadArray([
|
|
94743
|
-
statements[0]
|
|
94744
|
-
], parameterProperties, true), statements.slice(1), true);
|
|
94745
|
-
}
|
|
94746
|
-
// Since there wasn't a super() call, add them to the top of the constructor
|
|
94747
94754
|
else {
|
|
94748
|
-
|
|
94755
|
+
// Add add parameter properties to the top of the constructor after the prologue
|
|
94756
|
+
var superAndPrologueStatementCount = prologueStatementCount;
|
|
94757
|
+
// If a synthetic super() call was added, need to account for that
|
|
94758
|
+
if (needsSyntheticConstructor)
|
|
94759
|
+
superAndPrologueStatementCount++;
|
|
94760
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
|
|
94749
94761
|
}
|
|
94750
|
-
|
|
94762
|
+
indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
|
|
94751
94763
|
}
|
|
94752
94764
|
}
|
|
94753
94765
|
}
|
|
@@ -94757,7 +94769,7 @@ var ts;
|
|
|
94757
94769
|
addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
|
|
94758
94770
|
// Add existing statements after the initial prologues and super call
|
|
94759
94771
|
if (constructor) {
|
|
94760
|
-
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement,
|
|
94772
|
+
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
|
|
94761
94773
|
}
|
|
94762
94774
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
94763
94775
|
return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
|
|
@@ -98798,7 +98810,7 @@ var ts;
|
|
|
98798
98810
|
// ```
|
|
98799
98811
|
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
98800
98812
|
}
|
|
98801
|
-
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)),
|
|
98813
|
+
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)),
|
|
98802
98814
|
/*location*/ constructor.body.statements),
|
|
98803
98815
|
/*multiLine*/ true);
|
|
98804
98816
|
ts.setTextRange(body, constructor.body);
|
|
@@ -109955,6 +109967,7 @@ var ts;
|
|
|
109955
109967
|
else {
|
|
109956
109968
|
printer.writeFile(sourceFile, writer, sourceMapGenerator);
|
|
109957
109969
|
}
|
|
109970
|
+
var sourceMapUrlPos;
|
|
109958
109971
|
if (sourceMapGenerator) {
|
|
109959
109972
|
if (sourceMapDataList) {
|
|
109960
109973
|
sourceMapDataList.push({
|
|
@@ -109966,6 +109979,7 @@ var ts;
|
|
|
109966
109979
|
if (sourceMappingURL) {
|
|
109967
109980
|
if (!writer.isAtStartOfLine())
|
|
109968
109981
|
writer.rawWrite(newLine);
|
|
109982
|
+
sourceMapUrlPos = writer.getTextPos();
|
|
109969
109983
|
writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment
|
|
109970
109984
|
}
|
|
109971
109985
|
// Write the source map
|
|
@@ -109978,7 +109992,7 @@ var ts;
|
|
|
109978
109992
|
writer.writeLine();
|
|
109979
109993
|
}
|
|
109980
109994
|
// Write the output file
|
|
109981
|
-
ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
|
|
109995
|
+
ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
|
|
109982
109996
|
// Reset state
|
|
109983
109997
|
writer.clear();
|
|
109984
109998
|
}
|
|
@@ -115445,7 +115459,11 @@ var ts;
|
|
|
115445
115459
|
return newValue;
|
|
115446
115460
|
};
|
|
115447
115461
|
if (originalWriteFile) {
|
|
115448
|
-
host.writeFile = function (fileName, data
|
|
115462
|
+
host.writeFile = function (fileName, data) {
|
|
115463
|
+
var rest = [];
|
|
115464
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
115465
|
+
rest[_i - 2] = arguments[_i];
|
|
115466
|
+
}
|
|
115449
115467
|
var key = toPath(fileName);
|
|
115450
115468
|
fileExistsCache.delete(key);
|
|
115451
115469
|
var value = readFileCache.get(key);
|
|
@@ -115459,7 +115477,7 @@ var ts;
|
|
|
115459
115477
|
sourceFileCache.delete(key);
|
|
115460
115478
|
}
|
|
115461
115479
|
}
|
|
115462
|
-
originalWriteFile.call(host, fileName, data,
|
|
115480
|
+
originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
|
|
115463
115481
|
};
|
|
115464
115482
|
}
|
|
115465
115483
|
// directoryExists
|
|
@@ -116392,6 +116410,7 @@ var ts;
|
|
|
116392
116410
|
useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
|
|
116393
116411
|
getFileIncludeReasons: function () { return fileReasons; },
|
|
116394
116412
|
structureIsReused: structureIsReused,
|
|
116413
|
+
writeFile: writeFile,
|
|
116395
116414
|
};
|
|
116396
116415
|
onProgramCreateComplete();
|
|
116397
116416
|
// Add file processingDiagnostics
|
|
@@ -116889,7 +116908,7 @@ var ts;
|
|
|
116889
116908
|
getProjectReferenceRedirect: getProjectReferenceRedirect,
|
|
116890
116909
|
isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
|
|
116891
116910
|
getSymlinkCache: getSymlinkCache,
|
|
116892
|
-
writeFile: writeFileCallback ||
|
|
116911
|
+
writeFile: writeFileCallback || writeFile,
|
|
116893
116912
|
isEmitBlocked: isEmitBlocked,
|
|
116894
116913
|
readFile: function (f) { return host.readFile(f); },
|
|
116895
116914
|
fileExists: function (f) {
|
|
@@ -116909,6 +116928,9 @@ var ts;
|
|
|
116909
116928
|
getFileIncludeReasons: program.getFileIncludeReasons,
|
|
116910
116929
|
};
|
|
116911
116930
|
}
|
|
116931
|
+
function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
|
|
116932
|
+
host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
|
|
116933
|
+
}
|
|
116912
116934
|
function emitBuildInfo(writeFileCallback) {
|
|
116913
116935
|
ts.Debug.assert(!ts.outFile(options));
|
|
116914
116936
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
|
|
@@ -119351,6 +119373,7 @@ var ts;
|
|
|
119351
119373
|
}
|
|
119352
119374
|
}
|
|
119353
119375
|
}
|
|
119376
|
+
BuilderState.updateExportedModules = updateExportedModules;
|
|
119354
119377
|
/**
|
|
119355
119378
|
* Updates the exported modules from cache into state's exported modules map
|
|
119356
119379
|
* This should be called whenever it is safe to commit the state of the builder
|
|
@@ -119774,6 +119797,18 @@ var ts;
|
|
|
119774
119797
|
}
|
|
119775
119798
|
return undefined;
|
|
119776
119799
|
}
|
|
119800
|
+
function removeDiagnosticsOfLibraryFiles(state) {
|
|
119801
|
+
if (!state.cleanedDiagnosticsOfLibFiles) {
|
|
119802
|
+
state.cleanedDiagnosticsOfLibFiles = true;
|
|
119803
|
+
var program_1 = ts.Debug.checkDefined(state.program);
|
|
119804
|
+
var options_2 = program_1.getCompilerOptions();
|
|
119805
|
+
ts.forEach(program_1.getSourceFiles(), function (f) {
|
|
119806
|
+
return program_1.isSourceFileDefaultLibrary(f) &&
|
|
119807
|
+
!ts.skipTypeChecking(f, options_2, program_1) &&
|
|
119808
|
+
removeSemanticDiagnosticsOf(state, f.resolvedPath);
|
|
119809
|
+
});
|
|
119810
|
+
}
|
|
119811
|
+
}
|
|
119777
119812
|
/**
|
|
119778
119813
|
* Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
|
|
119779
119814
|
* This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
|
|
@@ -119783,28 +119818,17 @@ var ts;
|
|
|
119783
119818
|
removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
|
|
119784
119819
|
// If affected files is everything except default library, then nothing more to do
|
|
119785
119820
|
if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
|
|
119786
|
-
|
|
119787
|
-
state.cleanedDiagnosticsOfLibFiles = true;
|
|
119788
|
-
var program_1 = ts.Debug.checkDefined(state.program);
|
|
119789
|
-
var options_2 = program_1.getCompilerOptions();
|
|
119790
|
-
ts.forEach(program_1.getSourceFiles(), function (f) {
|
|
119791
|
-
return program_1.isSourceFileDefaultLibrary(f) &&
|
|
119792
|
-
!ts.skipTypeChecking(f, options_2, program_1) &&
|
|
119793
|
-
removeSemanticDiagnosticsOf(state, f.resolvedPath);
|
|
119794
|
-
});
|
|
119795
|
-
}
|
|
119821
|
+
removeDiagnosticsOfLibraryFiles(state);
|
|
119796
119822
|
// When a change affects the global scope, all files are considered to be affected without updating their signature
|
|
119797
119823
|
// That means when affected file is handled, its signature can be out of date
|
|
119798
119824
|
// To avoid this, ensure that we update the signature for any affected file in this scenario.
|
|
119799
119825
|
ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
|
|
119800
119826
|
return;
|
|
119801
119827
|
}
|
|
119802
|
-
|
|
119803
|
-
|
|
119804
|
-
|
|
119805
|
-
|
|
119806
|
-
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
|
|
119807
|
-
}
|
|
119828
|
+
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);
|
|
119829
|
+
if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
|
|
119830
|
+
return;
|
|
119831
|
+
handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
|
|
119808
119832
|
}
|
|
119809
119833
|
/**
|
|
119810
119834
|
* Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
|
|
@@ -119846,16 +119870,41 @@ var ts;
|
|
|
119846
119870
|
var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
|
|
119847
119871
|
return newSignature !== oldSignature;
|
|
119848
119872
|
}
|
|
119873
|
+
function forEachKeyOfExportedModulesMap(state, filePath, fn) {
|
|
119874
|
+
// Go through exported modules from cache first
|
|
119875
|
+
var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
|
|
119876
|
+
var result = keys && ts.forEachKey(keys, fn);
|
|
119877
|
+
if (result)
|
|
119878
|
+
return result;
|
|
119879
|
+
// If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
|
|
119880
|
+
keys = state.exportedModulesMap.getKeys(filePath);
|
|
119881
|
+
return keys && ts.forEachKey(keys, function (exportedFromPath) {
|
|
119882
|
+
var _a;
|
|
119883
|
+
// If the cache had an updated value, skip
|
|
119884
|
+
return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
|
|
119885
|
+
!((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
|
|
119886
|
+
fn(exportedFromPath) :
|
|
119887
|
+
undefined;
|
|
119888
|
+
});
|
|
119889
|
+
}
|
|
119890
|
+
function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
|
|
119891
|
+
var _a;
|
|
119892
|
+
if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
|
|
119893
|
+
return false;
|
|
119894
|
+
// Every file needs to be handled
|
|
119895
|
+
ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
|
|
119896
|
+
.forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
|
|
119897
|
+
removeDiagnosticsOfLibraryFiles(state);
|
|
119898
|
+
return true;
|
|
119899
|
+
}
|
|
119849
119900
|
/**
|
|
119850
|
-
* Iterate on referencing modules that export entities from affected file
|
|
119901
|
+
* Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
|
|
119851
119902
|
*/
|
|
119852
|
-
function
|
|
119853
|
-
var _a, _b;
|
|
119903
|
+
function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
|
|
119854
119904
|
// If there was change in signature (dts output) for the changed file,
|
|
119855
119905
|
// then only we need to handle pending file emit
|
|
119856
|
-
if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
|
|
119906
|
+
if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
|
|
119857
119907
|
return;
|
|
119858
|
-
}
|
|
119859
119908
|
if (!isChangedSignature(state, affectedFile.resolvedPath))
|
|
119860
119909
|
return;
|
|
119861
119910
|
// Since isolated modules dont change js files, files affected by change in signature is itself
|
|
@@ -119868,7 +119917,9 @@ var ts;
|
|
|
119868
119917
|
var currentPath = queue.pop();
|
|
119869
119918
|
if (!seenFileNamesMap.has(currentPath)) {
|
|
119870
119919
|
seenFileNamesMap.set(currentPath, true);
|
|
119871
|
-
|
|
119920
|
+
if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
|
|
119921
|
+
return;
|
|
119922
|
+
handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
|
|
119872
119923
|
if (isChangedSignature(state, currentPath)) {
|
|
119873
119924
|
var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
|
|
119874
119925
|
queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
|
|
@@ -119880,56 +119931,38 @@ var ts;
|
|
|
119880
119931
|
var seenFileAndExportsOfFile = new ts.Set();
|
|
119881
119932
|
// Go through exported modules from cache first
|
|
119882
119933
|
// If exported modules has path, all files referencing file exported from are affected
|
|
119883
|
-
(
|
|
119884
|
-
|
|
119885
|
-
|
|
119886
|
-
|
|
119887
|
-
|
|
119888
|
-
|
|
119889
|
-
|
|
119890
|
-
return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
|
|
119891
|
-
!((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
|
|
119892
|
-
forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
|
|
119934
|
+
forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
|
|
119935
|
+
if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
|
|
119936
|
+
return true;
|
|
119937
|
+
var references = state.referencedMap.getKeys(exportedFromPath);
|
|
119938
|
+
return references && ts.forEachKey(references, function (filePath) {
|
|
119939
|
+
return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
|
|
119940
|
+
});
|
|
119893
119941
|
});
|
|
119894
119942
|
}
|
|
119895
119943
|
/**
|
|
119896
|
-
*
|
|
119944
|
+
* handle dts and semantic diagnostics on file and iterate on anything that exports this file
|
|
119945
|
+
* return true when all work is done and we can exit handling dts emit and semantic diagnostics
|
|
119897
119946
|
*/
|
|
119898
|
-
function
|
|
119947
|
+
function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
|
|
119899
119948
|
var _a;
|
|
119900
|
-
|
|
119901
|
-
return
|
|
119902
|
-
|
|
119903
|
-
|
|
119904
|
-
|
|
119905
|
-
* fn on file and iterate on anything that exports this file
|
|
119906
|
-
*/
|
|
119907
|
-
function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
|
|
119908
|
-
var _a, _b, _c;
|
|
119909
|
-
if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
|
|
119910
|
-
return;
|
|
119911
|
-
}
|
|
119912
|
-
fn(state, filePath);
|
|
119949
|
+
if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
|
|
119950
|
+
return undefined;
|
|
119951
|
+
if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
|
|
119952
|
+
return true;
|
|
119953
|
+
handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
|
|
119913
119954
|
ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
|
|
119914
|
-
// Go through exported modules from cache first
|
|
119915
119955
|
// If exported modules has path, all files referencing file exported from are affected
|
|
119916
|
-
(
|
|
119917
|
-
return
|
|
119918
|
-
});
|
|
119919
|
-
// If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
|
|
119920
|
-
(_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
|
|
119921
|
-
var _a;
|
|
119922
|
-
// If the cache had an updated value, skip
|
|
119923
|
-
return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
|
|
119924
|
-
!((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
|
|
119925
|
-
forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
|
|
119956
|
+
forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
|
|
119957
|
+
return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
|
|
119926
119958
|
});
|
|
119927
119959
|
// Remove diagnostics of files that import this file (without going to exports of referencing files)
|
|
119928
|
-
(
|
|
119960
|
+
(_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
|
|
119929
119961
|
return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
|
|
119930
|
-
|
|
119931
|
-
|
|
119932
|
-
);
|
|
119962
|
+
handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
|
|
119963
|
+
state, referencingFilePath, cancellationToken, computeHash, host);
|
|
119964
|
+
});
|
|
119965
|
+
return undefined;
|
|
119933
119966
|
}
|
|
119934
119967
|
/**
|
|
119935
119968
|
* This is called after completing operation on the next affected file.
|
|
@@ -120305,7 +120338,43 @@ var ts;
|
|
|
120305
120338
|
return toAffectedFileEmitResult(state,
|
|
120306
120339
|
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
|
|
120307
120340
|
// Otherwise just affected file
|
|
120308
|
-
ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected,
|
|
120341
|
+
ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
|
|
120342
|
+
getWriteFileUpdatingSignatureCallback(writeFile) :
|
|
120343
|
+
writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
|
|
120344
|
+
}
|
|
120345
|
+
function getWriteFileUpdatingSignatureCallback(writeFile) {
|
|
120346
|
+
return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
|
|
120347
|
+
var _a;
|
|
120348
|
+
if (ts.isDeclarationFileName(fileName)) {
|
|
120349
|
+
ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
|
|
120350
|
+
var file = sourceFiles[0];
|
|
120351
|
+
var info = state.fileInfos.get(file.resolvedPath);
|
|
120352
|
+
var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
|
|
120353
|
+
if (signature === file.version) {
|
|
120354
|
+
var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
|
|
120355
|
+
if (newSignature !== file.version) { // Update it
|
|
120356
|
+
if (host.storeFilesChangingSignatureDuringEmit)
|
|
120357
|
+
(state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
|
|
120358
|
+
if (state.exportedModulesMap)
|
|
120359
|
+
ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
|
|
120360
|
+
if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
|
|
120361
|
+
state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
|
|
120362
|
+
}
|
|
120363
|
+
else {
|
|
120364
|
+
info.signature = newSignature;
|
|
120365
|
+
if (state.exportedModulesMap)
|
|
120366
|
+
ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
|
|
120367
|
+
}
|
|
120368
|
+
}
|
|
120369
|
+
}
|
|
120370
|
+
}
|
|
120371
|
+
if (writeFile)
|
|
120372
|
+
writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
|
|
120373
|
+
else if (host.writeFile)
|
|
120374
|
+
host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
|
|
120375
|
+
else
|
|
120376
|
+
state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
|
|
120377
|
+
};
|
|
120309
120378
|
}
|
|
120310
120379
|
/**
|
|
120311
120380
|
* Emits the JavaScript and declaration files.
|
|
@@ -120362,7 +120431,9 @@ var ts;
|
|
|
120362
120431
|
}
|
|
120363
120432
|
}
|
|
120364
120433
|
}
|
|
120365
|
-
return ts.Debug.checkDefined(state.program).emit(targetSourceFile,
|
|
120434
|
+
return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
|
|
120435
|
+
getWriteFileUpdatingSignatureCallback(writeFile) :
|
|
120436
|
+
writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
120366
120437
|
}
|
|
120367
120438
|
/**
|
|
120368
120439
|
* Return the semantic diagnostics for the next affected file or undefined if iteration is complete
|
|
@@ -122554,6 +122625,7 @@ var ts;
|
|
|
122554
122625
|
createHash: ts.maybeBind(host, host.createHash),
|
|
122555
122626
|
readDirectory: ts.maybeBind(host, host.readDirectory),
|
|
122556
122627
|
disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
|
|
122628
|
+
storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
|
|
122557
122629
|
};
|
|
122558
122630
|
function writeFile(fileName, text, writeByteOrderMark, onError) {
|
|
122559
122631
|
try {
|
|
@@ -122613,6 +122685,7 @@ var ts;
|
|
|
122613
122685
|
createHash: ts.maybeBind(system, system.createHash),
|
|
122614
122686
|
createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
|
|
122615
122687
|
disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
|
|
122688
|
+
storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
|
|
122616
122689
|
};
|
|
122617
122690
|
}
|
|
122618
122691
|
ts.createProgramHost = createProgramHost;
|
|
@@ -122701,6 +122774,7 @@ var ts;
|
|
|
122701
122774
|
var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system);
|
|
122702
122775
|
host.createHash = ts.maybeBind(system, system.createHash);
|
|
122703
122776
|
host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
|
|
122777
|
+
host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
|
|
122704
122778
|
ts.setGetSourceFileAsHashVersioned(host, system);
|
|
122705
122779
|
ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
|
|
122706
122780
|
return host;
|
|
@@ -131769,22 +131843,44 @@ var ts;
|
|
|
131769
131843
|
}
|
|
131770
131844
|
}
|
|
131771
131845
|
function createSnippetPrinter(printerOptions) {
|
|
131846
|
+
var escapes;
|
|
131772
131847
|
var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
|
|
131773
131848
|
var printer = ts.createPrinter(printerOptions, baseWriter);
|
|
131774
|
-
var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(
|
|
131849
|
+
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); }); } });
|
|
131775
131850
|
return {
|
|
131776
131851
|
printSnippetList: printSnippetList,
|
|
131777
131852
|
printAndFormatSnippetList: printAndFormatSnippetList,
|
|
131778
131853
|
};
|
|
131854
|
+
// The formatter/scanner will have issues with snippet-escaped text,
|
|
131855
|
+
// so instead of writing the escaped text directly to the writer,
|
|
131856
|
+
// generate a set of changes that can be applied to the unescaped text
|
|
131857
|
+
// to escape it post-formatting.
|
|
131858
|
+
function escapingWrite(s, write) {
|
|
131859
|
+
var escaped = ts.escapeSnippetText(s);
|
|
131860
|
+
if (escaped !== s) {
|
|
131861
|
+
var start = baseWriter.getTextPos();
|
|
131862
|
+
write();
|
|
131863
|
+
var end = baseWriter.getTextPos();
|
|
131864
|
+
escapes = ts.append(escapes || (escapes = []), { newText: escaped, span: { start: start, length: end - start } });
|
|
131865
|
+
}
|
|
131866
|
+
else {
|
|
131867
|
+
write();
|
|
131868
|
+
}
|
|
131869
|
+
}
|
|
131779
131870
|
/* Snippet-escaping version of `printer.printList`. */
|
|
131780
131871
|
function printSnippetList(format, list, sourceFile) {
|
|
131872
|
+
var unescaped = printUnescapedSnippetList(format, list, sourceFile);
|
|
131873
|
+
return escapes ? ts.textChanges.applyChanges(unescaped, escapes) : unescaped;
|
|
131874
|
+
}
|
|
131875
|
+
function printUnescapedSnippetList(format, list, sourceFile) {
|
|
131876
|
+
escapes = undefined;
|
|
131781
131877
|
writer.clear();
|
|
131782
131878
|
printer.writeList(format, list, sourceFile, writer);
|
|
131783
131879
|
return writer.getText();
|
|
131784
131880
|
}
|
|
131785
131881
|
function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
|
|
131786
131882
|
var syntheticFile = {
|
|
131787
|
-
text:
|
|
131883
|
+
text: printUnescapedSnippetList(format, list, sourceFile),
|
|
131788
131884
|
getLineAndCharacterOfPosition: function (pos) {
|
|
131789
131885
|
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
131790
131886
|
},
|
|
@@ -131796,7 +131892,10 @@ var ts;
|
|
|
131796
131892
|
/* indentation */ 0,
|
|
131797
131893
|
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
|
|
131798
131894
|
});
|
|
131799
|
-
|
|
131895
|
+
var allChanges = escapes
|
|
131896
|
+
? ts.stableSort(ts.concatenate(changes, escapes), function (a, b) { return ts.compareTextSpans(a.span, b.span); })
|
|
131897
|
+
: changes;
|
|
131898
|
+
return ts.textChanges.applyChanges(syntheticFile.text, allChanges);
|
|
131800
131899
|
}
|
|
131801
131900
|
}
|
|
131802
131901
|
function originToCompletionEntryData(origin) {
|
package/lib/tsserverlibrary.d.ts
CHANGED
|
@@ -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 {
|