@zzzen/pyright-internal 1.2.0-dev.20241215 → 1.2.0-dev.20241229

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.
Files changed (283) hide show
  1. package/dist/analyzer/analysis.js +1 -1
  2. package/dist/analyzer/analysis.js.map +1 -1
  3. package/dist/analyzer/analyzerNodeInfo.js +17 -18
  4. package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
  5. package/dist/analyzer/backgroundAnalysisProgram.js +18 -35
  6. package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
  7. package/dist/analyzer/binder.js +38 -55
  8. package/dist/analyzer/binder.js.map +1 -1
  9. package/dist/analyzer/checker.js +146 -185
  10. package/dist/analyzer/checker.js.map +1 -1
  11. package/dist/analyzer/codeFlowEngine.js +24 -31
  12. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  13. package/dist/analyzer/constraintSolver.js +23 -24
  14. package/dist/analyzer/constraintSolver.js.map +1 -1
  15. package/dist/analyzer/constraintTracker.js +1 -2
  16. package/dist/analyzer/constraintTracker.js.map +1 -1
  17. package/dist/analyzer/constructorTransform.js +10 -12
  18. package/dist/analyzer/constructorTransform.js.map +1 -1
  19. package/dist/analyzer/constructors.js +14 -19
  20. package/dist/analyzer/constructors.js.map +1 -1
  21. package/dist/analyzer/dataClasses.js +27 -26
  22. package/dist/analyzer/dataClasses.js.map +1 -1
  23. package/dist/analyzer/declarationUtils.js +8 -11
  24. package/dist/analyzer/declarationUtils.js.map +1 -1
  25. package/dist/analyzer/decorators.js +2 -3
  26. package/dist/analyzer/decorators.js.map +1 -1
  27. package/dist/analyzer/docStringConversion.js +6 -8
  28. package/dist/analyzer/docStringConversion.js.map +1 -1
  29. package/dist/analyzer/enums.js +12 -13
  30. package/dist/analyzer/enums.js.map +1 -1
  31. package/dist/analyzer/functionTransform.js +1 -2
  32. package/dist/analyzer/functionTransform.js.map +1 -1
  33. package/dist/analyzer/importResolver.js +18 -27
  34. package/dist/analyzer/importResolver.js.map +1 -1
  35. package/dist/analyzer/importStatementUtils.js +4 -5
  36. package/dist/analyzer/importStatementUtils.js.map +1 -1
  37. package/dist/analyzer/namedTuples.js +6 -7
  38. package/dist/analyzer/namedTuples.js.map +1 -1
  39. package/dist/analyzer/operations.js +14 -17
  40. package/dist/analyzer/operations.js.map +1 -1
  41. package/dist/analyzer/packageTypeVerifier.js +35 -39
  42. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  43. package/dist/analyzer/parameterUtils.js +5 -7
  44. package/dist/analyzer/parameterUtils.js.map +1 -1
  45. package/dist/analyzer/parentDirectoryCache.js +8 -9
  46. package/dist/analyzer/parentDirectoryCache.js.map +1 -1
  47. package/dist/analyzer/parseTreeUtils.js +30 -44
  48. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  49. package/dist/analyzer/parseTreeWalker.js +2 -3
  50. package/dist/analyzer/parseTreeWalker.js.map +1 -1
  51. package/dist/analyzer/patternMatching.js +11 -20
  52. package/dist/analyzer/patternMatching.js.map +1 -1
  53. package/dist/analyzer/program.js +29 -40
  54. package/dist/analyzer/program.js.map +1 -1
  55. package/dist/analyzer/properties.js +7 -8
  56. package/dist/analyzer/properties.js.map +1 -1
  57. package/dist/analyzer/protocols.js +21 -23
  58. package/dist/analyzer/protocols.js.map +1 -1
  59. package/dist/analyzer/pythonPathUtils.js +1 -1
  60. package/dist/analyzer/pythonPathUtils.js.map +1 -1
  61. package/dist/analyzer/scope.js +10 -10
  62. package/dist/analyzer/scope.js.map +1 -1
  63. package/dist/analyzer/service.js +32 -47
  64. package/dist/analyzer/service.js.map +1 -1
  65. package/dist/analyzer/sourceFile.js +21 -26
  66. package/dist/analyzer/sourceFile.js.map +1 -1
  67. package/dist/analyzer/sourceFileInfo.js +2 -3
  68. package/dist/analyzer/sourceFileInfo.js.map +1 -1
  69. package/dist/analyzer/sourceFileInfoUtils.js +5 -5
  70. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
  71. package/dist/analyzer/sourceMapper.js +19 -30
  72. package/dist/analyzer/sourceMapper.js.map +1 -1
  73. package/dist/analyzer/testWalker.js +1 -2
  74. package/dist/analyzer/testWalker.js.map +1 -1
  75. package/dist/analyzer/tracePrinter.js +7 -9
  76. package/dist/analyzer/tracePrinter.js.map +1 -1
  77. package/dist/analyzer/tuples.js +11 -13
  78. package/dist/analyzer/tuples.js.map +1 -1
  79. package/dist/analyzer/typeCacheUtils.js +5 -6
  80. package/dist/analyzer/typeCacheUtils.js.map +1 -1
  81. package/dist/analyzer/typeDocStringUtils.js +7 -11
  82. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  83. package/dist/analyzer/typeEvaluator.js +628 -780
  84. package/dist/analyzer/typeEvaluator.js.map +1 -1
  85. package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -1
  86. package/dist/analyzer/typeEvaluatorWithTracker.js +2 -2
  87. package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
  88. package/dist/analyzer/typeGuards.js +26 -36
  89. package/dist/analyzer/typeGuards.js.map +1 -1
  90. package/dist/analyzer/typePrinter.js +15 -24
  91. package/dist/analyzer/typePrinter.js.map +1 -1
  92. package/dist/analyzer/typeStubWriter.js +1 -2
  93. package/dist/analyzer/typeStubWriter.js.map +1 -1
  94. package/dist/analyzer/typeUtils.js +65 -94
  95. package/dist/analyzer/typeUtils.js.map +1 -1
  96. package/dist/analyzer/typeWalker.js +4 -8
  97. package/dist/analyzer/typeWalker.js.map +1 -1
  98. package/dist/analyzer/typedDicts.js +39 -46
  99. package/dist/analyzer/typedDicts.js.map +1 -1
  100. package/dist/analyzer/types.js +64 -103
  101. package/dist/analyzer/types.js.map +1 -1
  102. package/dist/backgroundAnalysis.js +2 -3
  103. package/dist/backgroundAnalysis.js.map +1 -1
  104. package/dist/backgroundAnalysisBase.js +9 -10
  105. package/dist/backgroundAnalysisBase.js.map +1 -1
  106. package/dist/backgroundThreadBase.js +6 -7
  107. package/dist/backgroundThreadBase.js.map +1 -1
  108. package/dist/commands/createTypeStub.js +1 -1
  109. package/dist/commands/createTypeStub.js.map +1 -1
  110. package/dist/commands/dumpFileDebugInfoCommand.js +3 -3
  111. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  112. package/dist/commands/quickActionCommand.js +1 -1
  113. package/dist/commands/quickActionCommand.js.map +1 -1
  114. package/dist/common/asyncInitialization.js +1 -1
  115. package/dist/common/chokidarFileWatcherProvider.js +2 -4
  116. package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
  117. package/dist/common/configOptions.js +9 -9
  118. package/dist/common/configOptions.js.map +1 -1
  119. package/dist/common/console.js +1 -2
  120. package/dist/common/console.js.map +1 -1
  121. package/dist/common/core.js +2 -2
  122. package/dist/common/core.js.map +1 -1
  123. package/dist/common/crypto.js +1 -1
  124. package/dist/common/crypto.js.map +1 -1
  125. package/dist/common/diagnostic.js +3 -5
  126. package/dist/common/diagnostic.js.map +1 -1
  127. package/dist/common/envVarUtils.js +1 -1
  128. package/dist/common/envVarUtils.js.map +1 -1
  129. package/dist/common/extensibility.d.ts +1 -0
  130. package/dist/common/extensibility.js.map +1 -1
  131. package/dist/common/fileSystem.d.ts +1 -0
  132. package/dist/common/fileSystem.js.map +1 -1
  133. package/dist/common/fullAccessHost.js +5 -5
  134. package/dist/common/fullAccessHost.js.map +1 -1
  135. package/dist/common/host.js +1 -1
  136. package/dist/common/host.js.map +1 -1
  137. package/dist/common/logTracker.js +1 -1
  138. package/dist/common/logTracker.js.map +1 -1
  139. package/dist/common/lspUtils.js +1 -2
  140. package/dist/common/lspUtils.js.map +1 -1
  141. package/dist/common/progressReporter.js +1 -2
  142. package/dist/common/progressReporter.js.map +1 -1
  143. package/dist/common/realFileSystem.js +2 -3
  144. package/dist/common/realFileSystem.js.map +1 -1
  145. package/dist/common/serviceProvider.js +1 -1
  146. package/dist/common/serviceProvider.js.map +1 -1
  147. package/dist/common/textEditTracker.js +4 -6
  148. package/dist/common/textEditTracker.js.map +1 -1
  149. package/dist/common/tomlUtils.js +3 -1
  150. package/dist/common/tomlUtils.js.map +1 -1
  151. package/dist/common/uri/baseUri.js +1 -1
  152. package/dist/common/uri/baseUri.js.map +1 -1
  153. package/dist/common/uri/emptyUri.js +1 -1
  154. package/dist/common/uri/emptyUri.js.map +1 -1
  155. package/dist/common/uri/fileUri.js +2 -2
  156. package/dist/common/uri/fileUri.js.map +1 -1
  157. package/dist/common/uri/memoization.js +1 -1
  158. package/dist/common/uri/memoization.js.map +1 -1
  159. package/dist/common/uri/uri.js +2 -3
  160. package/dist/common/uri/uri.js.map +1 -1
  161. package/dist/common/uri/uriUtils.js +6 -8
  162. package/dist/common/uri/uriUtils.js.map +1 -1
  163. package/dist/common/uri/webUri.js +2 -2
  164. package/dist/common/uri/webUri.js.map +1 -1
  165. package/dist/common/workspaceEditUtils.js +10 -15
  166. package/dist/common/workspaceEditUtils.js.map +1 -1
  167. package/dist/languageServerBase.js +34 -42
  168. package/dist/languageServerBase.js.map +1 -1
  169. package/dist/languageService/analyzerServiceExecutor.js +8 -10
  170. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  171. package/dist/languageService/autoImporter.js +16 -19
  172. package/dist/languageService/autoImporter.js.map +1 -1
  173. package/dist/languageService/callHierarchyProvider.js +6 -11
  174. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  175. package/dist/languageService/completionProvider.js +81 -106
  176. package/dist/languageService/completionProvider.js.map +1 -1
  177. package/dist/languageService/completionProviderUtils.js +3 -3
  178. package/dist/languageService/completionProviderUtils.js.map +1 -1
  179. package/dist/languageService/definitionProvider.js +6 -9
  180. package/dist/languageService/definitionProvider.js.map +1 -1
  181. package/dist/languageService/documentSymbolCollector.js +32 -32
  182. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  183. package/dist/languageService/dynamicFeature.js +1 -2
  184. package/dist/languageService/dynamicFeature.js.map +1 -1
  185. package/dist/languageService/hoverProvider.js +17 -23
  186. package/dist/languageService/hoverProvider.js.map +1 -1
  187. package/dist/languageService/referencesProvider.js +4 -9
  188. package/dist/languageService/referencesProvider.js.map +1 -1
  189. package/dist/languageService/renameProvider.js +2 -4
  190. package/dist/languageService/renameProvider.js.map +1 -1
  191. package/dist/languageService/signatureHelpProvider.js +11 -15
  192. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  193. package/dist/languageService/tooltipUtils.js +15 -17
  194. package/dist/languageService/tooltipUtils.js.map +1 -1
  195. package/dist/localization/localize.js +3 -3
  196. package/dist/localization/localize.js.map +1 -1
  197. package/dist/localization/package.nls.cs.json +6 -0
  198. package/dist/localization/package.nls.de.json +6 -0
  199. package/dist/localization/package.nls.en-us.json +8 -8
  200. package/dist/localization/package.nls.es.json +6 -0
  201. package/dist/localization/package.nls.fr.json +7 -1
  202. package/dist/localization/package.nls.it.json +6 -0
  203. package/dist/localization/package.nls.ja.json +6 -0
  204. package/dist/localization/package.nls.ko.json +6 -0
  205. package/dist/localization/package.nls.pl.json +6 -0
  206. package/dist/localization/package.nls.pt-br.json +6 -0
  207. package/dist/localization/package.nls.qps-ploc.json +6 -0
  208. package/dist/localization/package.nls.ru.json +6 -0
  209. package/dist/localization/package.nls.tr.json +6 -0
  210. package/dist/localization/package.nls.zh-cn.json +6 -0
  211. package/dist/localization/package.nls.zh-tw.json +6 -0
  212. package/dist/parser/parser.js +30 -38
  213. package/dist/parser/parser.js.map +1 -1
  214. package/dist/parser/tokenizer.js +8 -13
  215. package/dist/parser/tokenizer.js.map +1 -1
  216. package/dist/pprof/profiler.js +3 -3
  217. package/dist/pprof/profiler.js.map +1 -1
  218. package/dist/pyright.js +5 -7
  219. package/dist/pyright.js.map +1 -1
  220. package/dist/pyrightFileSystem.js +4 -5
  221. package/dist/pyrightFileSystem.js.map +1 -1
  222. package/dist/readonlyAugmentedFileSystem.js +3 -5
  223. package/dist/readonlyAugmentedFileSystem.js.map +1 -1
  224. package/dist/server.js +1 -1
  225. package/dist/server.js.map +1 -1
  226. package/dist/tests/chainedSourceFiles.test.js +3 -3
  227. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  228. package/dist/tests/classDeclaration.test.js +7 -10
  229. package/dist/tests/classDeclaration.test.js.map +1 -1
  230. package/dist/tests/completions.test.js +3 -3
  231. package/dist/tests/completions.test.js.map +1 -1
  232. package/dist/tests/config.test.js +10 -17
  233. package/dist/tests/config.test.js.map +1 -1
  234. package/dist/tests/diagnosticOverrides.test.js +4 -6
  235. package/dist/tests/diagnosticOverrides.test.js.map +1 -1
  236. package/dist/tests/envVarUtils.test.js +9 -12
  237. package/dist/tests/envVarUtils.test.js.map +1 -1
  238. package/dist/tests/harness/fourslash/testLanguageService.js +1 -1
  239. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  240. package/dist/tests/harness/fourslash/testState.js +45 -60
  241. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  242. package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +6 -7
  243. package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
  244. package/dist/tests/harness/vfs/filesystem.js +3 -3
  245. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  246. package/dist/tests/importResolver.test.js +6 -7
  247. package/dist/tests/importResolver.test.js.map +1 -1
  248. package/dist/tests/importStatementUtils.test.js +2 -2
  249. package/dist/tests/importStatementUtils.test.js.map +1 -1
  250. package/dist/tests/ipythonMode.test.js +11 -12
  251. package/dist/tests/ipythonMode.test.js.map +1 -1
  252. package/dist/tests/languageServer.test.js +1 -2
  253. package/dist/tests/languageServer.test.js.map +1 -1
  254. package/dist/tests/lsp/languageServer.js +10 -14
  255. package/dist/tests/lsp/languageServer.js.map +1 -1
  256. package/dist/tests/lsp/languageServerTestUtils.js +10 -14
  257. package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
  258. package/dist/tests/parseTreeUtils.test.js +7 -7
  259. package/dist/tests/parseTreeUtils.test.js.map +1 -1
  260. package/dist/tests/parser.test.js +2 -2
  261. package/dist/tests/parser.test.js.map +1 -1
  262. package/dist/tests/service.test.js +2 -3
  263. package/dist/tests/service.test.js.map +1 -1
  264. package/dist/tests/sourceFile.test.js +2 -3
  265. package/dist/tests/sourceFile.test.js.map +1 -1
  266. package/dist/tests/sourceMapperUtils.test.js +3 -4
  267. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  268. package/dist/tests/testState.test.js +3 -6
  269. package/dist/tests/testState.test.js.map +1 -1
  270. package/dist/tests/testStateUtils.js +3 -4
  271. package/dist/tests/testStateUtils.js.map +1 -1
  272. package/dist/tests/textEditUtil.test.js +2 -2
  273. package/dist/tests/textEditUtil.test.js.map +1 -1
  274. package/dist/tests/typeEvaluator1.test.js +1 -1
  275. package/dist/tests/typeEvaluator4.test.js +4 -0
  276. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  277. package/dist/tests/typePrinter.test.js +1 -2
  278. package/dist/tests/typePrinter.test.js.map +1 -1
  279. package/dist/tests/workspaceEditUtils.test.js +3 -5
  280. package/dist/tests/workspaceEditUtils.test.js.map +1 -1
  281. package/dist/workspaceFactory.js +2 -3
  282. package/dist/workspaceFactory.js.map +1 -1
  283. package/package.json +1 -1
