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
|
@@ -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/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220525";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -62173,7 +62173,7 @@ var ts;
|
|
|
62173
62173
|
function substituteIndexedMappedType(objectType, index) {
|
|
62174
62174
|
var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
|
|
62175
62175
|
var templateMapper = combineTypeMappers(objectType.mapper, mapper);
|
|
62176
|
-
return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
|
|
62176
|
+
return instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper);
|
|
62177
62177
|
}
|
|
62178
62178
|
function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
62179
62179
|
if (accessFlags === void 0) { accessFlags = 0 /* None */; }
|
|
@@ -72285,7 +72285,7 @@ var ts;
|
|
|
72285
72285
|
if (result) {
|
|
72286
72286
|
return result;
|
|
72287
72287
|
}
|
|
72288
|
-
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)
|
|
72288
|
+
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) {
|
|
72289
72289
|
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
|
|
72290
72290
|
}
|
|
72291
72291
|
}
|
|
@@ -72754,22 +72754,20 @@ var ts;
|
|
|
72754
72754
|
var inferenceContext = getInferenceContext(node);
|
|
72755
72755
|
// If no inferences have been made, nothing is gained from instantiating as type parameters
|
|
72756
72756
|
// would just be replaced with their defaults similar to the apparent type.
|
|
72757
|
-
if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
72757
|
+
if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
72758
72758
|
// For contextual signatures we incorporate all inferences made so far, e.g. from return
|
|
72759
72759
|
// types as well as arguments to the left in a function call.
|
|
72760
|
-
|
|
72761
|
-
|
|
72762
|
-
|
|
72760
|
+
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
72761
|
+
}
|
|
72762
|
+
if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) {
|
|
72763
72763
|
// For other purposes (e.g. determining whether to produce literal types) we only
|
|
72764
72764
|
// incorporate inferences made from the return type in a function call. We remove
|
|
72765
72765
|
// the 'boolean' type from the contextual type such that contextually typed boolean
|
|
72766
72766
|
// literals actually end up widening to 'boolean' (see #48363).
|
|
72767
|
-
|
|
72768
|
-
|
|
72769
|
-
|
|
72770
|
-
|
|
72771
|
-
type;
|
|
72772
|
-
}
|
|
72767
|
+
var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
|
|
72768
|
+
return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
|
|
72769
|
+
filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
|
|
72770
|
+
type;
|
|
72773
72771
|
}
|
|
72774
72772
|
}
|
|
72775
72773
|
return contextualType;
|
|
@@ -75303,29 +75301,43 @@ var ts;
|
|
|
75303
75301
|
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
|
|
75304
75302
|
// return type of 'wrap'.
|
|
75305
75303
|
if (node.kind !== 165 /* Decorator */) {
|
|
75306
|
-
var
|
|
75304
|
+
var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); });
|
|
75305
|
+
var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
75307
75306
|
if (contextualType) {
|
|
75308
75307
|
var inferenceTargetType = getReturnTypeOfSignature(signature);
|
|
75309
75308
|
if (couldContainTypeVariables(inferenceTargetType)) {
|
|
75310
|
-
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75311
|
-
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75312
|
-
// inferred for any outer call expression so far.
|
|
75313
75309
|
var outerContext = getInferenceContext(node);
|
|
75314
|
-
var
|
|
75315
|
-
|
|
75316
|
-
//
|
|
75317
|
-
//
|
|
75318
|
-
//
|
|
75319
|
-
//
|
|
75320
|
-
// declare function
|
|
75321
|
-
// const
|
|
75322
|
-
//
|
|
75323
|
-
|
|
75324
|
-
|
|
75325
|
-
|
|
75326
|
-
|
|
75327
|
-
|
|
75328
|
-
|
|
75310
|
+
var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType;
|
|
75311
|
+
// A return type inference from a binding pattern can be used in instantiating the contextual
|
|
75312
|
+
// type of an argument later in inference, but cannot stand on its own as the final return type.
|
|
75313
|
+
// It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`,
|
|
75314
|
+
// but doesn't need to go into `context.inferences`. This allows a an array binding pattern to
|
|
75315
|
+
// produce a tuple for `T` in
|
|
75316
|
+
// declare function f<T>(cb: () => T): T;
|
|
75317
|
+
// const [e1, e2, e3] = f(() => [1, "hi", true]);
|
|
75318
|
+
// but does not produce any inference for `T` in
|
|
75319
|
+
// declare function f<T>(): T;
|
|
75320
|
+
// const [e1, e2, e3] = f();
|
|
75321
|
+
if (!isFromBindingPattern) {
|
|
75322
|
+
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75323
|
+
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75324
|
+
// inferred for any outer call expression so far.
|
|
75325
|
+
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
75326
|
+
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
75327
|
+
// If the contextual type is a generic function type with a single call signature, we
|
|
75328
|
+
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
75329
|
+
// the type parameters are not erased to type any during type inference such that they can
|
|
75330
|
+
// be inferred as actual types from the contextual type. For example:
|
|
75331
|
+
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
75332
|
+
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
75333
|
+
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
75334
|
+
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
75335
|
+
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
75336
|
+
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
75337
|
+
instantiatedType;
|
|
75338
|
+
// Inferences made from return types have lower priority than all other inferences.
|
|
75339
|
+
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
|
|
75340
|
+
}
|
|
75329
75341
|
// Create a type mapper for instantiating generic contextual types using the inferences made
|
|
75330
75342
|
// from the return type. We need a separate inference pass here because (a) instantiation of
|
|
75331
75343
|
// the source type uses the outer context's return mapper (which excludes inferences made from
|
|
@@ -107250,7 +107262,7 @@ var ts;
|
|
|
107250
107262
|
// Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
|
|
107251
107263
|
// 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`
|
|
107252
107264
|
// is available, just because the output is reasonable for a node-like runtime.
|
|
107253
|
-
return ts.
|
|
107265
|
+
return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined;
|
|
107254
107266
|
case 271 /* ExportAssignment */:
|
|
107255
107267
|
return visitExportAssignment(node);
|
|
107256
107268
|
case 272 /* ExportDeclaration */:
|
|
@@ -124081,7 +124093,6 @@ var ts;
|
|
|
124081
124093
|
allProjectBuildPending: true,
|
|
124082
124094
|
needsSummary: true,
|
|
124083
124095
|
watchAllProjectsPending: watch,
|
|
124084
|
-
currentInvalidatedProject: undefined,
|
|
124085
124096
|
// Watch state
|
|
124086
124097
|
watch: watch,
|
|
124087
124098
|
allWatchedWildcardDirectories: new ts.Map(),
|
|
@@ -124314,7 +124325,6 @@ var ts;
|
|
|
124314
124325
|
})(InvalidatedProjectKind = ts.InvalidatedProjectKind || (ts.InvalidatedProjectKind = {}));
|
|
124315
124326
|
function doneInvalidatedProject(state, projectPath) {
|
|
124316
124327
|
state.projectPendingBuild.delete(projectPath);
|
|
124317
|
-
state.currentInvalidatedProject = undefined;
|
|
124318
124328
|
return state.diagnostics.has(projectPath) ?
|
|
124319
124329
|
ts.ExitStatus.DiagnosticsPresent_OutputsSkipped :
|
|
124320
124330
|
ts.ExitStatus.Success;
|
|
@@ -124665,17 +124675,11 @@ var ts;
|
|
|
124665
124675
|
!!ts.getConfigFileParsingDiagnostics(config).length ||
|
|
124666
124676
|
!ts.isIncrementalCompilation(config.options);
|
|
124667
124677
|
}
|
|
124668
|
-
function
|
|
124678
|
+
function getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue) {
|
|
124669
124679
|
if (!state.projectPendingBuild.size)
|
|
124670
124680
|
return undefined;
|
|
124671
124681
|
if (isCircularBuildOrder(buildOrder))
|
|
124672
124682
|
return undefined;
|
|
124673
|
-
if (state.currentInvalidatedProject) {
|
|
124674
|
-
// Only if same buildOrder the currentInvalidated project can be sent again
|
|
124675
|
-
return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ?
|
|
124676
|
-
state.currentInvalidatedProject :
|
|
124677
|
-
undefined;
|
|
124678
|
-
}
|
|
124679
124683
|
var options = state.options, projectPendingBuild = state.projectPendingBuild;
|
|
124680
124684
|
for (var projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
|
|
124681
124685
|
var project = buildOrder[projectIndex];
|
|
@@ -124708,9 +124712,9 @@ var ts;
|
|
|
124708
124712
|
watchPackageJsonFiles(state, project, projectPath, config);
|
|
124709
124713
|
}
|
|
124710
124714
|
var status = getUpToDateStatus(state, config, projectPath);
|
|
124711
|
-
verboseReportProjectStatus(state, project, status);
|
|
124712
124715
|
if (!options.force) {
|
|
124713
124716
|
if (status.type === ts.UpToDateStatusType.UpToDate) {
|
|
124717
|
+
verboseReportProjectStatus(state, project, status);
|
|
124714
124718
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124715
124719
|
projectPendingBuild.delete(projectPath);
|
|
124716
124720
|
// Up to date, skip
|
|
@@ -124722,10 +124726,18 @@ var ts;
|
|
|
124722
124726
|
}
|
|
124723
124727
|
if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
|
|
124724
124728
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124725
|
-
return
|
|
124729
|
+
return {
|
|
124730
|
+
kind: InvalidatedProjectKind.UpdateOutputFileStamps,
|
|
124731
|
+
status: status,
|
|
124732
|
+
project: project,
|
|
124733
|
+
projectPath: projectPath,
|
|
124734
|
+
projectIndex: projectIndex,
|
|
124735
|
+
config: config
|
|
124736
|
+
};
|
|
124726
124737
|
}
|
|
124727
124738
|
}
|
|
124728
124739
|
if (status.type === ts.UpToDateStatusType.UpstreamBlocked) {
|
|
124740
|
+
verboseReportProjectStatus(state, project, status);
|
|
124729
124741
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124730
124742
|
projectPendingBuild.delete(projectPath);
|
|
124731
124743
|
if (options.verbose) {
|
|
@@ -124736,17 +124748,37 @@ var ts;
|
|
|
124736
124748
|
continue;
|
|
124737
124749
|
}
|
|
124738
124750
|
if (status.type === ts.UpToDateStatusType.ContainerOnly) {
|
|
124751
|
+
verboseReportProjectStatus(state, project, status);
|
|
124739
124752
|
reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
|
|
124740
124753
|
projectPendingBuild.delete(projectPath);
|
|
124741
124754
|
// Do nothing
|
|
124742
124755
|
continue;
|
|
124743
124756
|
}
|
|
124744
|
-
return
|
|
124745
|
-
|
|
124746
|
-
|
|
124757
|
+
return {
|
|
124758
|
+
kind: needsBuild(state, status, config) ?
|
|
124759
|
+
InvalidatedProjectKind.Build :
|
|
124760
|
+
InvalidatedProjectKind.UpdateBundle,
|
|
124761
|
+
status: status,
|
|
124762
|
+
project: project,
|
|
124763
|
+
projectPath: projectPath,
|
|
124764
|
+
projectIndex: projectIndex,
|
|
124765
|
+
config: config,
|
|
124766
|
+
};
|
|
124747
124767
|
}
|
|
124748
124768
|
return undefined;
|
|
124749
124769
|
}
|
|
124770
|
+
function createInvalidatedProjectWithInfo(state, info, buildOrder) {
|
|
124771
|
+
verboseReportProjectStatus(state, info.project, info.status);
|
|
124772
|
+
return info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps ?
|
|
124773
|
+
createBuildOrUpdateInvalidedProject(info.kind, state, info.project, info.projectPath, info.projectIndex, info.config, buildOrder) :
|
|
124774
|
+
createUpdateOutputFileStampsProject(state, info.project, info.projectPath, info.config, buildOrder);
|
|
124775
|
+
}
|
|
124776
|
+
function getNextInvalidatedProject(state, buildOrder, reportQueue) {
|
|
124777
|
+
var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, reportQueue);
|
|
124778
|
+
if (!info)
|
|
124779
|
+
return info;
|
|
124780
|
+
return createInvalidatedProjectWithInfo(state, info, buildOrder);
|
|
124781
|
+
}
|
|
124750
124782
|
function listEmittedFile(_a, proj, file) {
|
|
124751
124783
|
var write = _a.write;
|
|
124752
124784
|
if (write && proj.options.listEmittedFiles) {
|
|
@@ -125187,9 +125219,9 @@ var ts;
|
|
|
125187
125219
|
function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
|
|
125188
125220
|
state.reportFileChangeDetected = true;
|
|
125189
125221
|
invalidateProject(state, resolvedPath, reloadLevel);
|
|
125190
|
-
scheduleBuildInvalidatedProject(state);
|
|
125222
|
+
scheduleBuildInvalidatedProject(state, 250, /*changeDetected*/ true);
|
|
125191
125223
|
}
|
|
125192
|
-
function scheduleBuildInvalidatedProject(state) {
|
|
125224
|
+
function scheduleBuildInvalidatedProject(state, time, changeDetected) {
|
|
125193
125225
|
var hostWithWatch = state.hostWithWatch;
|
|
125194
125226
|
if (!hostWithWatch.setTimeout || !hostWithWatch.clearTimeout) {
|
|
125195
125227
|
return;
|
|
@@ -125197,25 +125229,38 @@ var ts;
|
|
|
125197
125229
|
if (state.timerToBuildInvalidatedProject) {
|
|
125198
125230
|
hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
|
|
125199
125231
|
}
|
|
125200
|
-
state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject,
|
|
125232
|
+
state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, time, state, changeDetected);
|
|
125201
125233
|
}
|
|
125202
|
-
function buildNextInvalidatedProject(state) {
|
|
125234
|
+
function buildNextInvalidatedProject(state, changeDetected) {
|
|
125203
125235
|
state.timerToBuildInvalidatedProject = undefined;
|
|
125204
125236
|
if (state.reportFileChangeDetected) {
|
|
125205
125237
|
state.reportFileChangeDetected = false;
|
|
125206
125238
|
state.projectErrorsReported.clear();
|
|
125207
125239
|
reportWatchStatus(state, ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
|
|
125208
125240
|
}
|
|
125241
|
+
var projectsBuilt = 0;
|
|
125209
125242
|
var buildOrder = getBuildOrder(state);
|
|
125210
125243
|
var invalidatedProject = getNextInvalidatedProject(state, buildOrder, /*reportQueue*/ false);
|
|
125211
125244
|
if (invalidatedProject) {
|
|
125212
125245
|
invalidatedProject.done();
|
|
125213
|
-
|
|
125214
|
-
|
|
125215
|
-
|
|
125216
|
-
|
|
125246
|
+
projectsBuilt++;
|
|
125247
|
+
while (state.projectPendingBuild.size) {
|
|
125248
|
+
// If already scheduled, skip
|
|
125249
|
+
if (state.timerToBuildInvalidatedProject)
|
|
125250
|
+
return;
|
|
125251
|
+
// Before scheduling check if the next project needs build
|
|
125252
|
+
var info = getNextInvalidatedProjectCreateInfo(state, buildOrder, /*reportQueue*/ false);
|
|
125253
|
+
if (!info)
|
|
125254
|
+
break; // Nothing to build any more
|
|
125255
|
+
if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps && (changeDetected || projectsBuilt === 5)) {
|
|
125256
|
+
// Schedule next project for build
|
|
125257
|
+
scheduleBuildInvalidatedProject(state, 100, /*changeDetected*/ false);
|
|
125258
|
+
return;
|
|
125217
125259
|
}
|
|
125218
|
-
|
|
125260
|
+
var project = createInvalidatedProjectWithInfo(state, info, buildOrder);
|
|
125261
|
+
project.done();
|
|
125262
|
+
if (info.kind !== InvalidatedProjectKind.UpdateOutputFileStamps)
|
|
125263
|
+
projectsBuilt++;
|
|
125219
125264
|
}
|
|
125220
125265
|
}
|
|
125221
125266
|
disableCache(state);
|
|
@@ -125319,8 +125364,6 @@ var ts;
|
|
|
125319
125364
|
return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
|
|
125320
125365
|
},
|
|
125321
125366
|
invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); },
|
|
125322
|
-
buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); },
|
|
125323
|
-
getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); },
|
|
125324
125367
|
close: function () { return stopWatching(state); },
|
|
125325
125368
|
};
|
|
125326
125369
|
}
|