typescript 4.8.0-dev.20220522 → 4.8.0-dev.20220525
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 +77 -45
- package/lib/tsserver.js +102 -58
- package/lib/tsserverlibrary.js +102 -58
- package/lib/typescript.js +102 -58
- package/lib/typescriptServices.js +102 -58
- package/lib/typingsInstaller.js +101 -58
- package/package.json +1 -1
package/lib/tsserverlibrary.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.20220525";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -62378,7 +62378,7 @@ var ts;
|
|
|
62378
62378
|
function substituteIndexedMappedType(objectType, index) {
|
|
62379
62379
|
var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
|
|
62380
62380
|
var templateMapper = combineTypeMappers(objectType.mapper, mapper);
|
|
62381
|
-
return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
|
|
62381
|
+
return instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper);
|
|
62382
62382
|
}
|
|
62383
62383
|
function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
62384
62384
|
if (accessFlags === void 0) { accessFlags = 0 /* None */; }
|
|
@@ -72490,7 +72490,7 @@ var ts;
|
|
|
72490
72490
|
if (result) {
|
|
72491
72491
|
return result;
|
|
72492
72492
|
}
|
|
72493
|
-
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)
|
|
72493
|
+
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) {
|
|
72494
72494
|
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
|
|
72495
72495
|
}
|
|
72496
72496
|
}
|
|
@@ -72959,22 +72959,20 @@ var ts;
|
|
|
72959
72959
|
var inferenceContext = getInferenceContext(node);
|
|
72960
72960
|
// If no inferences have been made, nothing is gained from instantiating as type parameters
|
|
72961
72961
|
// would just be replaced with their defaults similar to the apparent type.
|
|
72962
|
-
if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
72962
|
+
if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
72963
72963
|
// For contextual signatures we incorporate all inferences made so far, e.g. from return
|
|
72964
72964
|
// types as well as arguments to the left in a function call.
|
|
72965
|
-
|
|
72966
|
-
|
|
72967
|
-
|
|
72965
|
+
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
72966
|
+
}
|
|
72967
|
+
if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) {
|
|
72968
72968
|
// For other purposes (e.g. determining whether to produce literal types) we only
|
|
72969
72969
|
// incorporate inferences made from the return type in a function call. We remove
|
|
72970
72970
|
// the 'boolean' type from the contextual type such that contextually typed boolean
|
|
72971
72971
|
// literals actually end up widening to 'boolean' (see #48363).
|
|
72972
|
-
|
|
72973
|
-
|
|
72974
|
-
|
|
72975
|
-
|
|
72976
|
-
type;
|
|
72977
|
-
}
|
|
72972
|
+
var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
|
|
72973
|
+
return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
|
|
72974
|
+
filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
|
|
72975
|
+
type;
|
|
72978
72976
|
}
|
|
72979
72977
|
}
|
|
72980
72978
|
return contextualType;
|
|
@@ -75508,29 +75506,43 @@ var ts;
|
|
|
75508
75506
|
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
|
|
75509
75507
|
// return type of 'wrap'.
|
|
75510
75508
|
if (node.kind !== 165 /* Decorator */) {
|
|
75511
|
-
var
|
|
75509
|
+
var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); });
|
|
75510
|
+
var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
75512
75511
|
if (contextualType) {
|
|
75513
75512
|
var inferenceTargetType = getReturnTypeOfSignature(signature);
|
|
75514
75513
|
if (couldContainTypeVariables(inferenceTargetType)) {
|
|
75515
|
-
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75516
|
-
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75517
|
-
// inferred for any outer call expression so far.
|
|
75518
75514
|
var outerContext = getInferenceContext(node);
|
|
75519
|
-
var
|
|
75520
|
-
|
|
75521
|
-
//
|
|
75522
|
-
//
|
|
75523
|
-
//
|
|
75524
|
-
//
|
|
75525
|
-
// declare function
|
|
75526
|
-
// const
|
|
75527
|
-
//
|
|
75528
|
-
|
|
75529
|
-
|
|
75530
|
-
|
|
75531
|
-
|
|
75532
|
-
|
|
75533
|
-
|
|
75515
|
+
var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType;
|
|
75516
|
+
// A return type inference from a binding pattern can be used in instantiating the contextual
|
|
75517
|
+
// type of an argument later in inference, but cannot stand on its own as the final return type.
|
|
75518
|
+
// It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`,
|
|
75519
|
+
// but doesn't need to go into `context.inferences`. This allows a an array binding pattern to
|
|
75520
|
+
// produce a tuple for `T` in
|
|
75521
|
+
// declare function f<T>(cb: () => T): T;
|
|
75522
|
+
// const [e1, e2, e3] = f(() => [1, "hi", true]);
|
|
75523
|
+
// but does not produce any inference for `T` in
|
|
75524
|
+
// declare function f<T>(): T;
|
|
75525
|
+
// const [e1, e2, e3] = f();
|
|
75526
|
+
if (!isFromBindingPattern) {
|
|
75527
|
+
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75528
|
+
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75529
|
+
// inferred for any outer call expression so far.
|
|
75530
|
+
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
75531
|
+
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
75532
|
+
// If the contextual type is a generic function type with a single call signature, we
|
|
75533
|
+
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
75534
|
+
// the type parameters are not erased to type any during type inference such that they can
|
|
75535
|
+
// be inferred as actual types from the contextual type. For example:
|
|
75536
|
+
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
75537
|
+
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
75538
|
+
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
75539
|
+
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
75540
|
+
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
75541
|
+
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
75542
|
+
instantiatedType;
|
|
75543
|
+
// Inferences made from return types have lower priority than all other inferences.
|
|
75544
|
+
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
|
|
75545
|
+
}
|
|
75534
75546
|
// Create a type mapper for instantiating generic contextual types using the inferences made
|
|
75535
75547
|
// from the return type. We need a separate inference pass here because (a) instantiation of
|
|
75536
75548
|
// the source type uses the outer context's return mapper (which excludes inferences made from
|
|
@@ -107455,7 +107467,7 @@ var ts;
|
|
|
107455
107467
|
// Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
|
|
107456
107468
|
// To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url`
|
|
107457
107469
|
// is available, just because the output is reasonable for a node-like runtime.
|
|
107458
|
-
return ts.
|
|
107470
|
+
return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined;
|
|
107459
107471
|
case 271 /* ExportAssignment */:
|
|
107460
107472
|
return visitExportAssignment(node);
|
|
107461
107473
|
case 272 /* ExportDeclaration */:
|
|
@@ -124286,7 +124298,6 @@ var ts;
|
|
|
124286
124298
|
allProjectBuildPending: true,
|
|
124287
124299
|
needsSummary: true,
|
|
124288
124300
|
watchAllProjectsPending: watch,
|
|
124289
|
-
currentInvalidatedProject: undefined,
|
|
124290
124301
|
// Watch state
|
|
124291
124302
|
watch: watch,
|
|
124292
124303
|
allWatchedWildcardDirectories: new ts.Map(),
|
|
@@ -124519,7 +124530,6 @@ var ts;
|
|
|
124519
124530
|
})(InvalidatedProjectKind = ts.InvalidatedProjectKind || (ts.InvalidatedProjectKind = {}));
|
|
124520
124531
|
function doneInvalidatedProject(state, projectPath) {
|
|
124521
124532
|
state.projectPendingBuild.delete(projectPath);
|
|
124522
|
-
state.currentInvalidatedProject = undefined;
|
|
124523
124533
|
return state.diagnostics.has(projectPath) ?
|
|
124524
124534
|
ts.ExitStatus.DiagnosticsPresent_OutputsSkipped :
|
|
124525
124535
|
ts.ExitStatus.Success;
|
|
@@ -124870,17 +124880,11 @@ var ts;
|
|
|
124870
124880
|
!!ts.getConfigFileParsingDiagnostics(config).length ||
|
|
124871
124881
|
!ts.isIncrementalCompilation(config.options);
|
|
124872
124882
|
}
|
|
124873
|
-
function
|
|
124883
|
+
function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
|
|
124874
124884
|
if (!state.projectPendingBuild.size)
|
|
124875
124885
|
return undefined;
|
|
124876
124886
|
if (isCircularBuildOrder(buildOrder))
|
|
124877
124887
|
return undefined;
|
|
124878
|
-
if (state.currentInvalidatedProject) {
|
|
124879
|
-
// Only if same buildOrder the currentInvalidated project can be sent again
|
|
124880
|
-
return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ?
|
|
124881
|
-
state.currentInvalidatedProject :
|
|
124882
|
-
undefined;
|
|
124883
|
-
}
|
|
124884
124888
|
var options = state.options, projectPendingBuild = state.projectPendingBuild;
|
|
124885
124889
|
for (var projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
|
|
124886
124890
|
var project = buildOrder[projectIndex];
|
|
@@ -124913,9 +124917,9 @@ var ts;
|
|
|
124913
124917
|
watchPackageJsonFiles(state, project, projectPath, config);
|
|
124914
124918
|
}
|
|
124915
124919
|
var status = getUpToDateStatus(state, config, projectPath);
|
|
124916
|
-
verboseReportProjectStatus(state, project, status);
|
|
124917
124920
|
if (!options.force) {
|
|
124918
124921
|
if (status.type === ts.UpToDateStatusType.UpToDate) {
|
|
124922
|
+
verboseReportProjectStatus(state, project, status);
|
|
124919
124923
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124920
124924
|
projectPendingBuild.delete(projectPath);
|
|
124921
124925
|
// Up to date, skip
|
|
@@ -124927,10 +124931,18 @@ var ts;
|
|
|
124927
124931
|
}
|
|
124928
124932
|
if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
|
|
124929
124933
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124930
|
-
return
|
|
124934
|
+
return {
|
|
124935
|
+
kind: InvalidatedProjectKind.UpdateOutputFileStamps,
|
|
124936
|
+
status: status,
|
|
124937
|
+
project: project,
|
|
124938
|
+
projectPath: projectPath,
|
|
124939
|
+
projectIndex: projectIndex,
|
|
124940
|
+
config: config
|
|
124941
|
+
};
|
|
124931
124942
|
}
|
|
124932
124943
|
}
|
|
124933
124944
|
if (status.type === ts.UpToDateStatusType.UpstreamBlocked) {
|
|
124945
|
+
verboseReportProjectStatus(state, project, status);
|
|
124934
124946
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124935
124947
|
projectPendingBuild.delete(projectPath);
|
|
124936
124948
|
if (options.verbose) {
|
|
@@ -124941,17 +124953,37 @@ var ts;
|
|
|
124941
124953
|
continue;
|
|
124942
124954
|
}
|
|
124943
124955
|
if (status.type === ts.UpToDateStatusType.ContainerOnly) {
|
|
124956
|
+
verboseReportProjectStatus(state, project, status);
|
|
124944
124957
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124945
124958
|
projectPendingBuild.delete(projectPath);
|
|
124946
124959
|
// Do nothing
|
|
124947
124960
|
continue;
|
|
124948
124961
|
}
|
|
124949
|
-
return
|
|
124950
|
-
|
|
124951
|
-
|
|
124962
|
+
return {
|
|
124963
|
+
kind: needsBuild(state, status, config) ?
|
|
124964
|
+
InvalidatedProjectKind.Build :
|
|
124965
|
+
InvalidatedProjectKind.UpdateBundle,
|
|
124966
|
+
status: status,
|
|
124967
|
+
project: project,
|
|
124968
|
+
projectPath: projectPath,
|
|
124969
|
+
projectIndex: projectIndex,
|
|
124970
|
+
config: config,
|
|
124971
|
+
};
|
|
124952
124972
|
}
|
|
124953
124973
|
return undefined;
|
|
124954
124974
|
}
|
|
124975
|
+
function createInvalidatedProjectWithInfo(state, info, buildOrder) {
|
|
124976
|
+
verboseReportProjectStatus(state, info.project, info.status);
|
|
124977
|
+
return info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps ?
|
|
124978
|
+
createBuildOrUpdateInvalidedProject(info.kind, state, info.project, info.projectPath, info.projectIndex, info.config, buildOrder) :
|
|
124979
|
+
createUpdateOutputFileStampsProject(state, info.project, info.projectPath, info.config, buildOrder);
|
|
124980
|
+
}
|
|
124981
|
+
function getNextInvalidatedProject(state, buildOrder, reportQueue) {
|
|
124982
|
+
var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
|
|
124983
|
+
if (!info)
|
|
124984
|
+
return info;
|
|
124985
|
+
return createInvalidatedProjectWithInfo(state, info, buildOrder);
|
|
124986
|
+
}
|
|
124955
124987
|
function listEmittedFile(_a, proj, file) {
|
|
124956
124988
|
var write = _a.write;
|
|
124957
124989
|
if (write && proj.options.listEmittedFiles) {
|
|
@@ -125392,9 +125424,9 @@ var ts;
|
|
|
125392
125424
|
function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
|
|
125393
125425
|
state.reportFileChangeDetected = true;
|
|
125394
125426
|
invalidateProject(state, resolvedPath, reloadLevel);
|
|
125395
|
-
scheduleBuildInvalidatedProject(state);
|
|
125427
|
+
scheduleBuildInvalidatedProject(state, 250, /*changeDetected*/ true);
|
|
125396
125428
|
}
|
|
125397
|
-
function scheduleBuildInvalidatedProject(state) {
|
|
125429
|
+
function scheduleBuildInvalidatedProject(state, time, changeDetected) {
|
|
125398
125430
|
var hostWithWatch = state.hostWithWatch;
|
|
125399
125431
|
if (!hostWithWatch.setTimeout || !hostWithWatch.clearTimeout) {
|
|
125400
125432
|
return;
|
|
@@ -125402,25 +125434,38 @@ var ts;
|
|
|
125402
125434
|
if (state.timerToBuildInvalidatedProject) {
|
|
125403
125435
|
hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
|
|
125404
125436
|
}
|
|
125405
|
-
state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject,
|
|
125437
|
+
state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
|
|
125406
125438
|
}
|
|
125407
|
-
function buildNextInvalidatedProject(state) {
|
|
125439
|
+
function buildNextInvalidatedProject(state, changeDetected) {
|
|
125408
125440
|
state.timerToBuildInvalidatedProject = undefined;
|
|
125409
125441
|
if (state.reportFileChangeDetected) {
|
|
125410
125442
|
state.reportFileChangeDetected = false;
|
|
125411
125443
|
state.projectErrorsReported.clear();
|
|
125412
125444
|
reportWatchStatus(state, ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
|
|
125413
125445
|
}
|
|
125446
|
+
var projectsBuilt = 0;
|
|
125414
125447
|
var buildOrder = getBuildOrder(state);
|
|
125415
125448
|
var invalidatedProject = getNextInvalidatedProject(state, buildOrder, /*reportQueue*/ false);
|
|
125416
125449
|
if (invalidatedProject) {
|
|
125417
125450
|
invalidatedProject.done();
|
|
125418
|
-
|
|
125419
|
-
|
|
125420
|
-
|
|
125421
|
-
|
|
125451
|
+
projectsBuilt++;
|
|
125452
|
+
while (state.projectPendingBuild.size) {
|
|
125453
|
+
// If already scheduled, skip
|
|
125454
|
+
if (state.timerToBuildInvalidatedProject)
|
|
125455
|
+
return;
|
|
125456
|
+
// Before scheduling check if the next project needs build
|
|
125457
|
+
var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, /*reportQueue*/ false);
|
|
125458
|
+
if (!info)
|
|
125459
|
+
break; // Nothing to build any more
|
|
125460
|
+
if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps && (changeDetected || projectsBuilt === 5)) {
|
|
125461
|
+
// Schedule next project for build
|
|
125462
|
+
scheduleBuildInvalidatedProject(state, 100, /*changeDetected*/ false);
|
|
125463
|
+
return;
|
|
125422
125464
|
}
|
|
125423
|
-
|
|
125465
|
+
var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
|
|
125466
|
+
project.done();
|
|
125467
|
+
if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
|
|
125468
|
+
projectsBuilt++;
|
|
125424
125469
|
}
|
|
125425
125470
|
}
|
|
125426
125471
|
disableCache(state);
|
|
@@ -125524,8 +125569,6 @@ var ts;
|
|
|
125524
125569
|
return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
|
|
125525
125570
|
},
|
|
125526
125571
|
invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); },
|
|
125527
|
-
buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); },
|
|
125528
|
-
getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); },
|
|
125529
125572
|
close: function () { return stopWatching(state); },
|
|
125530
125573
|
};
|
|
125531
125574
|
}
|
|
@@ -135278,6 +135321,7 @@ var ts;
|
|
|
135278
135321
|
return kind === 131 /* AsyncKeyword */
|
|
135279
135322
|
|| kind === 132 /* AwaitKeyword */
|
|
135280
135323
|
|| kind === 127 /* AsKeyword */
|
|
135324
|
+
|| kind === 152 /* TypeKeyword */
|
|
135281
135325
|
|| !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
|
|
135282
135326
|
}
|
|
135283
135327
|
function keywordForNode(node) {
|
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.20220525";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -62378,7 +62378,7 @@ var ts;
|
|
|
62378
62378
|
function substituteIndexedMappedType(objectType, index) {
|
|
62379
62379
|
var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
|
|
62380
62380
|
var templateMapper = combineTypeMappers(objectType.mapper, mapper);
|
|
62381
|
-
return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
|
|
62381
|
+
return instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper);
|
|
62382
62382
|
}
|
|
62383
62383
|
function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
62384
62384
|
if (accessFlags === void 0) { accessFlags = 0 /* None */; }
|
|
@@ -72490,7 +72490,7 @@ var ts;
|
|
|
72490
72490
|
if (result) {
|
|
72491
72491
|
return result;
|
|
72492
72492
|
}
|
|
72493
|
-
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)
|
|
72493
|
+
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) {
|
|
72494
72494
|
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
|
|
72495
72495
|
}
|
|
72496
72496
|
}
|
|
@@ -72959,22 +72959,20 @@ var ts;
|
|
|
72959
72959
|
var inferenceContext = getInferenceContext(node);
|
|
72960
72960
|
// If no inferences have been made, nothing is gained from instantiating as type parameters
|
|
72961
72961
|
// would just be replaced with their defaults similar to the apparent type.
|
|
72962
|
-
if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
72962
|
+
if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
72963
72963
|
// For contextual signatures we incorporate all inferences made so far, e.g. from return
|
|
72964
72964
|
// types as well as arguments to the left in a function call.
|
|
72965
|
-
|
|
72966
|
-
|
|
72967
|
-
|
|
72965
|
+
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
72966
|
+
}
|
|
72967
|
+
if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) {
|
|
72968
72968
|
// For other purposes (e.g. determining whether to produce literal types) we only
|
|
72969
72969
|
// incorporate inferences made from the return type in a function call. We remove
|
|
72970
72970
|
// the 'boolean' type from the contextual type such that contextually typed boolean
|
|
72971
72971
|
// literals actually end up widening to 'boolean' (see #48363).
|
|
72972
|
-
|
|
72973
|
-
|
|
72974
|
-
|
|
72975
|
-
|
|
72976
|
-
type;
|
|
72977
|
-
}
|
|
72972
|
+
var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
|
|
72973
|
+
return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
|
|
72974
|
+
filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
|
|
72975
|
+
type;
|
|
72978
72976
|
}
|
|
72979
72977
|
}
|
|
72980
72978
|
return contextualType;
|
|
@@ -75508,29 +75506,43 @@ var ts;
|
|
|
75508
75506
|
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
|
|
75509
75507
|
// return type of 'wrap'.
|
|
75510
75508
|
if (node.kind !== 165 /* Decorator */) {
|
|
75511
|
-
var
|
|
75509
|
+
var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); });
|
|
75510
|
+
var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
75512
75511
|
if (contextualType) {
|
|
75513
75512
|
var inferenceTargetType = getReturnTypeOfSignature(signature);
|
|
75514
75513
|
if (couldContainTypeVariables(inferenceTargetType)) {
|
|
75515
|
-
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75516
|
-
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75517
|
-
// inferred for any outer call expression so far.
|
|
75518
75514
|
var outerContext = getInferenceContext(node);
|
|
75519
|
-
var
|
|
75520
|
-
|
|
75521
|
-
//
|
|
75522
|
-
//
|
|
75523
|
-
//
|
|
75524
|
-
//
|
|
75525
|
-
// declare function
|
|
75526
|
-
// const
|
|
75527
|
-
//
|
|
75528
|
-
|
|
75529
|
-
|
|
75530
|
-
|
|
75531
|
-
|
|
75532
|
-
|
|
75533
|
-
|
|
75515
|
+
var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType;
|
|
75516
|
+
// A return type inference from a binding pattern can be used in instantiating the contextual
|
|
75517
|
+
// type of an argument later in inference, but cannot stand on its own as the final return type.
|
|
75518
|
+
// It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`,
|
|
75519
|
+
// but doesn't need to go into `context.inferences`. This allows a an array binding pattern to
|
|
75520
|
+
// produce a tuple for `T` in
|
|
75521
|
+
// declare function f<T>(cb: () => T): T;
|
|
75522
|
+
// const [e1, e2, e3] = f(() => [1, "hi", true]);
|
|
75523
|
+
// but does not produce any inference for `T` in
|
|
75524
|
+
// declare function f<T>(): T;
|
|
75525
|
+
// const [e1, e2, e3] = f();
|
|
75526
|
+
if (!isFromBindingPattern) {
|
|
75527
|
+
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75528
|
+
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75529
|
+
// inferred for any outer call expression so far.
|
|
75530
|
+
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
75531
|
+
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
75532
|
+
// If the contextual type is a generic function type with a single call signature, we
|
|
75533
|
+
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
75534
|
+
// the type parameters are not erased to type any during type inference such that they can
|
|
75535
|
+
// be inferred as actual types from the contextual type. For example:
|
|
75536
|
+
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
75537
|
+
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
75538
|
+
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
75539
|
+
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
75540
|
+
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
75541
|
+
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
75542
|
+
instantiatedType;
|
|
75543
|
+
// Inferences made from return types have lower priority than all other inferences.
|
|
75544
|
+
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
|
|
75545
|
+
}
|
|
75534
75546
|
// Create a type mapper for instantiating generic contextual types using the inferences made
|
|
75535
75547
|
// from the return type. We need a separate inference pass here because (a) instantiation of
|
|
75536
75548
|
// the source type uses the outer context's return mapper (which excludes inferences made from
|
|
@@ -107455,7 +107467,7 @@ var ts;
|
|
|
107455
107467
|
// Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
|
|
107456
107468
|
// To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url`
|
|
107457
107469
|
// is available, just because the output is reasonable for a node-like runtime.
|
|
107458
|
-
return ts.
|
|
107470
|
+
return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined;
|
|
107459
107471
|
case 271 /* ExportAssignment */:
|
|
107460
107472
|
return visitExportAssignment(node);
|
|
107461
107473
|
case 272 /* ExportDeclaration */:
|
|
@@ -124286,7 +124298,6 @@ var ts;
|
|
|
124286
124298
|
allProjectBuildPending: true,
|
|
124287
124299
|
needsSummary: true,
|
|
124288
124300
|
watchAllProjectsPending: watch,
|
|
124289
|
-
currentInvalidatedProject: undefined,
|
|
124290
124301
|
// Watch state
|
|
124291
124302
|
watch: watch,
|
|
124292
124303
|
allWatchedWildcardDirectories: new ts.Map(),
|
|
@@ -124519,7 +124530,6 @@ var ts;
|
|
|
124519
124530
|
})(InvalidatedProjectKind = ts.InvalidatedProjectKind || (ts.InvalidatedProjectKind = {}));
|
|
124520
124531
|
function doneInvalidatedProject(state, projectPath) {
|
|
124521
124532
|
state.projectPendingBuild.delete(projectPath);
|
|
124522
|
-
state.currentInvalidatedProject = undefined;
|
|
124523
124533
|
return state.diagnostics.has(projectPath) ?
|
|
124524
124534
|
ts.ExitStatus.DiagnosticsPresent_OutputsSkipped :
|
|
124525
124535
|
ts.ExitStatus.Success;
|
|
@@ -124870,17 +124880,11 @@ var ts;
|
|
|
124870
124880
|
!!ts.getConfigFileParsingDiagnostics(config).length ||
|
|
124871
124881
|
!ts.isIncrementalCompilation(config.options);
|
|
124872
124882
|
}
|
|
124873
|
-
function
|
|
124883
|
+
function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
|
|
124874
124884
|
if (!state.projectPendingBuild.size)
|
|
124875
124885
|
return undefined;
|
|
124876
124886
|
if (isCircularBuildOrder(buildOrder))
|
|
124877
124887
|
return undefined;
|
|
124878
|
-
if (state.currentInvalidatedProject) {
|
|
124879
|
-
// Only if same buildOrder the currentInvalidated project can be sent again
|
|
124880
|
-
return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ?
|
|
124881
|
-
state.currentInvalidatedProject :
|
|
124882
|
-
undefined;
|
|
124883
|
-
}
|
|
124884
124888
|
var options = state.options, projectPendingBuild = state.projectPendingBuild;
|
|
124885
124889
|
for (var projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
|
|
124886
124890
|
var project = buildOrder[projectIndex];
|
|
@@ -124913,9 +124917,9 @@ var ts;
|
|
|
124913
124917
|
watchPackageJsonFiles(state, project, projectPath, config);
|
|
124914
124918
|
}
|
|
124915
124919
|
var status = getUpToDateStatus(state, config, projectPath);
|
|
124916
|
-
verboseReportProjectStatus(state, project, status);
|
|
124917
124920
|
if (!options.force) {
|
|
124918
124921
|
if (status.type === ts.UpToDateStatusType.UpToDate) {
|
|
124922
|
+
verboseReportProjectStatus(state, project, status);
|
|
124919
124923
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124920
124924
|
projectPendingBuild.delete(projectPath);
|
|
124921
124925
|
// Up to date, skip
|
|
@@ -124927,10 +124931,18 @@ var ts;
|
|
|
124927
124931
|
}
|
|
124928
124932
|
if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
|
|
124929
124933
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124930
|
-
return
|
|
124934
|
+
return {
|
|
124935
|
+
kind: InvalidatedProjectKind.UpdateOutputFileStamps,
|
|
124936
|
+
status: status,
|
|
124937
|
+
project: project,
|
|
124938
|
+
projectPath: projectPath,
|
|
124939
|
+
projectIndex: projectIndex,
|
|
124940
|
+
config: config
|
|
124941
|
+
};
|
|
124931
124942
|
}
|
|
124932
124943
|
}
|
|
124933
124944
|
if (status.type === ts.UpToDateStatusType.UpstreamBlocked) {
|
|
124945
|
+
verboseReportProjectStatus(state, project, status);
|
|
124934
124946
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124935
124947
|
projectPendingBuild.delete(projectPath);
|
|
124936
124948
|
if (options.verbose) {
|
|
@@ -124941,17 +124953,37 @@ var ts;
|
|
|
124941
124953
|
continue;
|
|
124942
124954
|
}
|
|
124943
124955
|
if (status.type === ts.UpToDateStatusType.ContainerOnly) {
|
|
124956
|
+
verboseReportProjectStatus(state, project, status);
|
|
124944
124957
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124945
124958
|
projectPendingBuild.delete(projectPath);
|
|
124946
124959
|
// Do nothing
|
|
124947
124960
|
continue;
|
|
124948
124961
|
}
|
|
124949
|
-
return
|
|
124950
|
-
|
|
124951
|
-
|
|
124962
|
+
return {
|
|
124963
|
+
kind: needsBuild(state, status, config) ?
|
|
124964
|
+
InvalidatedProjectKind.Build :
|
|
124965
|
+
InvalidatedProjectKind.UpdateBundle,
|
|
124966
|
+
status: status,
|
|
124967
|
+
project: project,
|
|
124968
|
+
projectPath: projectPath,
|
|
124969
|
+
projectIndex: projectIndex,
|
|
124970
|
+
config: config,
|
|
124971
|
+
};
|
|
124952
124972
|
}
|
|
124953
124973
|
return undefined;
|
|
124954
124974
|
}
|
|
124975
|
+
function createInvalidatedProjectWithInfo(state, info, buildOrder) {
|
|
124976
|
+
verboseReportProjectStatus(state, info.project, info.status);
|
|
124977
|
+
return info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps ?
|
|
124978
|
+
createBuildOrUpdateInvalidedProject(info.kind, state, info.project, info.projectPath, info.projectIndex, info.config, buildOrder) :
|
|
124979
|
+
createUpdateOutputFileStampsProject(state, info.project, info.projectPath, info.config, buildOrder);
|
|
124980
|
+
}
|
|
124981
|
+
function getNextInvalidatedProject(state, buildOrder, reportQueue) {
|
|
124982
|
+
var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
|
|
124983
|
+
if (!info)
|
|
124984
|
+
return info;
|
|
124985
|
+
return createInvalidatedProjectWithInfo(state, info, buildOrder);
|
|
124986
|
+
}
|
|
124955
124987
|
function listEmittedFile(_a, proj, file) {
|
|
124956
124988
|
var write = _a.write;
|
|
124957
124989
|
if (write && proj.options.listEmittedFiles) {
|
|
@@ -125392,9 +125424,9 @@ var ts;
|
|
|
125392
125424
|
function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
|
|
125393
125425
|
state.reportFileChangeDetected = true;
|
|
125394
125426
|
invalidateProject(state, resolvedPath, reloadLevel);
|
|
125395
|
-
scheduleBuildInvalidatedProject(state);
|
|
125427
|
+
scheduleBuildInvalidatedProject(state, 250, /*changeDetected*/ true);
|
|
125396
125428
|
}
|
|
125397
|
-
function scheduleBuildInvalidatedProject(state) {
|
|
125429
|
+
function scheduleBuildInvalidatedProject(state, time, changeDetected) {
|
|
125398
125430
|
var hostWithWatch = state.hostWithWatch;
|
|
125399
125431
|
if (!hostWithWatch.setTimeout || !hostWithWatch.clearTimeout) {
|
|
125400
125432
|
return;
|
|
@@ -125402,25 +125434,38 @@ var ts;
|
|
|
125402
125434
|
if (state.timerToBuildInvalidatedProject) {
|
|
125403
125435
|
hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
|
|
125404
125436
|
}
|
|
125405
|
-
state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject,
|
|
125437
|
+
state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
|
|
125406
125438
|
}
|
|
125407
|
-
function buildNextInvalidatedProject(state) {
|
|
125439
|
+
function buildNextInvalidatedProject(state, changeDetected) {
|
|
125408
125440
|
state.timerToBuildInvalidatedProject = undefined;
|
|
125409
125441
|
if (state.reportFileChangeDetected) {
|
|
125410
125442
|
state.reportFileChangeDetected = false;
|
|
125411
125443
|
state.projectErrorsReported.clear();
|
|
125412
125444
|
reportWatchStatus(state, ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
|
|
125413
125445
|
}
|
|
125446
|
+
var projectsBuilt = 0;
|
|
125414
125447
|
var buildOrder = getBuildOrder(state);
|
|
125415
125448
|
var invalidatedProject = getNextInvalidatedProject(state, buildOrder, /*reportQueue*/ false);
|
|
125416
125449
|
if (invalidatedProject) {
|
|
125417
125450
|
invalidatedProject.done();
|
|
125418
|
-
|
|
125419
|
-
|
|
125420
|
-
|
|
125421
|
-
|
|
125451
|
+
projectsBuilt++;
|
|
125452
|
+
while (state.projectPendingBuild.size) {
|
|
125453
|
+
// If already scheduled, skip
|
|
125454
|
+
if (state.timerToBuildInvalidatedProject)
|
|
125455
|
+
return;
|
|
125456
|
+
// Before scheduling check if the next project needs build
|
|
125457
|
+
var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, /*reportQueue*/ false);
|
|
125458
|
+
if (!info)
|
|
125459
|
+
break; // Nothing to build any more
|
|
125460
|
+
if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps && (changeDetected || projectsBuilt === 5)) {
|
|
125461
|
+
// Schedule next project for build
|
|
125462
|
+
scheduleBuildInvalidatedProject(state, 100, /*changeDetected*/ false);
|
|
125463
|
+
return;
|
|
125422
125464
|
}
|
|
125423
|
-
|
|
125465
|
+
var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
|
|
125466
|
+
project.done();
|
|
125467
|
+
if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
|
|
125468
|
+
projectsBuilt++;
|
|
125424
125469
|
}
|
|
125425
125470
|
}
|
|
125426
125471
|
disableCache(state);
|
|
@@ -125524,8 +125569,6 @@ var ts;
|
|
|
125524
125569
|
return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
|
|
125525
125570
|
},
|
|
125526
125571
|
invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); },
|
|
125527
|
-
buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); },
|
|
125528
|
-
getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); },
|
|
125529
125572
|
close: function () { return stopWatching(state); },
|
|
125530
125573
|
};
|
|
125531
125574
|
}
|
|
@@ -135278,6 +135321,7 @@ var ts;
|
|
|
135278
135321
|
return kind === 131 /* AsyncKeyword */
|
|
135279
135322
|
|| kind === 132 /* AwaitKeyword */
|
|
135280
135323
|
|| kind === 127 /* AsKeyword */
|
|
135324
|
+
|| kind === 152 /* TypeKeyword */
|
|
135281
135325
|
|| !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
|
|
135282
135326
|
}
|
|
135283
135327
|
function keywordForNode(node) {
|