@@ -214,9 +214,8 @@ class UniqueSignatureTracker {
214
214
  });
215
215
  }
216
216
  addSignature(signature, offset) {
217
- var _a;
218
217
  // If this function is part of a broader overload, use the overload instead.
219
- const effectiveSignature = (0, types_1.isFunction)(signature) ? (_a = signature.priv.overloaded) !== null && _a !== void 0 ? _a : signature : signature;
218
+ const effectiveSignature = (0, types_1.isFunction)(signature) ? signature.priv.overloaded ?? signature : signature;
220
219
  const existingSignature = this.findSignature(effectiveSignature);
221
220
  if (existingSignature) {
222
221
  if (!existingSignature.expressionOffsets.some((o) => o === offset)) {
@@ -289,9 +288,8 @@ function makeInferenceContext(expectedType, isTypeIncomplete, returnTypeOverride
289
288
  // into a final type. It performs no memory allocations if the
290
289
  // transformed type is the same as the original.
291
290
  function mapSubtypes(type, callback, options) {
292
- var _a;
293
291
  if ((0, types_1.isUnion)(type)) {
294
- const subtypes = (options === null || options === void 0 ? void 0 : options.sortSubtypes) ? sortTypes(type.priv.subtypes) : type.priv.subtypes;
292
+ const subtypes = options?.sortSubtypes ? sortTypes(type.priv.subtypes) : type.priv.subtypes;
295
293
  for (let i = 0; i < subtypes.length; i++) {
296
294
  const subtype = subtypes[i];
297
295
  const transformedType = callback(subtype);
@@ -309,10 +307,10 @@ function mapSubtypes(type, callback, options) {
309
307
  accumulateSubtype(callback(subtypes[i]));
310
308
  }
311
309
  let newType = (0, types_1.combineTypes)(typesToCombine, {
312
- skipElideRedundantLiterals: options === null || options === void 0 ? void 0 : options.skipElideRedundantLiterals,
310
+ skipElideRedundantLiterals: options?.skipElideRedundantLiterals,
313
311
  });
314
- if (options === null || options === void 0 ? void 0 : options.retainTypeAlias) {
315
- if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) {
312
+ if (options?.retainTypeAlias) {
313
+ if (type.props?.typeAliasInfo) {
316
314
  newType = types_1.TypeBase.cloneForTypeAlias(newType, type.props.typeAliasInfo);
317
315
  }
318
316
  }
@@ -430,7 +428,6 @@ function sortTypes(types) {
430
428
  });
431
429
  }
432
430
  function compareTypes(a, b, recursionCount = 0) {
433
- var _a, _b;
434
431
  if (recursionCount > types_1.maxTypeRecursionCount) {
435
432
  return 0;
436
433
  }
@@ -464,7 +461,7 @@ function compareTypes(a, b, recursionCount = 0) {
464
461
  return typeComparison;
465
462
  }
466
463
  }
467
- const returnTypeComparison = compareTypes((_a = types_1.FunctionType.getEffectiveReturnType(a)) !== null && _a !== void 0 ? _a : types_1.UnknownType.create(), (_b = types_1.FunctionType.getEffectiveReturnType(bFunc)) !== null && _b !== void 0 ? _b : types_1.UnknownType.create());
464
+ const returnTypeComparison = compareTypes(types_1.FunctionType.getEffectiveReturnType(a) ?? types_1.UnknownType.create(), types_1.FunctionType.getEffectiveReturnType(bFunc) ?? types_1.UnknownType.create());
468
465
  if (returnTypeComparison !== 0) {
469
466
  return returnTypeComparison;
470
467
  }
@@ -658,7 +655,7 @@ function preserveUnknown(type1, type2) {
658
655
  function isUnionableType(subtypes) {
659
656
  // If all of the subtypes are TypeForm types, we know that they
660
657
  // are unionable.
661
- if (subtypes.every((t) => { var _a; return ((_a = t.props) === null || _a === void 0 ? void 0 : _a.typeForm) !== undefined; })) {
658
+ if (subtypes.every((t) => t.props?.typeForm !== undefined)) {
662
659
  return true;
663
660
  }
664
661
  let typeFlags = 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */;
@@ -691,8 +688,7 @@ function derivesFromAnyOrUnknown(type) {
691
688
  return anyOrUnknown;
692
689
  }
693
690
  function getFullNameOfType(type) {
694
- var _a, _b;
695
- if ((_b = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) === null || _b === void 0 ? void 0 : _b.shared.fullName) {
691
+ if (type.props?.typeAliasInfo?.shared.fullName) {
696
692
  return type.props.typeAliasInfo.shared.fullName;
697
693
  }
698
694
  switch (type.category) {
@@ -719,17 +715,16 @@ function getFullNameOfType(type) {
719
715
  return undefined;
720
716
  }
721
717
  function addConditionToType(type, condition, options) {
722
- var _a, _b;
723
718
  if (!condition) {
724
719
  return type;
725
720
  }
726
- if (options === null || options === void 0 ? void 0 : options.skipSelfCondition) {
721
+ if (options?.skipSelfCondition) {
727
722
  condition = condition.filter((c) => !types_1.TypeVarType.isSelf(c.typeVar));
728
723
  if (condition.length === 0) {
729
724
  return type;
730
725
  }
731
726
  }
732
- if (options === null || options === void 0 ? void 0 : options.skipBoundTypeVars) {
727
+ if (options?.skipBoundTypeVars) {
733
728
  condition = condition.filter((c) => c.typeVar.shared.constraints.length > 0);
734
729
  if (condition.length === 0) {
735
730
  return type;
@@ -744,17 +739,16 @@ function addConditionToType(type, condition, options) {
744
739
  case 9 /* TypeCategory.TypeVar */:
745
740
  return type;
746
741
  case 4 /* TypeCategory.Function */:
747
- return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition, condition));
742
+ return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine(type.props?.condition, condition));
748
743
  case 5 /* TypeCategory.Overloaded */:
749
744
  return types_1.OverloadedType.create(types_1.OverloadedType.getOverloads(type).map((t) => addConditionToType(t, condition)));
750
745
  case 6 /* TypeCategory.Class */:
751
- return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine((_b = type.props) === null || _b === void 0 ? void 0 : _b.condition, condition));
746
+ return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine(type.props?.condition, condition));
752
747
  case 8 /* TypeCategory.Union */:
753
748
  return (0, types_1.combineTypes)(type.priv.subtypes.map((t) => addConditionToType(t, condition)));
754
749
  }
755
750
  }
756
751
  function getTypeCondition(type) {
757
- var _a;
758
752
  switch (type.category) {
759
753
  case 0 /* TypeCategory.Unbound */:
760
754
  case 1 /* TypeCategory.Unknown */:
@@ -767,7 +761,7 @@ function getTypeCondition(type) {
767
761
  return undefined;
768
762
  case 6 /* TypeCategory.Class */:
769
763
  case 4 /* TypeCategory.Function */:
770
- return (_a = type.props) === null || _a === void 0 ? void 0 : _a.condition;
764
+ return type.props?.condition;
771
765
  }
772
766
  }
773
767
  // Indicates whether the specified type is a recursive type alias
@@ -779,7 +773,6 @@ function isTypeAliasPlaceholder(type) {
779
773
  // within the specified type. It's OK if it's used indirectly as
780
774
  // a type argument.
781
775
  function isTypeAliasRecursive(typeAliasPlaceholder, type) {
782
- var _a, _b;
783
776
  if (type.category !== 8 /* TypeCategory.Union */) {
784
777
  if (type === typeAliasPlaceholder) {
785
778
  return true;
@@ -787,25 +780,24 @@ function isTypeAliasRecursive(typeAliasPlaceholder, type) {
787
780
  // Handle the specific case where the type alias directly refers to itself.
788
781
  // In this case, the type will be unbound because it could not be resolved.
789
782
  return ((0, types_1.isUnbound)(type) &&
790
- ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) &&
791
- type.props.typeAliasInfo.shared.name === ((_b = typeAliasPlaceholder.shared.recursiveAlias) === null || _b === void 0 ? void 0 : _b.name));
783
+ type.props?.typeAliasInfo &&
784
+ type.props.typeAliasInfo.shared.name === typeAliasPlaceholder.shared.recursiveAlias?.name);
792
785
  }
793
786
  return ((0, types_1.findSubtype)(type, (subtype) => (0, types_1.isTypeVar)(subtype) && subtype.shared === typeAliasPlaceholder.shared) !==
794
787
  undefined);
795
788
  }
796
789
  function transformPossibleRecursiveTypeAlias(type, recursionCount = 0) {
797
- var _a, _b;
798
790
  if (recursionCount >= types_1.maxTypeRecursionCount) {
799
791
  return type;
800
792
  }
801
793
  recursionCount++;
802
794
  if (type) {
803
- const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
804
- if ((0, types_1.isTypeVar)(type) && ((_b = type.shared.recursiveAlias) === null || _b === void 0 ? void 0 : _b.name) && type.shared.boundType) {
795
+ const aliasInfo = type.props?.typeAliasInfo;
796
+ if ((0, types_1.isTypeVar)(type) && type.shared.recursiveAlias?.name && type.shared.boundType) {
805
797
  const unspecializedType = types_1.TypeBase.isInstance(type)
806
798
  ? convertToInstance(type.shared.boundType)
807
799
  : type.shared.boundType;
808
- if (!(aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs) || !type.shared.recursiveAlias.typeParams) {
800
+ if (!aliasInfo?.typeArgs || !type.shared.recursiveAlias.typeParams) {
809
801
  return transformPossibleRecursiveTypeAlias(unspecializedType, recursionCount);
810
802
  }
811
803
  const solution = buildSolution(type.shared.recursiveAlias.typeParams, aliasInfo.typeArgs);
@@ -895,14 +887,14 @@ function selfSpecializeClass(type, options) {
895
887
  if (type.shared.typeParams.length === 0) {
896
888
  return type;
897
889
  }
898
- if (type.priv.typeArgs && !(options === null || options === void 0 ? void 0 : options.overrideTypeArgs)) {
890
+ if (type.priv.typeArgs && !options?.overrideTypeArgs) {
899
891
  return type;
900
892
  }
901
893
  const typeParams = type.shared.typeParams.map((typeParam) => {
902
894
  if ((0, types_1.isTypeVarTuple)(typeParam)) {
903
895
  typeParam = types_1.TypeVarType.cloneForUnpacked(typeParam);
904
896
  }
905
- return (options === null || options === void 0 ? void 0 : options.useBoundTypeVars) ? types_1.TypeVarType.cloneAsBound(typeParam) : typeParam;
897
+ return options?.useBoundTypeVars ? types_1.TypeVarType.cloneAsBound(typeParam) : typeParam;
906
898
  });
907
899
  return types_1.ClassType.specialize(type, typeParams);
908
900
  }
@@ -1014,19 +1006,17 @@ function getLiteralTypeClassName(type) {
1014
1006
  return undefined;
1015
1007
  }
1016
1008
  function stripTypeForm(type) {
1017
- var _a;
1018
- if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeForm) {
1009
+ if (type.props?.typeForm) {
1019
1010
  return types_1.TypeBase.cloneWithTypeForm(type, undefined);
1020
1011
  }
1021
1012
  return type;
1022
1013
  }
1023
1014
  function stripTypeFormRecursive(type, recursionCount = 0) {
1024
- var _a;
1025
1015
  if (recursionCount > types_1.maxTypeRecursionCount) {
1026
1016
  return type;
1027
1017
  }
1028
1018
  recursionCount++;
1029
- if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeForm) {
1019
+ if (type.props?.typeForm) {
1030
1020
  type = types_1.TypeBase.cloneWithTypeForm(type, undefined);
1031
1021
  }
1032
1022
  return mapSubtypes(type, (subtype) => stripTypeFormRecursive(subtype, recursionCount));
@@ -1098,8 +1088,7 @@ function isTupleClass(type) {
1098
1088
  // the form tuple[x, ...] where the number of elements
1099
1089
  // in the tuple is unknown.
1100
1090
  function isUnboundedTupleClass(type) {
1101
- var _a;
1102
- return (_a = type.priv.tupleTypeArgs) === null || _a === void 0 ? void 0 : _a.some((t) => t.isUnbounded || (0, types_1.isUnpackedTypeVarTuple)(t.type) || (0, types_1.isUnpackedTypeVar)(t.type));
1091
+ return type.priv.tupleTypeArgs?.some((t) => t.isUnbounded || (0, types_1.isUnpackedTypeVarTuple)(t.type) || (0, types_1.isUnpackedTypeVar)(t.type));
1103
1092
  }
1104
1093
  // Indicates whether the specified index is within range and its type is unambiguous
1105
1094
  // in that it doesn't involve any element ranges that are of indeterminate length.
@@ -1303,14 +1292,13 @@ function lookUpObjectMember(objectType, memberName, flags = 0 /* MemberAccessFla
1303
1292
  // Looks up a member in a class using the multiple-inheritance rules
1304
1293
  // defined by Python.
1305
1294
  function lookUpClassMember(classType, memberName, flags = 0 /* MemberAccessFlags.Default */, skipMroClass) {
1306
- var _a, _b;
1307
1295
  // Look in the metaclass first.
1308
1296
  const metaclass = classType.shared.effectiveMetaclass;
1309
1297
  // Skip the "type" class as an optimization because it is known to not
1310
1298
  // define any instance variables, and it's by far the most common metaclass.
1311
1299
  if (metaclass && (0, types_1.isClass)(metaclass) && !types_1.ClassType.isBuiltIn(metaclass, 'type')) {
1312
1300
  const metaMemberItr = getClassMemberIterator(metaclass, memberName, 32 /* MemberAccessFlags.SkipClassMembers */);
1313
- const metaMember = (_a = metaMemberItr.next()) === null || _a === void 0 ? void 0 : _a.value;
1301
+ const metaMember = metaMemberItr.next()?.value;
1314
1302
  // If the metaclass defines the member and we didn't hit an Unknown
1315
1303
  // class in the metaclass MRO, use the metaclass member.
1316
1304
  if (metaMember && !(0, types_1.isAnyOrUnknown)(metaMember.classType)) {
@@ -1321,7 +1309,7 @@ function lookUpClassMember(classType, memberName, flags = 0 /* MemberAccessFlags
1321
1309
  }
1322
1310
  }
1323
1311
  const memberItr = getClassMemberIterator(classType, memberName, flags, skipMroClass);
1324
- return (_b = memberItr.next()) === null || _b === void 0 ? void 0 : _b.value;
1312
+ return memberItr.next()?.value;
1325
1313
  }
1326
1314
  // Iterates members in a class matching memberName using the multiple-inheritance rules.
1327
1315
  // For more details, see this note on method resolution
@@ -1471,13 +1459,12 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* MemberAcces
1471
1459
  // Checks for whether the member is effectively read only because it
1472
1460
  // belongs to a frozen dataclass or a named tuple.
1473
1461
  function isMemberReadOnly(classType, name) {
1474
- var _a;
1475
1462
  if (types_1.ClassType.hasNamedTupleEntry(classType, name)) {
1476
1463
  return true;
1477
1464
  }
1478
1465
  if (types_1.ClassType.isDataClassFrozen(classType)) {
1479
- const dcEntries = (_a = classType.shared) === null || _a === void 0 ? void 0 : _a.dataClassEntries;
1480
- if (dcEntries === null || dcEntries === void 0 ? void 0 : dcEntries.some((entry) => entry.name === name)) {
1466
+ const dcEntries = classType.shared?.dataClassEntries;
1467
+ if (dcEntries?.some((entry) => entry.name === name)) {
1481
1468
  return true;
1482
1469
  }
1483
1470
  }
@@ -1575,16 +1562,15 @@ function addTypeVarsToListIfUnique(list1, list2, typeVarScopeId) {
1575
1562
  // Union[List[Dict[_T1, _T2]], _T1, _T3], the result would be
1576
1563
  // [_T1, _T2, _T3].
1577
1564
  function getTypeVarArgsRecursive(type, recursionCount = 0) {
1578
- var _a;
1579
1565
  if (recursionCount > types_1.maxTypeRecursionCount) {
1580
1566
  return [];
1581
1567
  }
1582
1568
  recursionCount++;
1583
- const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
1569
+ const aliasInfo = type.props?.typeAliasInfo;
1584
1570
  if (aliasInfo) {
1585
1571
  const combinedList = [];
1586
1572
  if (aliasInfo.typeArgs) {
1587
- aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs.forEach((typeArg) => {
1573
+ aliasInfo?.typeArgs.forEach((typeArg) => {
1588
1574
  addTypeVarsToListIfUnique(combinedList, getTypeVarArgsRecursive(typeArg, recursionCount));
1589
1575
  });
1590
1576
  return combinedList;
@@ -1719,9 +1705,8 @@ function derivesFromClassRecursive(classType, baseClassToFind, ignoreUnknown) {
1719
1705
  return false;
1720
1706
  }
1721
1707
  function synthesizeTypeVarForSelfCls(classType, isClsParam) {
1722
- var _a;
1723
1708
  const selfType = types_1.TypeVarType.createInstance(`__type_of_self__`);
1724
- const scopeId = (_a = getTypeVarScopeId(classType)) !== null && _a !== void 0 ? _a : '';
1709
+ const scopeId = getTypeVarScopeId(classType) ?? '';
1725
1710
  selfType.shared.isSynthesized = true;
1726
1711
  selfType.shared.isSynthesizedSelf = true;
1727
1712
  selfType.priv.scopeId = scopeId;
@@ -1790,7 +1775,7 @@ function isEffectivelyInstantiable(type, options, recursionCount = 0) {
1790
1775
  if (types_1.TypeBase.isInstantiable(type)) {
1791
1776
  return true;
1792
1777
  }
1793
- if ((options === null || options === void 0 ? void 0 : options.honorTypeVarBounds) && (0, types_1.isTypeVar)(type) && type.shared.boundType) {
1778
+ if (options?.honorTypeVarBounds && (0, types_1.isTypeVar)(type) && type.shared.boundType) {
1794
1779
  if (isEffectivelyInstantiable(type.shared.boundType, options, recursionCount)) {
1795
1780
  return true;
1796
1781
  }
@@ -1806,9 +1791,8 @@ function isEffectivelyInstantiable(type, options, recursionCount = 0) {
1806
1791
  return false;
1807
1792
  }
1808
1793
  function convertToInstance(type, includeSubclasses = true) {
1809
- var _a, _b;
1810
1794
  // See if we've already performed this conversion and cached it.
1811
- if (((_a = type.cached) === null || _a === void 0 ? void 0 : _a.instanceType) && includeSubclasses) {
1795
+ if (type.cached?.instanceType && includeSubclasses) {
1812
1796
  return type.cached.instanceType;
1813
1797
  }
1814
1798
  let result = mapSubtypes(type, (subtype) => {
@@ -1864,7 +1848,7 @@ function convertToInstance(type, includeSubclasses = true) {
1864
1848
  skipElideRedundantLiterals: true,
1865
1849
  });
1866
1850
  // Copy over any type alias information.
1867
- const aliasInfo = (_b = type.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo;
1851
+ const aliasInfo = type.props?.typeAliasInfo;
1868
1852
  if (aliasInfo && type !== result) {
1869
1853
  result = types_1.TypeBase.cloneForTypeAlias(result, aliasInfo);
1870
1854
  }
@@ -1878,9 +1862,8 @@ function convertToInstance(type, includeSubclasses = true) {
1878
1862
  return result;
1879
1863
  }
1880
1864
  function convertToInstantiable(type, includeSubclasses = true) {
1881
- var _a;
1882
1865
  // See if we've already performed this conversion and cached it.
1883
- if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.instantiableType) {
1866
+ if (type.cached?.instantiableType) {
1884
1867
  return type.cached.instantiableType;
1885
1868
  }
1886
1869
  const result = mapSubtypes(type, (subtype) => {
@@ -2036,7 +2019,6 @@ function containsAnyOrUnknown(type, recurse) {
2036
2019
  // and allocating a memory walker object for every call significantly increases
2037
2020
  // peak memory usage.
2038
2021
  function isPartlyUnknown(type, recursionCount = 0) {
2039
- var _a, _b;
2040
2022
  if (recursionCount > types_1.maxTypeRecursionCount) {
2041
2023
  return false;
2042
2024
  }
@@ -2046,8 +2028,8 @@ function isPartlyUnknown(type, recursionCount = 0) {
2046
2028
  }
2047
2029
  // If this is a generic type alias, see if any of its type arguments
2048
2030
  // are either unspecified or are partially known.
2049
- const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
2050
- if (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs) {
2031
+ const aliasInfo = type.props?.typeAliasInfo;
2032
+ if (aliasInfo?.typeArgs) {
2051
2033
  if (aliasInfo.typeArgs.some((typeArg) => isPartlyUnknown(typeArg, recursionCount))) {
2052
2034
  return true;
2053
2035
  }
@@ -2065,7 +2047,7 @@ function isPartlyUnknown(type, recursionCount = 0) {
2065
2047
  return false;
2066
2048
  }
2067
2049
  if (!types_1.ClassType.isPseudoGenericClass(type)) {
2068
- const typeArgs = ((_b = type.priv.tupleTypeArgs) === null || _b === void 0 ? void 0 : _b.map((t) => t.type)) || type.priv.typeArgs;
2050
+ const typeArgs = type.priv.tupleTypeArgs?.map((t) => t.type) || type.priv.typeArgs;
2069
2051
  if (typeArgs) {
2070
2052
  for (const argType of typeArgs) {
2071
2053
  if (isPartlyUnknown(argType, recursionCount)) {
@@ -2229,7 +2211,6 @@ function makeUnpacked(type) {
2229
2211
  // If the declared return type for the function is a Generator or AsyncGenerator,
2230
2212
  // returns the type arguments for the type.
2231
2213
  function getGeneratorTypeArgs(returnType) {
2232
- var _a;
2233
2214
  if ((0, types_1.isClassInstance)(returnType)) {
2234
2215
  if (types_1.ClassType.isBuiltIn(returnType, ['Generator', 'AsyncGenerator'])) {
2235
2216
  return returnType.priv.typeArgs;
@@ -2237,7 +2218,7 @@ function getGeneratorTypeArgs(returnType) {
2237
2218
  else if (types_1.ClassType.isBuiltIn(returnType, 'AwaitableGenerator')) {
2238
2219
  // AwaitableGenerator has four type arguments, and the first 3
2239
2220
  // correspond to the generator.
2240
- return (_a = returnType.priv.typeArgs) === null || _a === void 0 ? void 0 : _a.slice(0, 3);
2221
+ return returnType.priv.typeArgs?.slice(0, 3);
2241
2222
  }
2242
2223
  }
2243
2224
  return undefined;
@@ -2280,14 +2261,13 @@ function requiresTypeArgs(classType) {
2280
2261
  return false;
2281
2262
  }
2282
2263
  function requiresSpecialization(type, options, recursionCount = 0) {
2283
- var _a;
2284
2264
  if (recursionCount > types_1.maxTypeRecursionCount) {
2285
2265
  return false;
2286
2266
  }
2287
2267
  recursionCount++;
2288
2268
  // Is the answer cached?
2289
- const canUseCache = !(options === null || options === void 0 ? void 0 : options.ignorePseudoGeneric) && !(options === null || options === void 0 ? void 0 : options.ignoreSelf);
2290
- if (canUseCache && ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.requiresSpecialization) !== undefined) {
2269
+ const canUseCache = !options?.ignorePseudoGeneric && !options?.ignoreSelf;
2270
+ if (canUseCache && type.cached?.requiresSpecialization !== undefined) {
2291
2271
  return type.cached.requiresSpecialization;
2292
2272
  }
2293
2273
  const result = _requiresSpecialization(type, options, recursionCount);
@@ -2300,17 +2280,16 @@ function requiresSpecialization(type, options, recursionCount = 0) {
2300
2280
  return result;
2301
2281
  }
2302
2282
  function _requiresSpecialization(type, options, recursionCount = 0) {
2303
- var _a, _b;
2304
2283
  // If the type is conditioned on a TypeVar, it may need to be specialized.
2305
- if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition) {
2284
+ if (type.props?.condition) {
2306
2285
  return true;
2307
2286
  }
2308
2287
  switch (type.category) {
2309
2288
  case 6 /* TypeCategory.Class */: {
2310
- if (types_1.ClassType.isPseudoGenericClass(type) && (options === null || options === void 0 ? void 0 : options.ignorePseudoGeneric)) {
2289
+ if (types_1.ClassType.isPseudoGenericClass(type) && options?.ignorePseudoGeneric) {
2311
2290
  return false;
2312
2291
  }
2313
- if (!type.priv.isTypeArgExplicit && (options === null || options === void 0 ? void 0 : options.ignoreImplicitTypeArgs)) {
2292
+ if (!type.priv.isTypeArgExplicit && options?.ignoreImplicitTypeArgs) {
2314
2293
  return false;
2315
2294
  }
2316
2295
  if (type.priv.tupleTypeArgs) {
@@ -2361,15 +2340,15 @@ function _requiresSpecialization(type, options, recursionCount = 0) {
2361
2340
  case 9 /* TypeCategory.TypeVar */: {
2362
2341
  // Most TypeVar types need to be specialized.
2363
2342
  if (!type.shared.recursiveAlias) {
2364
- if (types_1.TypeVarType.isSelf(type) && (options === null || options === void 0 ? void 0 : options.ignoreSelf)) {
2343
+ if (types_1.TypeVarType.isSelf(type) && options?.ignoreSelf) {
2365
2344
  return false;
2366
2345
  }
2367
2346
  return true;
2368
2347
  }
2369
2348
  // If this is a recursive type alias, it may need to be specialized
2370
2349
  // if it has generic type arguments.
2371
- const aliasInfo = (_b = type.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo;
2372
- if (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs) {
2350
+ const aliasInfo = type.props?.typeAliasInfo;
2351
+ if (aliasInfo?.typeArgs) {
2373
2352
  return aliasInfo.typeArgs.some((typeArg) => requiresSpecialization(typeArg, options, recursionCount));
2374
2353
  }
2375
2354
  }
@@ -2441,7 +2420,7 @@ function isVarianceOfTypeArgCompatible(type, typeParamVariance) {
2441
2420
  effectiveVariance = 3 /* Variance.Covariant */;
2442
2421
  }
2443
2422
  }
2444
- return isVarianceOfTypeArgCompatible(typeArgType !== null && typeArgType !== void 0 ? typeArgType : types_1.UnknownType.create(), effectiveVariance);
2423
+ return isVarianceOfTypeArgCompatible(typeArgType ?? types_1.UnknownType.create(), effectiveVariance);
2445
2424
  });
2446
2425
  }
2447
2426
  }
@@ -2683,7 +2662,6 @@ class TypeVarTransformer {
2683
2662
  return this._pendingTypeVarTransformations;
2684
2663
  }
2685
2664
  apply(type, recursionCount) {
2686
- var _a, _b, _c;
2687
2665
  if (recursionCount > types_1.maxTypeRecursionCount) {
2688
2666
  return type;
2689
2667
  }
@@ -2691,7 +2669,7 @@ class TypeVarTransformer {
2691
2669
  type = this.transformGenericTypeAlias(type, recursionCount);
2692
2670
  // If the type is conditioned on a type variable, see if the condition
2693
2671
  // still applies.
2694
- if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition) {
2672
+ if (type.props?.condition) {
2695
2673
  type = this.transformConditionalType(type, recursionCount);
2696
2674
  }
2697
2675
  // Shortcut the operation if possible.
@@ -2708,9 +2686,9 @@ class TypeVarTransformer {
2708
2686
  // Handle recursive type aliases specially. In particular,
2709
2687
  // we need to specialize type arguments for generic recursive
2710
2688
  // type aliases.
2711
- const aliasInfo = (_b = type.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo;
2689
+ const aliasInfo = type.props?.typeAliasInfo;
2712
2690
  if (type.shared.recursiveAlias) {
2713
- if (!(aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs)) {
2691
+ if (!aliasInfo?.typeArgs) {
2714
2692
  return type;
2715
2693
  }
2716
2694
  let requiresUpdate = false;
@@ -2738,7 +2716,7 @@ class TypeVarTransformer {
2738
2716
  paramSpecAccess = type.priv.paramSpecAccess;
2739
2717
  type = types_1.TypeVarType.cloneForParamSpecAccess(type, /* access */ undefined);
2740
2718
  }
2741
- replacementType = (_c = this.transformTypeVar(type, recursionCount)) !== null && _c !== void 0 ? _c : type;
2719
+ replacementType = this.transformTypeVar(type, recursionCount) ?? type;
2742
2720
  if ((0, types_1.isParamSpec)(type) && replacementType !== type) {
2743
2721
  replacementType = simplifyFunctionToParamSpec(convertTypeToParamSpecValue(replacementType));
2744
2722
  }
@@ -2851,8 +2829,7 @@ class TypeVarTransformer {
2851
2829
  return callback();
2852
2830
  }
2853
2831
  transformGenericTypeAlias(type, recursionCount) {
2854
- var _a;
2855
- const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
2832
+ const aliasInfo = type.props?.typeAliasInfo;
2856
2833
  if (!aliasInfo || !aliasInfo.shared.typeParams || !aliasInfo.typeArgs) {
2857
2834
  return type;
2858
2835
  }
@@ -2871,7 +2848,6 @@ class TypeVarTransformer {
2871
2848
  return type;
2872
2849
  }
2873
2850
  transformTypeVarsInClassType(classType, recursionCount) {
2874
- var _a;
2875
2851
  const typeParams = types_1.ClassType.getTypeParams(classType);
2876
2852
  // Handle the common case where the class has no type parameters.
2877
2853
  if (typeParams.length === 0 &&
@@ -2941,7 +2917,7 @@ class TypeVarTransformer {
2941
2917
  }
2942
2918
  }
2943
2919
  if (!newTypeArgs) {
2944
- const typeArgs = (_a = classType.priv.typeArgs) !== null && _a !== void 0 ? _a : typeParams;
2920
+ const typeArgs = classType.priv.typeArgs ?? typeParams;
2945
2921
  if (!classType.priv.typeArgs) {
2946
2922
  isTypeArgExplicit = false;
2947
2923
  }
@@ -3227,8 +3203,7 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3227
3203
  this._isSolvingDefaultType = false;
3228
3204
  }
3229
3205
  transformTypeVar(typeVar, recursionCount) {
3230
- var _a, _b, _c;
3231
- const solutionSet = this._solution.getSolutionSet((_a = this._activeConstraintSetIndex) !== null && _a !== void 0 ? _a : 0);
3206
+ const solutionSet = this._solution.getSolutionSet(this._activeConstraintSetIndex ?? 0);
3232
3207
  // If we're solving a default type, handle type variables with no scope ID.
3233
3208
  if (this._isSolvingDefaultType && !typeVar.priv.scopeId) {
3234
3209
  const replacement = this._getReplacementForDefaultByName(typeVar, solutionSet);
@@ -3312,22 +3287,21 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3312
3287
  return undefined;
3313
3288
  }
3314
3289
  // Use the default value if there is one.
3315
- if (typeVar.shared.isDefaultExplicit && !((_b = this._options.replaceUnsolved) === null || _b === void 0 ? void 0 : _b.useUnknown)) {
3290
+ if (typeVar.shared.isDefaultExplicit && !this._options.replaceUnsolved?.useUnknown) {
3316
3291
  return this._solveDefaultType(typeVar, recursionCount);
3317
3292
  }
3318
- return getUnknownForTypeVar(typeVar, (_c = this._options.replaceUnsolved) === null || _c === void 0 ? void 0 : _c.tupleClassType);
3293
+ return getUnknownForTypeVar(typeVar, this._options.replaceUnsolved?.tupleClassType);
3319
3294
  }
3320
3295
  transformUnionSubtype(preTransform, postTransform) {
3321
- var _a, _b, _c;
3322
3296
  // If a union contains unsolved TypeVars within scope, eliminate them
3323
3297
  // unless this results in an empty union. This elimination is needed
3324
3298
  // in cases where TypeVars can go unsolved due to unions in parameter
3325
3299
  // annotations, like this:
3326
3300
  // def test(x: Union[str, T]) -> Union[str, T]
3327
- if (!((_a = this._options.replaceUnsolved) === null || _a === void 0 ? void 0 : _a.eliminateUnsolvedInUnions)) {
3301
+ if (!this._options.replaceUnsolved?.eliminateUnsolvedInUnions) {
3328
3302
  return postTransform;
3329
3303
  }
3330
- const solutionSet = this._solution.getSolutionSet((_b = this._activeConstraintSetIndex) !== null && _b !== void 0 ? _b : 0);
3304
+ const solutionSet = this._solution.getSolutionSet(this._activeConstraintSetIndex ?? 0);
3331
3305
  if ((0, types_1.isTypeVar)(preTransform)) {
3332
3306
  if (!this._shouldReplaceTypeVar(preTransform) || !this._shouldReplaceUnsolvedTypeVar(preTransform)) {
3333
3307
  return postTransform;
@@ -3350,7 +3324,7 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3350
3324
  return undefined;
3351
3325
  }
3352
3326
  }
3353
- else if ((_c = preTransform.props) === null || _c === void 0 ? void 0 : _c.condition) {
3327
+ else if (preTransform.props?.condition) {
3354
3328
  // If this is a type that is conditioned on a unification TypeVar,
3355
3329
  // see if TypeVar was solved. If not, eliminate the type.
3356
3330
  for (const condition of preTransform.props.condition) {
@@ -3362,7 +3336,6 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3362
3336
  return postTransform;
3363
3337
  }
3364
3338
  transformTupleTypeVar(typeVar) {
3365
- var _a;
3366
3339
  if (!this._shouldReplaceTypeVar(typeVar)) {
3367
3340
  const defaultType = typeVar.shared.defaultType;
3368
3341
  if (typeVar.shared.isDefaultExplicit && (0, types_1.isClassInstance)(defaultType) && defaultType.priv.tupleTypeArgs) {
@@ -3370,7 +3343,7 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3370
3343
  }
3371
3344
  return undefined;
3372
3345
  }
3373
- const solutionSet = this._solution.getSolutionSet((_a = this._activeConstraintSetIndex) !== null && _a !== void 0 ? _a : 0);
3346
+ const solutionSet = this._solution.getSolutionSet(this._activeConstraintSetIndex ?? 0);
3374
3347
  const value = solutionSet.getType(typeVar);
3375
3348
  if (value && (0, types_1.isClassInstance)(value) && value.priv.tupleTypeArgs && (0, types_1.isUnpackedClass)(value)) {
3376
3349
  return value.priv.tupleTypeArgs;
@@ -3378,17 +3351,16 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3378
3351
  return undefined;
3379
3352
  }
3380
3353
  transformConditionalType(type, recursionCount) {
3381
- var _a, _b, _c, _d;
3382
- if (!((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition)) {
3354
+ if (!type.props?.condition) {
3383
3355
  return type;
3384
3356
  }
3385
- const solutionSet = this._solution.getSolutionSet((_b = this._activeConstraintSetIndex) !== null && _b !== void 0 ? _b : 0);
3357
+ const solutionSet = this._solution.getSolutionSet(this._activeConstraintSetIndex ?? 0);
3386
3358
  for (const condition of type.props.condition) {
3387
3359
  // This doesn't apply to bound type variables.
3388
3360
  if (!types_1.TypeVarType.hasConstraints(condition.typeVar)) {
3389
3361
  continue;
3390
3362
  }
3391
- const conditionTypeVar = (_d = (_c = condition.typeVar.priv) === null || _c === void 0 ? void 0 : _c.freeTypeVar) !== null && _d !== void 0 ? _d : condition.typeVar;
3363
+ const conditionTypeVar = condition.typeVar.priv?.freeTypeVar ?? condition.typeVar;
3392
3364
  const replacement = solutionSet.getType(conditionTypeVar);
3393
3365
  if (!replacement || condition.constraintIndex >= conditionTypeVar.shared.constraints.length) {
3394
3366
  continue;
@@ -3456,7 +3428,6 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3456
3428
  return true;
3457
3429
  }
3458
3430
  _shouldReplaceUnsolvedTypeVar(typeVar) {
3459
- var _a;
3460
3431
  // Never replace nested TypeVars with unknown.
3461
3432
  if (this.pendingTypeVarTransformations.size > 0) {
3462
3433
  return false;
@@ -3470,7 +3441,7 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3470
3441
  if (!this._options.replaceUnsolved.scopeIds.includes(typeVar.priv.scopeId)) {
3471
3442
  return false;
3472
3443
  }
3473
- const exemptTypeVars = (_a = this._options.replaceUnsolved) === null || _a === void 0 ? void 0 : _a.unsolvedExemptTypeVars;
3444
+ const exemptTypeVars = this._options.replaceUnsolved?.unsolvedExemptTypeVars;
3474
3445
  if (exemptTypeVars) {
3475
3446
  if (exemptTypeVars.some((t) => (0, types_1.isTypeSame)(t, typeVar, { ignoreTypeFlags: true }))) {
3476
3447
  return false;
@@ -3500,7 +3471,7 @@ class UnificationTypeTransformer extends TypeVarTransformer {
3500
3471
  return undefined;
3501
3472
  }
3502
3473
  _isTypeVarLive(typeVar) {
3503
- return this._liveTypeVarScopes.some((scopeId) => { var _a; return typeVar.priv.scopeId === scopeId || ((_a = typeVar.priv.freeTypeVar) === null || _a === void 0 ? void 0 : _a.priv.scopeId) === scopeId; });
3474
+ return this._liveTypeVarScopes.some((scopeId) => typeVar.priv.scopeId === scopeId || typeVar.priv.freeTypeVar?.priv.scopeId === scopeId);
3504
3475
  }
3505
3476
  }
3506
3477
  //# sourceMappingURL=typeUtils.js.map