typescript 4.8.0-dev.20220524 → 4.8.0-dev.20220527
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/protocol.d.ts +1 -0
- package/lib/tsc.js +51 -39
- package/lib/tsserver.js +82 -55
- package/lib/tsserverlibrary.d.ts +2 -0
- package/lib/tsserverlibrary.js +82 -55
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +81 -53
- package/lib/typescriptServices.d.ts +1 -0
- package/lib/typescriptServices.js +81 -53
- package/lib/typingsInstaller.js +74 -51
- package/package.json +1 -1
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.20220527";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -16207,9 +16207,6 @@ var ts;
|
|
|
16207
16207
|
}
|
|
16208
16208
|
ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
|
|
16209
16209
|
function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
|
|
16210
|
-
if (node.kind === 203 /* BindingElement */) {
|
|
16211
|
-
node = node.parent.parent;
|
|
16212
|
-
}
|
|
16213
16210
|
return ts.isVariableDeclaration(node) &&
|
|
16214
16211
|
!!node.initializer &&
|
|
16215
16212
|
isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
|
|
@@ -20021,8 +20018,9 @@ var ts;
|
|
|
20021
20018
|
*/
|
|
20022
20019
|
function isFileForcedToBeModuleByFormat(file) {
|
|
20023
20020
|
// Excludes declaration files - they still require an explicit `export {}` or the like
|
|
20024
|
-
// for back compat purposes.
|
|
20025
|
-
|
|
20021
|
+
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
|
20022
|
+
// that aren't esm-mode (meaning not in a `type: module` scope).
|
|
20023
|
+
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20026
20024
|
}
|
|
20027
20025
|
function getSetExternalModuleIndicator(options) {
|
|
20028
20026
|
// TODO: Should this callback be cached?
|
|
@@ -20030,7 +20028,7 @@ var ts;
|
|
|
20030
20028
|
case ts.ModuleDetectionKind.Force:
|
|
20031
20029
|
// All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
|
|
20032
20030
|
return function (file) {
|
|
20033
|
-
file.externalModuleIndicator = !file.isDeclarationFile ||
|
|
20031
|
+
file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
|
|
20034
20032
|
};
|
|
20035
20033
|
case ts.ModuleDetectionKind.Legacy:
|
|
20036
20034
|
// Files are modules if they have imports, exports, or import.meta
|
|
@@ -20090,7 +20088,8 @@ var ts;
|
|
|
20090
20088
|
}
|
|
20091
20089
|
ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
|
|
20092
20090
|
function getEmitModuleDetectionKind(options) {
|
|
20093
|
-
return options.moduleDetection ||
|
|
20091
|
+
return options.moduleDetection ||
|
|
20092
|
+
(getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
|
|
20094
20093
|
}
|
|
20095
20094
|
ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
|
|
20096
20095
|
function hasJsonModuleEmitEnabled(options) {
|
|
@@ -42032,7 +42031,7 @@ var ts;
|
|
|
42032
42031
|
}
|
|
42033
42032
|
if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
|
|
42034
42033
|
return {
|
|
42035
|
-
key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
|
|
42034
|
+
key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
|
|
42036
42035
|
flags: 1 /* Recursive */
|
|
42037
42036
|
};
|
|
42038
42037
|
}
|
|
@@ -43137,16 +43136,20 @@ var ts;
|
|
|
43137
43136
|
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
43138
43137
|
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
43139
43138
|
}
|
|
43139
|
+
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
43140
|
+
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
43141
|
+
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
43142
|
+
var tsconfigExtensions = [Extensions.TSConfig];
|
|
43140
43143
|
function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
43141
43144
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
43142
43145
|
// es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
|
|
43143
43146
|
var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
|
|
43144
|
-
|
|
43147
|
+
var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
|
|
43148
|
+
if (compilerOptions.resolveJsonModule) {
|
|
43149
|
+
extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
|
|
43150
|
+
}
|
|
43151
|
+
return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
|
|
43145
43152
|
}
|
|
43146
|
-
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
43147
|
-
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
43148
|
-
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
43149
|
-
var tsconfigExtensions = [Extensions.TSConfig];
|
|
43150
43153
|
function tryResolveJSModuleWorker(moduleName, initialDir, host) {
|
|
43151
43154
|
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
43152
43155
|
}
|
|
@@ -46931,12 +46934,14 @@ var ts;
|
|
|
46931
46934
|
}
|
|
46932
46935
|
}
|
|
46933
46936
|
function setCommonJsModuleIndicator(node) {
|
|
46934
|
-
if (file.externalModuleIndicator) {
|
|
46937
|
+
if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
|
|
46935
46938
|
return false;
|
|
46936
46939
|
}
|
|
46937
46940
|
if (!file.commonJsModuleIndicator) {
|
|
46938
46941
|
file.commonJsModuleIndicator = node;
|
|
46939
|
-
|
|
46942
|
+
if (!file.externalModuleIndicator) {
|
|
46943
|
+
bindSourceFileAsExternalModule();
|
|
46944
|
+
}
|
|
46940
46945
|
}
|
|
46941
46946
|
return true;
|
|
46942
46947
|
}
|
|
@@ -47350,7 +47355,11 @@ var ts;
|
|
|
47350
47355
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
47351
47356
|
}
|
|
47352
47357
|
if (!ts.isBindingPattern(node.name)) {
|
|
47353
|
-
|
|
47358
|
+
var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
|
|
47359
|
+
if (ts.isInJSFile(node) &&
|
|
47360
|
+
ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
|
|
47361
|
+
!ts.getJSDocTypeTag(node) &&
|
|
47362
|
+
!(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
|
|
47354
47363
|
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
|
|
47355
47364
|
}
|
|
47356
47365
|
else if (ts.isBlockOrCatchScoped(node)) {
|
|
@@ -50177,7 +50186,8 @@ var ts;
|
|
|
50177
50186
|
&& isAliasableOrJsExpression(node.parent.right)
|
|
50178
50187
|
|| node.kind === 297 /* ShorthandPropertyAssignment */
|
|
50179
50188
|
|| node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
|
|
50180
|
-
|| ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
|
|
50189
|
+
|| node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
|
|
50190
|
+
|| node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
|
|
50181
50191
|
}
|
|
50182
50192
|
function isAliasableOrJsExpression(e) {
|
|
50183
50193
|
return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
|
|
@@ -50270,7 +50280,7 @@ var ts;
|
|
|
50270
50280
|
return hasExportAssignmentSymbol(moduleSymbol);
|
|
50271
50281
|
}
|
|
50272
50282
|
// JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
|
|
50273
|
-
return
|
|
50283
|
+
return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
|
|
50274
50284
|
}
|
|
50275
50285
|
function getTargetOfImportClause(node, dontResolveAlias) {
|
|
50276
50286
|
var _a;
|
|
@@ -72285,7 +72295,7 @@ var ts;
|
|
|
72285
72295
|
if (result) {
|
|
72286
72296
|
return result;
|
|
72287
72297
|
}
|
|
72288
|
-
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)
|
|
72298
|
+
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) {
|
|
72289
72299
|
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
|
|
72290
72300
|
}
|
|
72291
72301
|
}
|
|
@@ -72754,22 +72764,20 @@ var ts;
|
|
|
72754
72764
|
var inferenceContext = getInferenceContext(node);
|
|
72755
72765
|
// If no inferences have been made, nothing is gained from instantiating as type parameters
|
|
72756
72766
|
// would just be replaced with their defaults similar to the apparent type.
|
|
72757
|
-
if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
72767
|
+
if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
|
|
72758
72768
|
// For contextual signatures we incorporate all inferences made so far, e.g. from return
|
|
72759
72769
|
// types as well as arguments to the left in a function call.
|
|
72760
|
-
|
|
72761
|
-
|
|
72762
|
-
|
|
72770
|
+
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
72771
|
+
}
|
|
72772
|
+
if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) {
|
|
72763
72773
|
// For other purposes (e.g. determining whether to produce literal types) we only
|
|
72764
72774
|
// incorporate inferences made from the return type in a function call. We remove
|
|
72765
72775
|
// the 'boolean' type from the contextual type such that contextually typed boolean
|
|
72766
72776
|
// literals actually end up widening to 'boolean' (see #48363).
|
|
72767
|
-
|
|
72768
|
-
|
|
72769
|
-
|
|
72770
|
-
|
|
72771
|
-
type;
|
|
72772
|
-
}
|
|
72777
|
+
var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
|
|
72778
|
+
return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
|
|
72779
|
+
filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
|
|
72780
|
+
type;
|
|
72773
72781
|
}
|
|
72774
72782
|
}
|
|
72775
72783
|
return contextualType;
|
|
@@ -75303,29 +75311,43 @@ var ts;
|
|
|
75303
75311
|
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
|
|
75304
75312
|
// return type of 'wrap'.
|
|
75305
75313
|
if (node.kind !== 165 /* Decorator */) {
|
|
75306
|
-
var
|
|
75314
|
+
var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); });
|
|
75315
|
+
var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
75307
75316
|
if (contextualType) {
|
|
75308
75317
|
var inferenceTargetType = getReturnTypeOfSignature(signature);
|
|
75309
75318
|
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
75319
|
var outerContext = getInferenceContext(node);
|
|
75314
|
-
var
|
|
75315
|
-
|
|
75316
|
-
//
|
|
75317
|
-
//
|
|
75318
|
-
//
|
|
75319
|
-
//
|
|
75320
|
-
// declare function
|
|
75321
|
-
// const
|
|
75322
|
-
//
|
|
75323
|
-
|
|
75324
|
-
|
|
75325
|
-
|
|
75326
|
-
|
|
75327
|
-
|
|
75328
|
-
|
|
75320
|
+
var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType;
|
|
75321
|
+
// A return type inference from a binding pattern can be used in instantiating the contextual
|
|
75322
|
+
// type of an argument later in inference, but cannot stand on its own as the final return type.
|
|
75323
|
+
// It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`,
|
|
75324
|
+
// but doesn't need to go into `context.inferences`. This allows a an array binding pattern to
|
|
75325
|
+
// produce a tuple for `T` in
|
|
75326
|
+
// declare function f<T>(cb: () => T): T;
|
|
75327
|
+
// const [e1, e2, e3] = f(() => [1, "hi", true]);
|
|
75328
|
+
// but does not produce any inference for `T` in
|
|
75329
|
+
// declare function f<T>(): T;
|
|
75330
|
+
// const [e1, e2, e3] = f();
|
|
75331
|
+
if (!isFromBindingPattern) {
|
|
75332
|
+
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75333
|
+
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75334
|
+
// inferred for any outer call expression so far.
|
|
75335
|
+
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
75336
|
+
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
75337
|
+
// If the contextual type is a generic function type with a single call signature, we
|
|
75338
|
+
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
75339
|
+
// the type parameters are not erased to type any during type inference such that they can
|
|
75340
|
+
// be inferred as actual types from the contextual type. For example:
|
|
75341
|
+
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
75342
|
+
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
75343
|
+
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
75344
|
+
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
75345
|
+
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
75346
|
+
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
75347
|
+
instantiatedType;
|
|
75348
|
+
// Inferences made from return types have lower priority than all other inferences.
|
|
75349
|
+
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
|
|
75350
|
+
}
|
|
75329
75351
|
// Create a type mapper for instantiating generic contextual types using the inferences made
|
|
75330
75352
|
// from the return type. We need a separate inference pass here because (a) instantiation of
|
|
75331
75353
|
// the source type uses the outer context's return mapper (which excludes inferences made from
|
|
@@ -82441,7 +82463,7 @@ var ts;
|
|
|
82441
82463
|
}
|
|
82442
82464
|
// For a commonjs `const x = require`, validate the alias and exit
|
|
82443
82465
|
var symbol = getSymbolOfNode(node);
|
|
82444
|
-
if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
|
|
82466
|
+
if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
|
|
82445
82467
|
checkAliasSymbol(node);
|
|
82446
82468
|
return;
|
|
82447
82469
|
}
|
|
@@ -107250,7 +107272,7 @@ var ts;
|
|
|
107250
107272
|
// Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
|
|
107251
107273
|
// 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
107274
|
// is available, just because the output is reasonable for a node-like runtime.
|
|
107253
|
-
return ts.
|
|
107275
|
+
return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined;
|
|
107254
107276
|
case 271 /* ExportAssignment */:
|
|
107255
107277
|
return visitExportAssignment(node);
|
|
107256
107278
|
case 272 /* ExportDeclaration */:
|
|
@@ -123624,6 +123646,7 @@ var ts;
|
|
|
123624
123646
|
}
|
|
123625
123647
|
function reloadFileNamesFromConfigFile() {
|
|
123626
123648
|
writeLog("Reloading new file names and options");
|
|
123649
|
+
reloadLevel = ts.ConfigFileProgramReloadLevel.None;
|
|
123627
123650
|
rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
|
|
123628
123651
|
if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
|
|
123629
123652
|
hasChangedConfigFileParsingErrors = true;
|
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.20220527",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|