typescript 4.8.0-dev.20220524 → 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 +23 -21
- package/lib/tsserver.js +45 -32
- package/lib/tsserverlibrary.js +45 -32
- package/lib/typescript.js +45 -32
- package/lib/typescriptServices.js +45 -32
- package/lib/typingsInstaller.js +44 -32
- package/package.json +1 -1
package/lib/tsc.js
CHANGED
|
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
69
|
var ts;
|
|
70
70
|
(function (ts) {
|
|
71
71
|
ts.versionMajorMinor = "4.8";
|
|
72
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
72
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220525";
|
|
73
73
|
var NativeCollections;
|
|
74
74
|
(function (NativeCollections) {
|
|
75
75
|
var globals = typeof globalThis !== "undefined" ? globalThis :
|
|
@@ -60320,7 +60320,7 @@ var ts;
|
|
|
60320
60320
|
if (result) {
|
|
60321
60321
|
return result;
|
|
60322
60322
|
}
|
|
60323
|
-
if (!(contextFlags & 8) && ts.isBindingPattern(declaration.name)) {
|
|
60323
|
+
if (!(contextFlags & 8) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) {
|
|
60324
60324
|
return getTypeFromBindingPattern(declaration.name, true, false);
|
|
60325
60325
|
}
|
|
60326
60326
|
}
|
|
@@ -60737,16 +60737,14 @@ var ts;
|
|
|
60737
60737
|
function instantiateContextualType(contextualType, node, contextFlags) {
|
|
60738
60738
|
if (contextualType && maybeTypeOfKind(contextualType, 465829888)) {
|
|
60739
60739
|
var inferenceContext = getInferenceContext(node);
|
|
60740
|
-
if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
60741
|
-
|
|
60742
|
-
|
|
60743
|
-
|
|
60744
|
-
|
|
60745
|
-
|
|
60746
|
-
|
|
60747
|
-
|
|
60748
|
-
type;
|
|
60749
|
-
}
|
|
60740
|
+
if (inferenceContext && contextFlags & 1 && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
60741
|
+
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
60742
|
+
}
|
|
60743
|
+
if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) {
|
|
60744
|
+
var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
|
|
60745
|
+
return type.flags & 1048576 && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
|
|
60746
|
+
filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
|
|
60747
|
+
type;
|
|
60750
60748
|
}
|
|
60751
60749
|
}
|
|
60752
60750
|
return contextualType;
|
|
@@ -62900,18 +62898,22 @@ var ts;
|
|
|
62900
62898
|
return inferJsxTypeArguments(node, signature, checkMode, context);
|
|
62901
62899
|
}
|
|
62902
62900
|
if (node.kind !== 165) {
|
|
62903
|
-
var
|
|
62901
|
+
var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); });
|
|
62902
|
+
var contextualType = getContextualType(node, skipBindingPatterns ? 8 : 0);
|
|
62904
62903
|
if (contextualType) {
|
|
62905
62904
|
var inferenceTargetType = getReturnTypeOfSignature(signature);
|
|
62906
62905
|
if (couldContainTypeVariables(inferenceTargetType)) {
|
|
62907
62906
|
var outerContext = getInferenceContext(node);
|
|
62908
|
-
var
|
|
62909
|
-
|
|
62910
|
-
|
|
62911
|
-
|
|
62912
|
-
|
|
62913
|
-
|
|
62914
|
-
|
|
62907
|
+
var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8) !== contextualType;
|
|
62908
|
+
if (!isFromBindingPattern) {
|
|
62909
|
+
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
|
|
62910
|
+
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
62911
|
+
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
62912
|
+
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
62913
|
+
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
62914
|
+
instantiatedType;
|
|
62915
|
+
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128);
|
|
62916
|
+
}
|
|
62915
62917
|
var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
|
|
62916
62918
|
var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
|
|
62917
62919
|
inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
|
|
@@ -87835,7 +87837,7 @@ var ts;
|
|
|
87835
87837
|
function visitor(node) {
|
|
87836
87838
|
switch (node.kind) {
|
|
87837
87839
|
case 265:
|
|
87838
|
-
return ts.
|
|
87840
|
+
return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined;
|
|
87839
87841
|
case 271:
|
|
87840
87842
|
return visitExportAssignment(node);
|
|
87841
87843
|
case 272:
|
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.20220525";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -72296,7 +72296,7 @@ var ts;
|
|
|
72296
72296
|
if (result) {
|
|
72297
72297
|
return result;
|
|
72298
72298
|
}
|
|
72299
|
-
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)
|
|
72299
|
+
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) {
|
|
72300
72300
|
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
|
|
72301
72301
|
}
|
|
72302
72302
|
}
|
|
@@ -72765,22 +72765,20 @@ var ts;
|
|
|
72765
72765
|
var inferenceContext = getInferenceContext(node);
|
|
72766
72766
|
// If no inferences have been made, nothing is gained from instantiating as type parameters
|
|
72767
72767
|
// would just be replaced with their defaults similar to the apparent type.
|
|
72768
|
-
if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
72768
|
+
if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
72769
72769
|
// For contextual signatures we incorporate all inferences made so far, e.g. from return
|
|
72770
72770
|
// types as well as arguments to the left in a function call.
|
|
72771
|
-
|
|
72772
|
-
|
|
72773
|
-
|
|
72771
|
+
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
72772
|
+
}
|
|
72773
|
+
if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) {
|
|
72774
72774
|
// For other purposes (e.g. determining whether to produce literal types) we only
|
|
72775
72775
|
// incorporate inferences made from the return type in a function call. We remove
|
|
72776
72776
|
// the 'boolean' type from the contextual type such that contextually typed boolean
|
|
72777
72777
|
// literals actually end up widening to 'boolean' (see #48363).
|
|
72778
|
-
|
|
72779
|
-
|
|
72780
|
-
|
|
72781
|
-
|
|
72782
|
-
type;
|
|
72783
|
-
}
|
|
72778
|
+
var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
|
|
72779
|
+
return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
|
|
72780
|
+
filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
|
|
72781
|
+
type;
|
|
72784
72782
|
}
|
|
72785
72783
|
}
|
|
72786
72784
|
return contextualType;
|
|
@@ -75314,29 +75312,43 @@ var ts;
|
|
|
75314
75312
|
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
|
|
75315
75313
|
// return type of 'wrap'.
|
|
75316
75314
|
if (node.kind !== 165 /* Decorator */) {
|
|
75317
|
-
var
|
|
75315
|
+
var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); });
|
|
75316
|
+
var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
75318
75317
|
if (contextualType) {
|
|
75319
75318
|
var inferenceTargetType = getReturnTypeOfSignature(signature);
|
|
75320
75319
|
if (couldContainTypeVariables(inferenceTargetType)) {
|
|
75321
|
-
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75322
|
-
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75323
|
-
// inferred for any outer call expression so far.
|
|
75324
75320
|
var outerContext = getInferenceContext(node);
|
|
75325
|
-
var
|
|
75326
|
-
|
|
75327
|
-
//
|
|
75328
|
-
//
|
|
75329
|
-
//
|
|
75330
|
-
//
|
|
75331
|
-
// declare function
|
|
75332
|
-
// const
|
|
75333
|
-
//
|
|
75334
|
-
|
|
75335
|
-
|
|
75336
|
-
|
|
75337
|
-
|
|
75338
|
-
|
|
75339
|
-
|
|
75321
|
+
var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType;
|
|
75322
|
+
// A return type inference from a binding pattern can be used in instantiating the contextual
|
|
75323
|
+
// type of an argument later in inference, but cannot stand on its own as the final return type.
|
|
75324
|
+
// It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`,
|
|
75325
|
+
// but doesn't need to go into `context.inferences`. This allows a an array binding pattern to
|
|
75326
|
+
// produce a tuple for `T` in
|
|
75327
|
+
// declare function f<T>(cb: () => T): T;
|
|
75328
|
+
// const [e1, e2, e3] = f(() => [1, "hi", true]);
|
|
75329
|
+
// but does not produce any inference for `T` in
|
|
75330
|
+
// declare function f<T>(): T;
|
|
75331
|
+
// const [e1, e2, e3] = f();
|
|
75332
|
+
if (!isFromBindingPattern) {
|
|
75333
|
+
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75334
|
+
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75335
|
+
// inferred for any outer call expression so far.
|
|
75336
|
+
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
75337
|
+
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
75338
|
+
// If the contextual type is a generic function type with a single call signature, we
|
|
75339
|
+
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
75340
|
+
// the type parameters are not erased to type any during type inference such that they can
|
|
75341
|
+
// be inferred as actual types from the contextual type. For example:
|
|
75342
|
+
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
75343
|
+
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
75344
|
+
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
75345
|
+
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
75346
|
+
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
75347
|
+
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
75348
|
+
instantiatedType;
|
|
75349
|
+
// Inferences made from return types have lower priority than all other inferences.
|
|
75350
|
+
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
|
|
75351
|
+
}
|
|
75340
75352
|
// Create a type mapper for instantiating generic contextual types using the inferences made
|
|
75341
75353
|
// from the return type. We need a separate inference pass here because (a) instantiation of
|
|
75342
75354
|
// the source type uses the outer context's return mapper (which excludes inferences made from
|
|
@@ -107261,7 +107273,7 @@ var ts;
|
|
|
107261
107273
|
// Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
|
|
107262
107274
|
// 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`
|
|
107263
107275
|
// is available, just because the output is reasonable for a node-like runtime.
|
|
107264
|
-
return ts.
|
|
107276
|
+
return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined;
|
|
107265
107277
|
case 271 /* ExportAssignment */:
|
|
107266
107278
|
return visitExportAssignment(node);
|
|
107267
107279
|
case 272 /* ExportDeclaration */:
|
|
@@ -134698,6 +134710,7 @@ var ts;
|
|
|
134698
134710
|
return kind === 131 /* AsyncKeyword */
|
|
134699
134711
|
|| kind === 132 /* AwaitKeyword */
|
|
134700
134712
|
|| kind === 127 /* AsKeyword */
|
|
134713
|
+
|| kind === 152 /* TypeKeyword */
|
|
134701
134714
|
|| !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
|
|
134702
134715
|
}
|
|
134703
134716
|
function keywordForNode(node) {
|
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) {
|
|
@@ -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 */:
|
|
@@ -135309,6 +135321,7 @@ var ts;
|
|
|
135309
135321
|
return kind === 131 /* AsyncKeyword */
|
|
135310
135322
|
|| kind === 132 /* AwaitKeyword */
|
|
135311
135323
|
|| kind === 127 /* AsKeyword */
|
|
135324
|
+
|| kind === 152 /* TypeKeyword */
|
|
135312
135325
|
|| !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
|
|
135313
135326
|
}
|
|
135314
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) {
|
|
@@ -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 */:
|
|
@@ -135309,6 +135321,7 @@ var ts;
|
|
|
135309
135321
|
return kind === 131 /* AsyncKeyword */
|
|
135310
135322
|
|| kind === 132 /* AwaitKeyword */
|
|
135311
135323
|
|| kind === 127 /* AsKeyword */
|
|
135324
|
+
|| kind === 152 /* TypeKeyword */
|
|
135312
135325
|
|| !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
|
|
135313
135326
|
}
|
|
135314
135327
|
function keywordForNode(node) {
|
|
@@ -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) {
|
|
@@ -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 */:
|
|
@@ -135309,6 +135321,7 @@ var ts;
|
|
|
135309
135321
|
return kind === 131 /* AsyncKeyword */
|
|
135310
135322
|
|| kind === 132 /* AwaitKeyword */
|
|
135311
135323
|
|| kind === 127 /* AsKeyword */
|
|
135324
|
+
|| kind === 152 /* TypeKeyword */
|
|
135312
135325
|
|| !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
|
|
135313
135326
|
}
|
|
135314
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) {
|
|
@@ -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 */:
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "4.8.0-dev.
|
|
5
|
+
"version": "4.8.0-dev.20220525",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|