@zzzen/pyright-internal 1.2.0-dev.20241208 → 1.2.0-dev.20241222
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/dist/analyzer/analysis.js +1 -1
- package/dist/analyzer/analysis.js.map +1 -1
- package/dist/analyzer/analyzerNodeInfo.js +17 -18
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.js +18 -35
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +38 -55
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +146 -185
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +24 -31
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +23 -24
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constraintTracker.js +1 -2
- package/dist/analyzer/constraintTracker.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +10 -12
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js +14 -19
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +32 -27
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declarationUtils.js +8 -11
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.js +2 -3
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +6 -8
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/enums.js +12 -13
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/functionTransform.js +1 -2
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.js +18 -27
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.js +4 -5
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +6 -7
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +14 -17
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +48 -50
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.js +5 -7
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.js +8 -9
- package/dist/analyzer/parentDirectoryCache.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +30 -44
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.js +2 -3
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.js +18 -20
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.js +29 -40
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +7 -8
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +21 -23
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +1 -1
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/scope.js +10 -10
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/service.js +32 -47
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.js +21 -26
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfo.js +2 -3
- package/dist/analyzer/sourceFileInfo.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js +5 -5
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.js +19 -30
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/testWalker.js +1 -2
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +7 -9
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/tuples.js +11 -13
- package/dist/analyzer/tuples.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.js +5 -6
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.js +7 -11
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +619 -776
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -1
- package/dist/analyzer/typeEvaluatorWithTracker.js +2 -2
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
- package/dist/analyzer/typeGuards.js +26 -36
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +15 -24
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js +1 -2
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.js +65 -94
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeWalker.js +4 -8
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.js +39 -46
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +1 -0
- package/dist/analyzer/types.js +64 -103
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysis.js +2 -3
- package/dist/backgroundAnalysis.js.map +1 -1
- package/dist/backgroundAnalysisBase.js +9 -10
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.js +6 -7
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/createTypeStub.js +1 -1
- package/dist/commands/createTypeStub.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +3 -3
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/commands/quickActionCommand.js +1 -1
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/common/asyncInitialization.js +1 -1
- package/dist/common/chokidarFileWatcherProvider.js +2 -4
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
- package/dist/common/configOptions.js +6 -9
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/console.js +1 -2
- package/dist/common/console.js.map +1 -1
- package/dist/common/core.js +2 -2
- package/dist/common/core.js.map +1 -1
- package/dist/common/crypto.js +1 -1
- package/dist/common/crypto.js.map +1 -1
- package/dist/common/diagnostic.js +3 -5
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/envVarUtils.js +1 -1
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +1 -0
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileSystem.d.ts +1 -0
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/fullAccessHost.js +5 -5
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/host.js +1 -1
- package/dist/common/host.js.map +1 -1
- package/dist/common/logTracker.js +1 -1
- package/dist/common/logTracker.js.map +1 -1
- package/dist/common/lspUtils.js +1 -2
- package/dist/common/lspUtils.js.map +1 -1
- package/dist/common/progressReporter.js +1 -2
- package/dist/common/progressReporter.js.map +1 -1
- package/dist/common/realFileSystem.js +2 -3
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.js +1 -1
- package/dist/common/serviceProvider.js.map +1 -1
- package/dist/common/streamUtils.d.ts +2 -0
- package/dist/common/streamUtils.js +29 -0
- package/dist/common/streamUtils.js.map +1 -0
- package/dist/common/textEditTracker.js +4 -6
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/tomlUtils.js +3 -1
- package/dist/common/tomlUtils.js.map +1 -1
- package/dist/common/uri/baseUri.js +1 -1
- package/dist/common/uri/baseUri.js.map +1 -1
- package/dist/common/uri/emptyUri.js +1 -1
- package/dist/common/uri/emptyUri.js.map +1 -1
- package/dist/common/uri/fileUri.js +2 -2
- package/dist/common/uri/fileUri.js.map +1 -1
- package/dist/common/uri/memoization.js +1 -1
- package/dist/common/uri/memoization.js.map +1 -1
- package/dist/common/uri/uri.js +2 -3
- package/dist/common/uri/uri.js.map +1 -1
- package/dist/common/uri/uriUtils.js +6 -8
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/common/uri/webUri.js +2 -2
- package/dist/common/uri/webUri.js.map +1 -1
- package/dist/common/workspaceEditUtils.js +10 -15
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.js +34 -42
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +8 -10
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.js +16 -19
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +6 -11
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +81 -106
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.js +3 -3
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.js +6 -9
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +32 -32
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/dynamicFeature.js +1 -2
- package/dist/languageService/dynamicFeature.js.map +1 -1
- package/dist/languageService/hoverProvider.js +17 -23
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/referencesProvider.js +4 -9
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.js +2 -4
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +11 -15
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +15 -17
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.js +3 -3
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +6 -0
- package/dist/localization/package.nls.de.json +6 -0
- package/dist/localization/package.nls.en-us.json +8 -8
- package/dist/localization/package.nls.es.json +6 -0
- package/dist/localization/package.nls.fr.json +7 -1
- package/dist/localization/package.nls.it.json +6 -0
- package/dist/localization/package.nls.ja.json +6 -0
- package/dist/localization/package.nls.ko.json +6 -0
- package/dist/localization/package.nls.pl.json +6 -0
- package/dist/localization/package.nls.pt-br.json +6 -0
- package/dist/localization/package.nls.qps-ploc.json +6 -0
- package/dist/localization/package.nls.ru.json +6 -0
- package/dist/localization/package.nls.tr.json +6 -0
- package/dist/localization/package.nls.zh-cn.json +6 -0
- package/dist/localization/package.nls.zh-tw.json +6 -0
- package/dist/parser/parser.js +30 -38
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/tokenizer.js +8 -13
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/pprof/profiler.js +3 -3
- package/dist/pprof/profiler.js.map +1 -1
- package/dist/pyright.js +9 -11
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.js +4 -5
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.js +3 -5
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +3 -3
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/classDeclaration.test.js +7 -10
- package/dist/tests/classDeclaration.test.js.map +1 -1
- package/dist/tests/completions.test.js +3 -3
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +10 -15
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/diagnosticOverrides.test.js +4 -6
- package/dist/tests/diagnosticOverrides.test.js.map +1 -1
- package/dist/tests/envVarUtils.test.js +9 -12
- package/dist/tests/envVarUtils.test.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +45 -60
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +6 -7
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.js +3 -3
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/importResolver.test.js +6 -7
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +2 -2
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js +11 -12
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/languageServer.test.js +1 -2
- package/dist/tests/languageServer.test.js.map +1 -1
- package/dist/tests/lsp/languageServer.js +10 -14
- package/dist/tests/lsp/languageServer.js.map +1 -1
- package/dist/tests/lsp/languageServerTestUtils.js +10 -14
- package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +7 -7
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/parser.test.js +2 -2
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/service.test.js +2 -3
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +2 -3
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js +3 -4
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/testState.test.js +3 -6
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testStateUtils.js +3 -4
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js +2 -2
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +1 -1
- package/dist/tests/typePrinter.test.js +1 -2
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/tests/workspaceEditUtils.test.js +3 -5
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/workspaceFactory.js +2 -3
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +1 -1
package/dist/analyzer/types.js
CHANGED
@@ -130,8 +130,7 @@ var TypeBase;
|
|
130
130
|
}
|
131
131
|
TypeBase.addProps = addProps;
|
132
132
|
function getInstantiableDepth(type) {
|
133
|
-
|
134
|
-
return (_b = (_a = type.props) === null || _a === void 0 ? void 0 : _a.instantiableDepth) !== null && _b !== void 0 ? _b : 0;
|
133
|
+
return type.props?.instantiableDepth ?? 0;
|
135
134
|
}
|
136
135
|
TypeBase.getInstantiableDepth = getInstantiableDepth;
|
137
136
|
function setSpecialForm(type, specialForm) {
|
@@ -173,14 +172,13 @@ var TypeBase;
|
|
173
172
|
}
|
174
173
|
TypeBase.cloneAsSpecialForm = cloneAsSpecialForm;
|
175
174
|
function cloneTypeAsInstance(type, cache) {
|
176
|
-
var _a, _b;
|
177
175
|
(0, debug_1.assert)(TypeBase.isInstantiable(type));
|
178
176
|
const newInstance = TypeBase.cloneType(type);
|
179
177
|
// Remove type form information from the type.
|
180
|
-
if (
|
178
|
+
if (newInstance.props?.typeForm) {
|
181
179
|
TypeBase.setTypeForm(newInstance, undefined);
|
182
180
|
}
|
183
|
-
const depth =
|
181
|
+
const depth = newInstance.props?.instantiableDepth;
|
184
182
|
if (depth === undefined) {
|
185
183
|
newInstance.flags &= ~1 /* TypeFlags.Instantiable */;
|
186
184
|
newInstance.flags |= 2 /* TypeFlags.Instance */;
|
@@ -202,23 +200,22 @@ var TypeBase;
|
|
202
200
|
}
|
203
201
|
TypeBase.cloneTypeAsInstance = cloneTypeAsInstance;
|
204
202
|
function cloneTypeAsInstantiable(type, cache) {
|
205
|
-
var _a, _b, _c;
|
206
203
|
const newInstance = TypeBase.cloneType(type);
|
207
204
|
if (TypeBase.isInstance(type)) {
|
208
205
|
newInstance.flags &= ~2 /* TypeFlags.Instance */;
|
209
206
|
newInstance.flags |= 1 /* TypeFlags.Instantiable */;
|
210
207
|
}
|
211
208
|
else {
|
212
|
-
const oldDepth =
|
209
|
+
const oldDepth = type.props?.instantiableDepth;
|
213
210
|
TypeBase.setInstantiableDepth(newInstance, oldDepth === undefined ? 1 : oldDepth + 1);
|
214
211
|
}
|
215
212
|
// Remove type alias information because the type will no longer match
|
216
213
|
// that of the type alias definition.
|
217
|
-
if (
|
214
|
+
if (newInstance.props?.typeAliasInfo) {
|
218
215
|
TypeBase.setTypeAliasInfo(newInstance, undefined);
|
219
216
|
}
|
220
217
|
// Remove type form information from the type.
|
221
|
-
if (
|
218
|
+
if (newInstance.props?.typeForm) {
|
222
219
|
TypeBase.setTypeForm(newInstance, undefined);
|
223
220
|
}
|
224
221
|
// Should we cache it for next time?
|
@@ -244,10 +241,9 @@ var TypeBase;
|
|
244
241
|
}
|
245
242
|
TypeBase.cloneWithTypeForm = cloneWithTypeForm;
|
246
243
|
function cloneForCondition(type, condition) {
|
247
|
-
var _a;
|
248
244
|
// Handle the common case where there are no conditions. In this case,
|
249
245
|
// cloning isn't necessary.
|
250
|
-
if (
|
246
|
+
if (type.props?.condition === undefined && condition === undefined) {
|
251
247
|
return type;
|
252
248
|
}
|
253
249
|
const typeClone = cloneType(type);
|
@@ -281,9 +277,8 @@ var UnboundType;
|
|
281
277
|
}
|
282
278
|
UnboundType.create = create;
|
283
279
|
function convertToInstance(type) {
|
284
|
-
var _a;
|
285
280
|
// Remove the "special form" if present. Otherwise return the existing type.
|
286
|
-
return
|
281
|
+
return type.props?.specialForm ? UnboundType.create() : type;
|
287
282
|
}
|
288
283
|
UnboundType.convertToInstance = convertToInstance;
|
289
284
|
})(UnboundType || (exports.UnboundType = UnboundType = {}));
|
@@ -331,9 +326,8 @@ var UnknownType;
|
|
331
326
|
}
|
332
327
|
UnknownType.createPossibleType = createPossibleType;
|
333
328
|
function convertToInstance(type) {
|
334
|
-
var _a;
|
335
329
|
// Remove the "special form" if present. Otherwise return the existing type.
|
336
|
-
return
|
330
|
+
return type.props?.specialForm ? UnknownType.create(type.priv.isIncomplete) : type;
|
337
331
|
}
|
338
332
|
UnknownType.convertToInstance = convertToInstance;
|
339
333
|
})(UnknownType || (exports.UnknownType = UnknownType = {}));
|
@@ -488,15 +482,14 @@ var ClassType;
|
|
488
482
|
}
|
489
483
|
ClassType.createInstantiable = createInstantiable;
|
490
484
|
function cloneAsInstance(type, includeSubclasses = true) {
|
491
|
-
var _a, _b;
|
492
485
|
if (TypeBase.isInstance(type)) {
|
493
486
|
return type;
|
494
487
|
}
|
495
|
-
if (includeSubclasses &&
|
488
|
+
if (includeSubclasses && type.cached?.typeBaseInstanceType) {
|
496
489
|
return type.cached.typeBaseInstanceType;
|
497
490
|
}
|
498
491
|
const newInstance = TypeBase.cloneTypeAsInstance(type, /* cache */ includeSubclasses);
|
499
|
-
if (
|
492
|
+
if (newInstance.props?.specialForm) {
|
500
493
|
TypeBase.setSpecialForm(newInstance, undefined);
|
501
494
|
}
|
502
495
|
if (includeSubclasses) {
|
@@ -506,8 +499,7 @@ var ClassType;
|
|
506
499
|
}
|
507
500
|
ClassType.cloneAsInstance = cloneAsInstance;
|
508
501
|
function cloneAsInstantiable(type, includeSubclasses = true) {
|
509
|
-
|
510
|
-
if (includeSubclasses && ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstantiableType)) {
|
502
|
+
if (includeSubclasses && type.cached?.typeBaseInstantiableType) {
|
511
503
|
return type.cached.typeBaseInstantiableType;
|
512
504
|
}
|
513
505
|
const newInstance = TypeBase.cloneTypeAsInstantiable(type, includeSubclasses);
|
@@ -519,7 +511,7 @@ var ClassType;
|
|
519
511
|
ClassType.cloneAsInstantiable = cloneAsInstantiable;
|
520
512
|
function specialize(classType, typeArgs, isTypeArgExplicit, includeSubclasses = false, tupleTypeArgs, isEmptyContainer) {
|
521
513
|
const newClassType = TypeBase.cloneType(classType);
|
522
|
-
newClassType.priv.typeArgs =
|
514
|
+
newClassType.priv.typeArgs = typeArgs?.length === 0 ? undefined : typeArgs;
|
523
515
|
// If the user passed undefined for this argument, infer it
|
524
516
|
// based on whether typeArgs was provided.
|
525
517
|
if (isTypeArgExplicit === undefined) {
|
@@ -546,12 +538,11 @@ var ClassType;
|
|
546
538
|
}
|
547
539
|
ClassType.cloneIncludeSubclasses = cloneIncludeSubclasses;
|
548
540
|
function cloneWithLiteral(classType, value) {
|
549
|
-
var _a;
|
550
541
|
const newClassType = TypeBase.cloneType(classType);
|
551
542
|
newClassType.priv.literalValue = value;
|
552
543
|
// Remove type alias information because the type will no longer match
|
553
544
|
// that of the type alias definition if we change the literal type.
|
554
|
-
if (
|
545
|
+
if (newClassType.props?.typeAliasInfo) {
|
555
546
|
TypeBase.setTypeAliasInfo(newClassType, undefined);
|
556
547
|
}
|
557
548
|
return newClassType;
|
@@ -674,18 +665,17 @@ var ClassType;
|
|
674
665
|
// i.e. all of the "narrowed entries" found within type2 are also found
|
675
666
|
// within type1.
|
676
667
|
function isTypedDictNarrower(type1, type2) {
|
677
|
-
var _a;
|
678
668
|
const tdEntries2 = type2.priv.typedDictNarrowedEntries;
|
679
669
|
if (!tdEntries2) {
|
680
670
|
return true;
|
681
671
|
}
|
682
|
-
const tdEntries1 =
|
672
|
+
const tdEntries1 = type1.priv.typedDictNarrowedEntries ?? new Map();
|
683
673
|
let key;
|
684
674
|
let entry2;
|
685
675
|
for ([key, entry2] of tdEntries2.entries()) {
|
686
676
|
if (entry2.isProvided) {
|
687
677
|
const entry1 = tdEntries1.get(key);
|
688
|
-
if (!
|
678
|
+
if (!entry1?.isProvided) {
|
689
679
|
return false;
|
690
680
|
}
|
691
681
|
}
|
@@ -730,38 +720,31 @@ var ClassType;
|
|
730
720
|
}
|
731
721
|
ClassType.isDataClass = isDataClass;
|
732
722
|
function isDataClassSkipGenerateInit(classType) {
|
733
|
-
|
734
|
-
return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.skipGenerateInit);
|
723
|
+
return !!classType.shared.dataClassBehaviors?.skipGenerateInit;
|
735
724
|
}
|
736
725
|
ClassType.isDataClassSkipGenerateInit = isDataClassSkipGenerateInit;
|
737
726
|
function isDataClassSkipGenerateEq(classType) {
|
738
|
-
|
739
|
-
return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.skipGenerateEq);
|
727
|
+
return !!classType.shared.dataClassBehaviors?.skipGenerateEq;
|
740
728
|
}
|
741
729
|
ClassType.isDataClassSkipGenerateEq = isDataClassSkipGenerateEq;
|
742
730
|
function isDataClassFrozen(classType) {
|
743
|
-
|
744
|
-
return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.frozen);
|
731
|
+
return !!classType.shared.dataClassBehaviors?.frozen;
|
745
732
|
}
|
746
733
|
ClassType.isDataClassFrozen = isDataClassFrozen;
|
747
734
|
function isDataClassGenerateOrder(classType) {
|
748
|
-
|
749
|
-
return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.generateOrder);
|
735
|
+
return !!classType.shared.dataClassBehaviors?.generateOrder;
|
750
736
|
}
|
751
737
|
ClassType.isDataClassGenerateOrder = isDataClassGenerateOrder;
|
752
738
|
function isDataClassKeywordOnly(classType) {
|
753
|
-
|
754
|
-
return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.keywordOnly);
|
739
|
+
return !!classType.shared.dataClassBehaviors?.keywordOnly;
|
755
740
|
}
|
756
741
|
ClassType.isDataClassKeywordOnly = isDataClassKeywordOnly;
|
757
742
|
function isDataClassGenerateSlots(classType) {
|
758
|
-
|
759
|
-
return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.generateSlots);
|
743
|
+
return !!classType.shared.dataClassBehaviors?.generateSlots;
|
760
744
|
}
|
761
745
|
ClassType.isDataClassGenerateSlots = isDataClassGenerateSlots;
|
762
746
|
function isDataClassGenerateHash(classType) {
|
763
|
-
|
764
|
-
return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.generateHash);
|
747
|
+
return !!classType.shared.dataClassBehaviors?.generateHash;
|
765
748
|
}
|
766
749
|
ClassType.isDataClassGenerateHash = isDataClassGenerateHash;
|
767
750
|
function isTypeCheckOnly(classType) {
|
@@ -829,8 +812,7 @@ var ClassType;
|
|
829
812
|
}
|
830
813
|
ClassType.isPseudoGenericClass = isPseudoGenericClass;
|
831
814
|
function getDataClassEntries(classType) {
|
832
|
-
|
833
|
-
(_b = (_a = classType.shared).synthesizeMethodsDeferred) === null || _b === void 0 ? void 0 : _b.call(_a);
|
815
|
+
classType.shared.synthesizeMethodsDeferred?.();
|
834
816
|
return classType.shared.dataClassEntries || [];
|
835
817
|
}
|
836
818
|
ClassType.getDataClassEntries = getDataClassEntries;
|
@@ -863,17 +845,15 @@ var ClassType;
|
|
863
845
|
}
|
864
846
|
ClassType.derivesFromAnyOrUnknown = derivesFromAnyOrUnknown;
|
865
847
|
function getSymbolTable(classType) {
|
866
|
-
|
867
|
-
(_b = (_a = classType.shared).synthesizeMethodsDeferred) === null || _b === void 0 ? void 0 : _b.call(_a);
|
848
|
+
classType.shared.synthesizeMethodsDeferred?.();
|
868
849
|
return classType.shared.fields;
|
869
850
|
}
|
870
851
|
ClassType.getSymbolTable = getSymbolTable;
|
871
852
|
function getInheritedSlotsNames(classType) {
|
872
|
-
var _a, _b, _c, _d;
|
873
853
|
// First synthesize methods if needed. The slots entries
|
874
854
|
// can depend on synthesized methods.
|
875
|
-
|
876
|
-
|
855
|
+
classType.shared.synthesizeMethodsDeferred?.();
|
856
|
+
classType.shared.calculateInheritedSlotsNamesDeferred?.();
|
877
857
|
return classType.shared.inheritedSlotsNamesCached;
|
878
858
|
}
|
879
859
|
ClassType.getInheritedSlotsNames = getInheritedSlotsNames;
|
@@ -1147,7 +1127,6 @@ var FunctionType;
|
|
1147
1127
|
// Creates a deep copy of the function type, including a fresh
|
1148
1128
|
// version of _functionDetails.
|
1149
1129
|
function clone(type, stripFirstParam = false, boundToType) {
|
1150
|
-
var _a, _b;
|
1151
1130
|
const newFunction = TypeBase.cloneType(type);
|
1152
1131
|
newFunction.shared = { ...type.shared };
|
1153
1132
|
newFunction.priv.preBoundFlags = newFunction.shared.flags;
|
@@ -1176,7 +1155,7 @@ var FunctionType;
|
|
1176
1155
|
newFunction.shared.flags &= ~(1 /* FunctionTypeFlags.ConstructorMethod */ | 2 /* FunctionTypeFlags.ClassMethod */);
|
1177
1156
|
newFunction.shared.flags |= 4 /* FunctionTypeFlags.StaticMethod */;
|
1178
1157
|
}
|
1179
|
-
if (
|
1158
|
+
if (type.props?.typeAliasInfo) {
|
1180
1159
|
TypeBase.setTypeAliasInfo(newFunction, type.props.typeAliasInfo);
|
1181
1160
|
}
|
1182
1161
|
if (type.priv.specializedTypes) {
|
@@ -1185,7 +1164,7 @@ var FunctionType;
|
|
1185
1164
|
? type.priv.specializedTypes.parameterTypes.slice(1)
|
1186
1165
|
: type.priv.specializedTypes.parameterTypes,
|
1187
1166
|
parameterDefaultTypes: stripFirstParam
|
1188
|
-
?
|
1167
|
+
? type.priv.specializedTypes.parameterDefaultTypes?.slice(1)
|
1189
1168
|
: type.priv.specializedTypes.parameterDefaultTypes,
|
1190
1169
|
returnType: type.priv.specializedTypes.returnType,
|
1191
1170
|
};
|
@@ -1195,20 +1174,18 @@ var FunctionType;
|
|
1195
1174
|
}
|
1196
1175
|
FunctionType.clone = clone;
|
1197
1176
|
function cloneAsInstance(type) {
|
1198
|
-
|
1199
|
-
if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstanceType) {
|
1177
|
+
if (type.cached?.typeBaseInstanceType) {
|
1200
1178
|
return type.cached.typeBaseInstanceType;
|
1201
1179
|
}
|
1202
1180
|
const newInstance = TypeBase.cloneTypeAsInstance(type, /* cache */ true);
|
1203
|
-
if (
|
1181
|
+
if (newInstance.props?.specialForm) {
|
1204
1182
|
TypeBase.setSpecialForm(newInstance, undefined);
|
1205
1183
|
}
|
1206
1184
|
return newInstance;
|
1207
1185
|
}
|
1208
1186
|
FunctionType.cloneAsInstance = cloneAsInstance;
|
1209
1187
|
function cloneAsInstantiable(type) {
|
1210
|
-
|
1211
|
-
if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstantiableType) {
|
1188
|
+
if (type.cached?.typeBaseInstantiableType) {
|
1212
1189
|
return type.cached.typeBaseInstantiableType;
|
1213
1190
|
}
|
1214
1191
|
const newInstance = TypeBase.cloneTypeAsInstantiable(type, /* cache */ true);
|
@@ -1273,10 +1250,9 @@ var FunctionType;
|
|
1273
1250
|
const specializedTypes = newFunction.priv.specializedTypes;
|
1274
1251
|
if (specializedTypes) {
|
1275
1252
|
paramSpecValue.shared.parameters.forEach((_, index) => {
|
1276
|
-
var _a;
|
1277
1253
|
specializedTypes.parameterTypes.push(FunctionType.getParamType(paramSpecValue, index));
|
1278
1254
|
if (specializedTypes.parameterDefaultTypes) {
|
1279
|
-
|
1255
|
+
specializedTypes.parameterDefaultTypes?.push(FunctionType.getParamDefaultType(paramSpecValue, index));
|
1280
1256
|
}
|
1281
1257
|
});
|
1282
1258
|
}
|
@@ -1538,9 +1514,8 @@ var FunctionType;
|
|
1538
1514
|
}
|
1539
1515
|
FunctionType.getParamType = getParamType;
|
1540
1516
|
function getParamDefaultType(type, index) {
|
1541
|
-
var _a;
|
1542
1517
|
(0, debug_1.assert)(index < type.shared.parameters.length, 'Parameter types array overflow');
|
1543
|
-
if (
|
1518
|
+
if (type.priv.specializedTypes?.parameterDefaultTypes &&
|
1544
1519
|
index < type.priv.specializedTypes.parameterDefaultTypes.length) {
|
1545
1520
|
const defaultArgType = type.priv.specializedTypes.parameterDefaultTypes[index];
|
1546
1521
|
if (defaultArgType) {
|
@@ -1566,8 +1541,7 @@ var FunctionType;
|
|
1566
1541
|
}
|
1567
1542
|
FunctionType.addKeywordOnlyParamSeparator = addKeywordOnlyParamSeparator;
|
1568
1543
|
function getEffectiveReturnType(type, includeInferred = true) {
|
1569
|
-
|
1570
|
-
if ((_a = type.priv.specializedTypes) === null || _a === void 0 ? void 0 : _a.returnType) {
|
1544
|
+
if (type.priv.specializedTypes?.returnType) {
|
1571
1545
|
return type.priv.specializedTypes.returnType;
|
1572
1546
|
}
|
1573
1547
|
if (type.shared.declaredReturnType) {
|
@@ -1645,9 +1619,8 @@ var NeverType;
|
|
1645
1619
|
}
|
1646
1620
|
NeverType.createNoReturn = createNoReturn;
|
1647
1621
|
function convertToInstance(type) {
|
1648
|
-
var _a, _b;
|
1649
1622
|
// Remove the specialForm or typeForm if present. Otherwise return the existing type.
|
1650
|
-
if (!
|
1623
|
+
if (!type.props?.specialForm && !type.props?.typeForm) {
|
1651
1624
|
return type;
|
1652
1625
|
}
|
1653
1626
|
return type.priv.isNoReturn ? NeverType.createNoReturn() : NeverType.createNever();
|
@@ -1691,9 +1664,8 @@ var AnyType;
|
|
1691
1664
|
})(AnyType || (exports.AnyType = AnyType = {}));
|
1692
1665
|
(function (AnyType) {
|
1693
1666
|
function convertToInstance(type) {
|
1694
|
-
var _a;
|
1695
1667
|
// Remove the "special form" if present. Otherwise return the existing type.
|
1696
|
-
return
|
1668
|
+
return type.props?.specialForm ? AnyType.create() : type;
|
1697
1669
|
}
|
1698
1670
|
AnyType.convertToInstance = convertToInstance;
|
1699
1671
|
})(AnyType || (exports.AnyType = AnyType = {}));
|
@@ -1797,11 +1769,10 @@ var UnionType;
|
|
1797
1769
|
}
|
1798
1770
|
UnionType.create = create;
|
1799
1771
|
function addType(unionType, newType) {
|
1800
|
-
var _a, _b;
|
1801
1772
|
// If we're adding a string, integer or enum literal, add it to the
|
1802
1773
|
// corresponding literal map to speed up some operations. It's not
|
1803
1774
|
// uncommon for unions to contain hundreds of literals.
|
1804
|
-
if (isClass(newType) && newType.priv.literalValue !== undefined && !
|
1775
|
+
if (isClass(newType) && newType.priv.literalValue !== undefined && !newType.props?.condition) {
|
1805
1776
|
const literalMaps = isClassInstance(newType)
|
1806
1777
|
? unionType.priv.literalInstances
|
1807
1778
|
: unionType.priv.literalClasses;
|
@@ -1827,7 +1798,7 @@ var UnionType;
|
|
1827
1798
|
}
|
1828
1799
|
unionType.flags &= newType.flags;
|
1829
1800
|
unionType.priv.subtypes.push(newType);
|
1830
|
-
if (isTypeVar(newType) &&
|
1801
|
+
if (isTypeVar(newType) && newType.shared.recursiveAlias?.name) {
|
1831
1802
|
// Note that at least one recursive type alias was included in
|
1832
1803
|
// this union. We'll need to expand it before the union is used.
|
1833
1804
|
unionType.priv.includesRecursiveTypeAlias = true;
|
@@ -1838,10 +1809,9 @@ var UnionType;
|
|
1838
1809
|
// the method skips any subtype indexes that are in the set and adds a found index to
|
1839
1810
|
// the exclusion set. This speeds up union type comparisons.
|
1840
1811
|
function containsType(unionType, subtype, options = {}, exclusionSet, recursionCount = 0) {
|
1841
|
-
var _a;
|
1842
1812
|
// Handle string literals as a special case because unions can sometimes
|
1843
1813
|
// contain hundreds of string literal types.
|
1844
|
-
if (isClass(subtype) &&
|
1814
|
+
if (isClass(subtype) && subtype.props?.condition === undefined && subtype.priv.literalValue !== undefined) {
|
1845
1815
|
const literalMaps = isClassInstance(subtype)
|
1846
1816
|
? unionType.priv.literalInstances
|
1847
1817
|
: unionType.priv.literalClasses;
|
@@ -1857,7 +1827,7 @@ var UnionType;
|
|
1857
1827
|
}
|
1858
1828
|
}
|
1859
1829
|
const foundIndex = unionType.priv.subtypes.findIndex((t, i) => {
|
1860
|
-
if (exclusionSet
|
1830
|
+
if (exclusionSet?.has(i)) {
|
1861
1831
|
return false;
|
1862
1832
|
}
|
1863
1833
|
return isTypeSame(t, subtype, options, recursionCount);
|
@@ -1865,14 +1835,13 @@ var UnionType;
|
|
1865
1835
|
if (foundIndex < 0) {
|
1866
1836
|
return false;
|
1867
1837
|
}
|
1868
|
-
exclusionSet
|
1838
|
+
exclusionSet?.add(foundIndex);
|
1869
1839
|
return true;
|
1870
1840
|
}
|
1871
1841
|
UnionType.containsType = containsType;
|
1872
1842
|
function addTypeAliasSource(unionType, typeAliasSource) {
|
1873
|
-
var _a;
|
1874
1843
|
if (typeAliasSource.category === 8 /* TypeCategory.Union */) {
|
1875
|
-
const sourcesToAdd =
|
1844
|
+
const sourcesToAdd = typeAliasSource.props?.typeAliasInfo
|
1876
1845
|
? [typeAliasSource]
|
1877
1846
|
: typeAliasSource.priv.typeAliasSources;
|
1878
1847
|
if (sourcesToAdd) {
|
@@ -1928,13 +1897,12 @@ var TypeVarType;
|
|
1928
1897
|
}
|
1929
1898
|
TypeVarType.createInstantiable = createInstantiable;
|
1930
1899
|
function cloneAsInstance(type) {
|
1931
|
-
var _a, _b;
|
1932
1900
|
(0, debug_1.assert)(TypeBase.isInstantiable(type));
|
1933
|
-
if (
|
1901
|
+
if (type.cached?.typeBaseInstanceType) {
|
1934
1902
|
return type.cached.typeBaseInstanceType;
|
1935
1903
|
}
|
1936
1904
|
const newInstance = TypeBase.cloneTypeAsInstance(type, /* cache */ true);
|
1937
|
-
if (
|
1905
|
+
if (newInstance.props?.specialForm) {
|
1938
1906
|
TypeBase.setSpecialForm(newInstance, undefined);
|
1939
1907
|
}
|
1940
1908
|
if (newInstance.priv.freeTypeVar) {
|
@@ -1944,8 +1912,7 @@ var TypeVarType;
|
|
1944
1912
|
}
|
1945
1913
|
TypeVarType.cloneAsInstance = cloneAsInstance;
|
1946
1914
|
function cloneAsInstantiable(type) {
|
1947
|
-
|
1948
|
-
if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstantiableType) {
|
1915
|
+
if (type.cached?.typeBaseInstantiableType) {
|
1949
1916
|
return type.cached.typeBaseInstantiableType;
|
1950
1917
|
}
|
1951
1918
|
const newInstance = TypeBase.cloneTypeAsInstantiable(type, /* cache */ true);
|
@@ -1956,19 +1923,18 @@ var TypeVarType;
|
|
1956
1923
|
}
|
1957
1924
|
TypeVarType.cloneAsInstantiable = cloneAsInstantiable;
|
1958
1925
|
function cloneForNewName(type, name) {
|
1959
|
-
var _a;
|
1960
1926
|
const newInstance = TypeBase.cloneType(type);
|
1961
1927
|
newInstance.shared = { ...type.shared };
|
1962
1928
|
newInstance.shared.name = name;
|
1963
1929
|
if (newInstance.priv.scopeId) {
|
1964
|
-
newInstance.priv.nameWithScope = makeNameWithScope(name, newInstance.priv.scopeId,
|
1930
|
+
newInstance.priv.nameWithScope = makeNameWithScope(name, newInstance.priv.scopeId, newInstance.priv.scopeName ?? '');
|
1965
1931
|
}
|
1966
1932
|
return newInstance;
|
1967
1933
|
}
|
1968
1934
|
TypeVarType.cloneForNewName = cloneForNewName;
|
1969
1935
|
function cloneForScopeId(type, scopeId, scopeName, scopeType) {
|
1970
1936
|
const newInstance = TypeBase.cloneType(type);
|
1971
|
-
newInstance.priv.nameWithScope = makeNameWithScope(type.shared.name, scopeId, scopeName
|
1937
|
+
newInstance.priv.nameWithScope = makeNameWithScope(type.shared.name, scopeId, scopeName ?? '');
|
1972
1938
|
newInstance.priv.scopeId = scopeId;
|
1973
1939
|
newInstance.priv.scopeName = scopeName;
|
1974
1940
|
newInstance.priv.scopeType = scopeType;
|
@@ -2142,8 +2108,7 @@ var TypeVarType;
|
|
2142
2108
|
}
|
2143
2109
|
TypeVarType.getReadableName = getReadableName;
|
2144
2110
|
function getVariance(type) {
|
2145
|
-
|
2146
|
-
const variance = (_a = type.priv.computedVariance) !== null && _a !== void 0 ? _a : type.shared.declaredVariance;
|
2111
|
+
const variance = type.priv.computedVariance ?? type.shared.declaredVariance;
|
2147
2112
|
// By this point, the variance should have been inferred.
|
2148
2113
|
(0, debug_1.assert)(variance !== 0 /* Variance.Auto */, 'Expected variance to be inferred');
|
2149
2114
|
// If we're in the process of computing variance, it will still be
|
@@ -2249,14 +2214,13 @@ function isOverloaded(type) {
|
|
2249
2214
|
return type.category === 5 /* TypeCategory.Overloaded */;
|
2250
2215
|
}
|
2251
2216
|
function getTypeAliasInfo(type) {
|
2252
|
-
|
2253
|
-
if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) {
|
2217
|
+
if (type.props?.typeAliasInfo) {
|
2254
2218
|
return type.props.typeAliasInfo;
|
2255
2219
|
}
|
2256
2220
|
if (isTypeVar(type) &&
|
2257
2221
|
type.shared.recursiveAlias &&
|
2258
2222
|
type.shared.boundType &&
|
2259
|
-
|
2223
|
+
type.shared.boundType.props?.typeAliasInfo) {
|
2260
2224
|
return type.shared.boundType.props.typeAliasInfo;
|
2261
2225
|
}
|
2262
2226
|
return undefined;
|
@@ -2265,7 +2229,6 @@ function getTypeAliasInfo(type) {
|
|
2265
2229
|
// type arguments for "pseudo-generic" classes (non-generic classes whose init
|
2266
2230
|
// methods are not annotated and are therefore treated as generic) are ignored.
|
2267
2231
|
function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
2268
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2269
2232
|
if (type1 === type2) {
|
2270
2233
|
return true;
|
2271
2234
|
}
|
@@ -2290,8 +2253,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2290
2253
|
}
|
2291
2254
|
recursionCount++;
|
2292
2255
|
if (options.honorTypeForm) {
|
2293
|
-
const typeForm1 =
|
2294
|
-
const typeForm2 =
|
2256
|
+
const typeForm1 = type1.props?.typeForm;
|
2257
|
+
const typeForm2 = type2.props?.typeForm;
|
2295
2258
|
if (typeForm1) {
|
2296
2259
|
if (!typeForm2) {
|
2297
2260
|
return false;
|
@@ -2311,7 +2274,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2311
2274
|
if (!ClassType.isSameGenericClass(type1, classType2, recursionCount)) {
|
2312
2275
|
return false;
|
2313
2276
|
}
|
2314
|
-
if (!options.ignoreConditions && !TypeCondition.isSame(
|
2277
|
+
if (!options.ignoreConditions && !TypeCondition.isSame(type1.props?.condition, type2.props?.condition)) {
|
2315
2278
|
return false;
|
2316
2279
|
}
|
2317
2280
|
if (!options.ignorePseudoGeneric || !ClassType.isPseudoGenericClass(type1)) {
|
@@ -2469,8 +2432,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2469
2432
|
// Handle the case where this is a generic recursive type alias. Make
|
2470
2433
|
// sure that the type argument types match.
|
2471
2434
|
if (type1.shared.recursiveAlias && type2TypeVar.shared.recursiveAlias) {
|
2472
|
-
const type1TypeArgs =
|
2473
|
-
const type2TypeArgs =
|
2435
|
+
const type1TypeArgs = type1?.props?.typeAliasInfo?.typeArgs || [];
|
2436
|
+
const type2TypeArgs = type2?.props?.typeAliasInfo?.typeArgs || [];
|
2474
2437
|
const typeArgCount = Math.max(type1TypeArgs.length, type2TypeArgs.length);
|
2475
2438
|
for (let i = 0; i < typeArgCount; i++) {
|
2476
2439
|
// Assume that missing type args are "Any".
|
@@ -2589,7 +2552,6 @@ function findSubtype(type, filter) {
|
|
2589
2552
|
// are combined into a UnionType. NeverTypes are filtered out.
|
2590
2553
|
// If no types remain in the end, a NeverType is returned.
|
2591
2554
|
function combineTypes(subtypes, options) {
|
2592
|
-
var _a, _b;
|
2593
2555
|
let neverTypes;
|
2594
2556
|
// Filter out any Never or NoReturn types.
|
2595
2557
|
[neverTypes, subtypes] = (0, collectionUtils_1.partition)(subtypes, isNever);
|
@@ -2597,7 +2559,7 @@ function combineTypes(subtypes, options) {
|
|
2597
2559
|
if (neverTypes.length > 0) {
|
2598
2560
|
// Prefer NoReturn over Never. This approach preserves type alias
|
2599
2561
|
// information if present.
|
2600
|
-
return
|
2562
|
+
return neverTypes.find((t) => t.priv.isNoReturn) ?? neverTypes[0];
|
2601
2563
|
}
|
2602
2564
|
return NeverType.createNever();
|
2603
2565
|
}
|
@@ -2625,7 +2587,7 @@ function combineTypes(subtypes, options) {
|
|
2625
2587
|
expandedTypes = subtypes.slice(0, i);
|
2626
2588
|
}
|
2627
2589
|
expandedTypes = expandedTypes.concat(subtype.priv.subtypes);
|
2628
|
-
if (
|
2590
|
+
if (subtype.props?.typeAliasInfo) {
|
2629
2591
|
typeAliasSources.add(subtype);
|
2630
2592
|
}
|
2631
2593
|
else if (subtype.priv.typeAliasSources) {
|
@@ -2638,7 +2600,7 @@ function combineTypes(subtypes, options) {
|
|
2638
2600
|
expandedTypes.push(subtype);
|
2639
2601
|
}
|
2640
2602
|
}
|
2641
|
-
expandedTypes = expandedTypes
|
2603
|
+
expandedTypes = expandedTypes ?? subtypes;
|
2642
2604
|
// Sort all of the literal and empty types to the end.
|
2643
2605
|
expandedTypes = expandedTypes.sort((type1, type2) => {
|
2644
2606
|
if (isClass(type1) && type1.priv.literalValue !== undefined) {
|
@@ -2670,8 +2632,8 @@ function combineTypes(subtypes, options) {
|
|
2670
2632
|
UnionType.addType(newUnionType, subtype);
|
2671
2633
|
}
|
2672
2634
|
else {
|
2673
|
-
if (
|
2674
|
-
_addTypeIfUnique(newUnionType, subtype, !
|
2635
|
+
if (options?.maxSubtypeCount === undefined || newUnionType.priv.subtypes.length < options.maxSubtypeCount) {
|
2636
|
+
_addTypeIfUnique(newUnionType, subtype, !options?.skipElideRedundantLiterals);
|
2675
2637
|
}
|
2676
2638
|
else {
|
2677
2639
|
hitMaxSubtypeCount = true;
|
@@ -2708,11 +2670,10 @@ function isSameWithoutLiteralValue(destType, srcType) {
|
|
2708
2670
|
return false;
|
2709
2671
|
}
|
2710
2672
|
function _addTypeIfUnique(unionType, typeToAdd, elideRedundantLiterals) {
|
2711
|
-
var _a, _b, _c;
|
2712
2673
|
// Handle the addition of a string literal in a special manner to
|
2713
2674
|
// avoid n^2 behavior in unions that contain hundreds of string
|
2714
2675
|
// literal types. Skip this for constrained types.
|
2715
|
-
if (isClass(typeToAdd) && !
|
2676
|
+
if (isClass(typeToAdd) && !typeToAdd.props?.condition) {
|
2716
2677
|
const literalMaps = isClassInstance(typeToAdd)
|
2717
2678
|
? unionType.priv.literalInstances
|
2718
2679
|
: unionType.priv.literalClasses;
|
@@ -2772,9 +2733,9 @@ function _addTypeIfUnique(unionType, typeToAdd, elideRedundantLiterals) {
|
|
2772
2733
|
// If we're adding Literal[False] or Literal[True] to its
|
2773
2734
|
// opposite, combine them into a non-literal 'bool' type.
|
2774
2735
|
if (ClassType.isBuiltIn(type, 'bool') &&
|
2775
|
-
!
|
2736
|
+
!type.props?.condition &&
|
2776
2737
|
ClassType.isBuiltIn(typeToAdd, 'bool') &&
|
2777
|
-
!
|
2738
|
+
!typeToAdd.props?.condition) {
|
2778
2739
|
if (typeToAdd.priv.literalValue !== undefined &&
|
2779
2740
|
!typeToAdd.priv.literalValue === type.priv.literalValue) {
|
2780
2741
|
unionType.priv.subtypes[i] = ClassType.cloneWithLiteral(type, /* value */ undefined);
|