typescript 5.5.0-dev.20240522 → 5.5.0-dev.20240524

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/typescript.js CHANGED
@@ -112,6 +112,7 @@ __export(typescript_exports, {
112
112
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
113
113
  ListFormat: () => ListFormat,
114
114
  LogLevel: () => LogLevel,
115
+ MapCode: () => ts_MapCode_exports,
115
116
  MemberOverrideStatus: () => MemberOverrideStatus,
116
117
  ModifierFlags: () => ModifierFlags,
117
118
  ModuleDetectionKind: () => ModuleDetectionKind,
@@ -2369,7 +2370,7 @@ module.exports = __toCommonJS(typescript_exports);
2369
2370
 
2370
2371
  // src/compiler/corePublic.ts
2371
2372
  var versionMajorMinor = "5.5";
2372
- var version = `${versionMajorMinor}.0-dev.20240522`;
2373
+ var version = `${versionMajorMinor}.0-dev.20240524`;
2373
2374
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2374
2375
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2375
2376
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6601,6 +6602,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
6601
6602
  TypeFlags2[TypeFlags2["TemplateLiteral"] = 134217728] = "TemplateLiteral";
6602
6603
  TypeFlags2[TypeFlags2["StringMapping"] = 268435456] = "StringMapping";
6603
6604
  TypeFlags2[TypeFlags2["Reserved1"] = 536870912] = "Reserved1";
6605
+ TypeFlags2[TypeFlags2["Reserved2"] = 1073741824] = "Reserved2";
6604
6606
  TypeFlags2[TypeFlags2["AnyOrUnknown"] = 3] = "AnyOrUnknown";
6605
6607
  TypeFlags2[TypeFlags2["Nullable"] = 98304] = "Nullable";
6606
6608
  TypeFlags2[TypeFlags2["Literal"] = 2944] = "Literal";
@@ -6639,6 +6641,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
6639
6641
  TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
6640
6642
  TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
6641
6643
  TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 536870912 /* Reserved1 */] = "IncludesConstrainedTypeVariable";
6644
+ TypeFlags2[TypeFlags2["IncludesError"] = 1073741824 /* Reserved2 */] = "IncludesError";
6642
6645
  TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
6643
6646
  return TypeFlags2;
6644
6647
  })(TypeFlags || {});
@@ -11116,6 +11119,8 @@ var Diagnostics = {
11116
11119
  Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit: diag(9035, 1 /* Error */, "Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit_9035", "Add satisfies and a type assertion to this expression (satisfies T as T) to make the type explicit."),
11117
11120
  Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it: diag(9036, 1 /* Error */, "Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it_9036", "Move the expression in default export to a variable and add a type annotation to it."),
11118
11121
  Default_exports_can_t_be_inferred_with_isolatedDeclarations: diag(9037, 1 /* Error */, "Default_exports_can_t_be_inferred_with_isolatedDeclarations_9037", "Default exports can't be inferred with --isolatedDeclarations."),
11122
+ Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations: diag(9038, 1 /* Error */, "Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations_9038", "Computed property names on class or object literals cannot be inferred with --isolatedDeclarations."),
11123
+ Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations: diag(9039, 1 /* Error */, "Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations_9039", "Type containing private name '{0}' can't be used with --isolatedDeclarations."),
11119
11124
  JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17e3, 1 /* Error */, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
11120
11125
  JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, 1 /* Error */, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."),
11121
11126
  Expected_corresponding_JSX_closing_tag_for_0: diag(17002, 1 /* Error */, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."),
@@ -49847,7 +49852,6 @@ function createTypeChecker(host) {
49847
49852
  var syntacticNodeBuilder = createSyntacticTypeNodeBuilder(compilerOptions, {
49848
49853
  isEntityNameVisible,
49849
49854
  isExpandoFunctionDeclaration,
49850
- isNonNarrowedBindableName,
49851
49855
  getAllAccessorDeclarations: getAllAccessorDeclarationsForDeclaration,
49852
49856
  requiresAddingImplicitUndefined,
49853
49857
  isUndefinedIdentifierExpression(node) {
@@ -51033,7 +51037,12 @@ function createTypeChecker(host) {
51033
51037
  if (resolvedTarget === unknownSymbol) {
51034
51038
  return source;
51035
51039
  }
51036
- target = cloneSymbol(resolvedTarget);
51040
+ if (!(resolvedTarget.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | resolvedTarget.flags) & 67108864 /* Assignment */) {
51041
+ target = cloneSymbol(resolvedTarget);
51042
+ } else {
51043
+ reportMergeSymbolError(target, source);
51044
+ return source;
51045
+ }
51037
51046
  }
51038
51047
  if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
51039
51048
  target.constEnumOnlyModule = false;
@@ -51063,27 +51072,30 @@ function createTypeChecker(host) {
51063
51072
  );
51064
51073
  }
51065
51074
  } else {
51066
- const isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */);
51067
- const isEitherBlockScoped = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */);
51075
+ reportMergeSymbolError(target, source);
51076
+ }
51077
+ return target;
51078
+ function reportMergeSymbolError(target2, source2) {
51079
+ const isEitherEnum = !!(target2.flags & 384 /* Enum */ || source2.flags & 384 /* Enum */);
51080
+ const isEitherBlockScoped = !!(target2.flags & 2 /* BlockScopedVariable */ || source2.flags & 2 /* BlockScopedVariable */);
51068
51081
  const message = isEitherEnum ? Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0;
51069
- const sourceSymbolFile = source.declarations && getSourceFileOfNode(source.declarations[0]);
51070
- const targetSymbolFile = target.declarations && getSourceFileOfNode(target.declarations[0]);
51082
+ const sourceSymbolFile = source2.declarations && getSourceFileOfNode(source2.declarations[0]);
51083
+ const targetSymbolFile = target2.declarations && getSourceFileOfNode(target2.declarations[0]);
51071
51084
  const isSourcePlainJs = isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
51072
51085
  const isTargetPlainJs = isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
51073
- const symbolName2 = symbolToString(source);
51086
+ const symbolName2 = symbolToString(source2);
51074
51087
  if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
51075
51088
  const firstFile = comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile;
51076
51089
  const secondFile = firstFile === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile;
51077
51090
  const filesDuplicates = getOrUpdate(amalgamatedDuplicates, `${firstFile.path}|${secondFile.path}`, () => ({ firstFile, secondFile, conflictingSymbols: /* @__PURE__ */ new Map() }));
51078
51091
  const conflictingSymbolInfo = getOrUpdate(filesDuplicates.conflictingSymbols, symbolName2, () => ({ isBlockScoped: isEitherBlockScoped, firstFileLocations: [], secondFileLocations: [] }));
51079
- if (!isSourcePlainJs) addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
51080
- if (!isTargetPlainJs) addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
51092
+ if (!isSourcePlainJs) addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source2);
51093
+ if (!isTargetPlainJs) addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target2);
51081
51094
  } else {
51082
- if (!isSourcePlainJs) addDuplicateDeclarationErrorsForSymbols(source, message, symbolName2, target);
51083
- if (!isTargetPlainJs) addDuplicateDeclarationErrorsForSymbols(target, message, symbolName2, source);
51095
+ if (!isSourcePlainJs) addDuplicateDeclarationErrorsForSymbols(source2, message, symbolName2, target2);
51096
+ if (!isTargetPlainJs) addDuplicateDeclarationErrorsForSymbols(target2, message, symbolName2, source2);
51084
51097
  }
51085
51098
  }
51086
- return target;
51087
51099
  function addDuplicateLocations(locs, symbol) {
51088
51100
  if (symbol.declarations) {
51089
51101
  for (const decl of symbol.declarations) {
@@ -53929,6 +53941,9 @@ function createTypeChecker(host) {
53929
53941
  function isClassInstanceSide(type) {
53930
53942
  return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(type.flags & 524288 /* Object */) && !!(getObjectFlags(type) & 16777216 /* IsClassInstanceClone */));
53931
53943
  }
53944
+ function getTypeFromTypeNodeWithoutContext(node) {
53945
+ return getTypeFromTypeNode(node);
53946
+ }
53932
53947
  function createNodeBuilder() {
53933
53948
  return {
53934
53949
  typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
@@ -53957,6 +53972,12 @@ function createTypeChecker(host) {
53957
53972
  symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
53958
53973
  symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
53959
53974
  };
53975
+ function getTypeFromTypeNode2(context, node, noMappedTypes) {
53976
+ const type = getTypeFromTypeNodeWithoutContext(node);
53977
+ if (!context.mapper) return type;
53978
+ const mappedType = instantiateType(type, context.mapper);
53979
+ return noMappedTypes && mappedType !== type ? void 0 : mappedType;
53980
+ }
53960
53981
  function setTextRange2(context, range, location) {
53961
53982
  if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
53962
53983
  range = factory.cloneNode(range);
@@ -54002,7 +54023,7 @@ function createTypeChecker(host) {
54002
54023
  }
54003
54024
  const clone2 = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2);
54004
54025
  if (clone2) {
54005
- if (addUndefined && !someType(getTypeFromTypeNode(typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
54026
+ if (addUndefined && !someType(getTypeFromTypeNode2(context, typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
54006
54027
  return factory.createUnionTypeNode([clone2, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
54007
54028
  }
54008
54029
  return clone2;
@@ -54015,13 +54036,19 @@ function createTypeChecker(host) {
54015
54036
  }
54016
54037
  return void 0;
54017
54038
  }
54018
- function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, annotationType) {
54019
- if (typeNodeIsEquivalentToType(existing, host2, type, annotationType) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
54039
+ function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, annotationType = getTypeFromTypeNode2(
54040
+ context,
54041
+ existing,
54042
+ /*noMappedTypes*/
54043
+ true
54044
+ )) {
54045
+ if (annotationType && typeNodeIsEquivalentToType(host2, type, annotationType) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
54020
54046
  const result = tryReuseExistingTypeNodeHelper(context, existing);
54021
54047
  if (result) {
54022
54048
  return result;
54023
54049
  }
54024
54050
  }
54051
+ context.tracker.reportInferenceFallback(existing);
54025
54052
  return void 0;
54026
54053
  }
54027
54054
  function symbolToNode(symbol, context, meaning) {
@@ -54063,7 +54090,8 @@ function createTypeChecker(host) {
54063
54090
  mustCreateTypeParametersNamesLookups: true,
54064
54091
  typeParameterNames: void 0,
54065
54092
  typeParameterNamesByText: void 0,
54066
- typeParameterNamesByTextNextNameCount: void 0
54093
+ typeParameterNamesByTextNextNameCount: void 0,
54094
+ mapper: void 0
54067
54095
  };
54068
54096
  context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
54069
54097
  const resultingNode = cb(context);
@@ -54354,8 +54382,8 @@ function createTypeChecker(host) {
54354
54382
  context.inferTypeParameters = type2.root.inferTypeParameters;
54355
54383
  const extendsTypeNode2 = typeToTypeNodeHelper(instantiateType(type2.root.extendsType, newMapper), context);
54356
54384
  context.inferTypeParameters = saveInferTypeParameters2;
54357
- const trueTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type2.root.node.trueType), newMapper));
54358
- const falseTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type2.root.node.falseType), newMapper));
54385
+ const trueTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode2(context, type2.root.node.trueType), newMapper));
54386
+ const falseTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode2(context, type2.root.node.falseType), newMapper));
54359
54387
  return factory.createConditionalTypeNode(
54360
54388
  checkTypeNode,
54361
54389
  factory.createInferTypeNode(factory.createTypeParameterDeclaration(
@@ -54438,7 +54466,7 @@ function createTypeChecker(host) {
54438
54466
  context.approximateLength += 10;
54439
54467
  const result = setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
54440
54468
  if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type2) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
54441
- const originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type2.declaration.typeParameter.constraint.type)) || unknownType, type2.mapper);
54469
+ const originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode2(context, type2.declaration.typeParameter.constraint.type)) || unknownType, type2.mapper);
54442
54470
  return factory.createConditionalTypeNode(
54443
54471
  typeToTypeNodeHelper(getModifiersTypeFromMappedType(type2), context),
54444
54472
  factory.createInferTypeNode(factory.createTypeParameterDeclaration(
@@ -55065,7 +55093,7 @@ function createTypeChecker(host) {
55065
55093
  /*skipUnionExpanding*/
55066
55094
  true
55067
55095
  )[0];
55068
- const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters, signature.parameters);
55096
+ const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters, signature.parameters, signature.mapper);
55069
55097
  context.approximateLength += 3;
55070
55098
  if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) {
55071
55099
  typeArguments = signature.target.typeParameters.map((parameter) => typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context));
@@ -55173,11 +55201,15 @@ function createTypeChecker(host) {
55173
55201
  function getParametersInScope(node) {
55174
55202
  return isFunctionLike(node) || isJSDocSignature(node) ? getSignatureFromDeclaration(node).parameters : void 0;
55175
55203
  }
55176
- function enterNewScope(context, declaration, expandedParams, typeParameters, originalParameters) {
55204
+ function enterNewScope(context, declaration, expandedParams, typeParameters, originalParameters, mapper) {
55177
55205
  const cleanupContext = cloneNodeBuilderContext(context);
55178
55206
  let cleanupParams;
55179
55207
  let cleanupTypeParams;
55180
55208
  const oldEnclosingDecl = context.enclosingDeclaration;
55209
+ const oldMapper = context.mapper;
55210
+ if (mapper) {
55211
+ context.mapper = mapper;
55212
+ }
55181
55213
  if (context.enclosingDeclaration && declaration) {
55182
55214
  let pushFakeScope2 = function(kind, addAll) {
55183
55215
  Debug.assert(context.enclosingDeclaration);
@@ -55276,6 +55308,7 @@ function createTypeChecker(host) {
55276
55308
  cleanupTypeParams == null ? void 0 : cleanupTypeParams();
55277
55309
  cleanupContext();
55278
55310
  context.enclosingDeclaration = oldEnclosingDecl;
55311
+ context.mapper = oldMapper;
55279
55312
  };
55280
55313
  }
55281
55314
  function tryGetThisParameterDeclaration(signature, context) {
@@ -55293,7 +55326,7 @@ function createTypeChecker(host) {
55293
55326
  "this",
55294
55327
  /*questionToken*/
55295
55328
  void 0,
55296
- typeToTypeNodeHelper(getTypeFromTypeNode(thisTag.typeExpression), context)
55329
+ typeToTypeNodeHelper(getTypeFromTypeNode2(context, thisTag.typeExpression), context)
55297
55330
  );
55298
55331
  }
55299
55332
  }
@@ -55932,10 +55965,10 @@ function createTypeChecker(host) {
55932
55965
  const addUndefined = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
55933
55966
  const enclosingDeclaration = context.enclosingDeclaration;
55934
55967
  if (enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */)) {
55935
- const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol, getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration));
55968
+ const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol);
55936
55969
  if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
55937
55970
  const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
55938
- const result2 = tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
55971
+ const result2 = !isTypePredicateNode(existing) && tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
55939
55972
  if (result2) {
55940
55973
  return result2;
55941
55974
  }
@@ -55955,7 +55988,7 @@ function createTypeChecker(host) {
55955
55988
  context.flags = oldFlags;
55956
55989
  return result;
55957
55990
  }
55958
- function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type, typeFromTypeNode = getTypeFromTypeNode(typeNode)) {
55991
+ function typeNodeIsEquivalentToType(annotatedDeclaration, type, typeFromTypeNode) {
55959
55992
  if (typeFromTypeNode === type) {
55960
55993
  return true;
55961
55994
  }
@@ -55985,13 +56018,10 @@ function createTypeChecker(host) {
55985
56018
  function serializeReturnTypeForSignatureWorker(context, signature) {
55986
56019
  const typePredicate = getTypePredicateOfSignature(signature);
55987
56020
  const type = getReturnTypeOfSignature(signature);
55988
- if (context.enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */)) {
56021
+ if (context.enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */) && signature.declaration && !nodeIsSynthesized(signature.declaration)) {
55989
56022
  const annotation = signature.declaration && getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
55990
- const enclosingDeclarationIgnoringFakeScope = getEnclosingDeclarationIgnoringFakeScope(context.enclosingDeclaration);
55991
- if (!!findAncestor(annotation, (n) => n === enclosingDeclarationIgnoringFakeScope) && annotation) {
55992
- const annotated = getTypeFromTypeNode(annotation);
55993
- const thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated;
55994
- const result = tryReuseExistingNonParameterTypeNode(context, annotation, type, signature.declaration, thisInstantiated);
56023
+ if (annotation && getTypeFromTypeNode2(context, annotation) === type) {
56024
+ const result = tryReuseExistingTypeNodeHelper(context, annotation);
55995
56025
  if (result) {
55996
56026
  return result;
55997
56027
  }
@@ -56057,6 +56087,9 @@ function createTypeChecker(host) {
56057
56087
  symAtLocation === void 0 && sym !== void 0 || // If the symbol is found both in declaration scope and in current scope then it shoudl point to the same reference
56058
56088
  symAtLocation && sym && !getSymbolIfSameReference(getExportSymbolOfValueSymbolIfExported(symAtLocation), sym)
56059
56089
  ) {
56090
+ if (symAtLocation !== unknownSymbol) {
56091
+ context.tracker.reportInferenceFallback(node);
56092
+ }
56060
56093
  introducesError = true;
56061
56094
  return { introducesError, node, sym };
56062
56095
  }
@@ -56075,6 +56108,7 @@ function createTypeChecker(host) {
56075
56108
  /*shouldComputeAliasesToMakeVisible*/
56076
56109
  false
56077
56110
  ).accessibility !== 0 /* Accessible */) {
56111
+ context.tracker.reportInferenceFallback(node);
56078
56112
  introducesError = true;
56079
56113
  } else {
56080
56114
  context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
@@ -56130,13 +56164,26 @@ function createTypeChecker(host) {
56130
56164
  !(length(existing.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))));
56131
56165
  }
56132
56166
  }
56167
+ if (isThisTypeNode(existing)) {
56168
+ if (context.mapper === void 0) return true;
56169
+ const type = getTypeFromTypeNode2(
56170
+ context,
56171
+ existing,
56172
+ /*noMappedTypes*/
56173
+ true
56174
+ );
56175
+ return !!type;
56176
+ }
56133
56177
  if (isTypeReferenceNode(existing)) {
56134
56178
  if (isConstTypeReference(existing)) return false;
56135
56179
  const type = getTypeFromTypeReference(existing);
56136
56180
  const symbol = getNodeLinks(existing).resolvedSymbol;
56137
56181
  if (!symbol) return false;
56138
56182
  if (symbol.flags & 262144 /* TypeParameter */) {
56139
- return true;
56183
+ const type2 = getDeclaredTypeOfSymbol(symbol);
56184
+ if (context.mapper && getMappedType(type2, context.mapper) !== type2) {
56185
+ return false;
56186
+ }
56140
56187
  }
56141
56188
  if (isInJSDoc(existing)) {
56142
56189
  return existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) && !getIntendedTypeFromJSDocTypeReference(existing) && symbol.flags & 788968 /* Type */;
@@ -56149,7 +56196,7 @@ function createTypeChecker(host) {
56149
56196
  return true;
56150
56197
  }
56151
56198
  function serializeExistingTypeNode(context, typeNode) {
56152
- const type = getTypeFromTypeNode(typeNode);
56199
+ const type = getTypeFromTypeNode2(context, typeNode);
56153
56200
  return typeToTypeNodeHelper(type, context);
56154
56201
  }
56155
56202
  function tryReuseExistingTypeNodeHelper(context, existing) {
@@ -56197,8 +56244,8 @@ function createTypeChecker(host) {
56197
56244
  if (isJSDocTypeLiteral(node)) {
56198
56245
  return factory.createTypeLiteralNode(map(node.jsDocPropertyTags, (t) => {
56199
56246
  const name = isIdentifier(t.name) ? t.name : t.name.right;
56200
- const typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText);
56201
- const overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : void 0;
56247
+ const typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode2(context, node), name.escapedText);
56248
+ const overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode2(context, t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : void 0;
56202
56249
  return factory.createPropertySignature(
56203
56250
  /*modifiers*/
56204
56251
  void 0,
@@ -56239,7 +56286,7 @@ function createTypeChecker(host) {
56239
56286
  /*modifiers*/
56240
56287
  void 0,
56241
56288
  getEffectiveDotDotDotForParameter(p),
56242
- getNameForJSDocFunctionParameter(p, i),
56289
+ setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
56243
56290
  p.questionToken,
56244
56291
  visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
56245
56292
  /*initializer*/
@@ -56254,7 +56301,7 @@ function createTypeChecker(host) {
56254
56301
  /*modifiers*/
56255
56302
  void 0,
56256
56303
  getEffectiveDotDotDotForParameter(p),
56257
- getNameForJSDocFunctionParameter(p, i),
56304
+ setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
56258
56305
  p.questionToken,
56259
56306
  visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
56260
56307
  /*initializer*/
@@ -56264,6 +56311,21 @@ function createTypeChecker(host) {
56264
56311
  );
56265
56312
  }
56266
56313
  }
56314
+ if (isThisTypeNode(node)) {
56315
+ if (canReuseTypeNode(context, node)) {
56316
+ return node;
56317
+ }
56318
+ return serializeExistingTypeNode(context, node);
56319
+ }
56320
+ if (isTypeParameterDeclaration(node)) {
56321
+ return factory.updateTypeParameterDeclaration(
56322
+ node,
56323
+ node.modifiers,
56324
+ setTextRange2(context, typeParameterToName(getDeclaredTypeOfSymbol(getSymbolOfDeclaration(node)), context), node),
56325
+ visitNode(node.constraint, visitExistingNodeTreeSymbols, isTypeNode),
56326
+ visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode)
56327
+ );
56328
+ }
56267
56329
  if (isTypeReferenceNode(node)) {
56268
56330
  if (canReuseTypeNode(context, node)) {
56269
56331
  const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
@@ -56295,7 +56357,7 @@ function createTypeChecker(host) {
56295
56357
  if (isInJSDoc(node) && nodeSymbol && // The import type resolved using jsdoc fallback logic
56296
56358
  (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
56297
56359
  !(length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
56298
- return setTextRange2(context, typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
56360
+ return setTextRange2(context, typeToTypeNodeHelper(getTypeFromTypeNode2(context, node), context), node);
56299
56361
  }
56300
56362
  return factory.updateImportTypeNode(
56301
56363
  node,
@@ -56365,10 +56427,16 @@ function createTypeChecker(host) {
56365
56427
  return factory.updateComputedPropertyName(node, literal);
56366
56428
  }
56367
56429
  }
56368
- if (isTypePredicateNode(node) && isIdentifier(node.parameterName)) {
56369
- const { node: result, introducesError } = trackExistingEntityName(node.parameterName, context);
56370
- hadError = hadError || introducesError;
56371
- return factory.updateTypePredicateNode(node, node.assertsModifier, result, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
56430
+ if (isTypePredicateNode(node)) {
56431
+ let parameterName;
56432
+ if (isIdentifier(node.parameterName)) {
56433
+ const { node: result, introducesError } = trackExistingEntityName(node.parameterName, context);
56434
+ hadError = hadError || introducesError;
56435
+ parameterName = result;
56436
+ } else {
56437
+ parameterName = node.parameterName;
56438
+ }
56439
+ return factory.updateTypePredicateNode(node, node.assertsModifier, parameterName, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
56372
56440
  }
56373
56441
  if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
56374
56442
  const visited = visitEachChild(
@@ -57144,7 +57212,7 @@ function createTypeChecker(host) {
57144
57212
  }
57145
57213
  return cleanup(factory.createExpressionWithTypeArguments(
57146
57214
  expr,
57147
- map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(context, a, getTypeFromTypeNode(a)) || typeToTypeNodeHelper(getTypeFromTypeNode(a), context))
57215
+ map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(context, a, getTypeFromTypeNode2(context, a)) || typeToTypeNodeHelper(getTypeFromTypeNode2(context, a), context))
57148
57216
  ));
57149
57217
  function cleanup(result2) {
57150
57218
  context.enclosingDeclaration = oldEnclosing;
@@ -63688,6 +63756,7 @@ function createTypeChecker(host) {
63688
63756
  if (flags & 465829888 /* Instantiable */) includes |= 33554432 /* IncludesInstantiable */;
63689
63757
  if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) includes |= 536870912 /* IncludesConstrainedTypeVariable */;
63690
63758
  if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
63759
+ if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
63691
63760
  if (!strictNullChecks && flags & 98304 /* Nullable */) {
63692
63761
  if (!(getObjectFlags(type) & 65536 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */;
63693
63762
  } else {
@@ -63879,7 +63948,7 @@ function createTypeChecker(host) {
63879
63948
  const includes = addTypesToUnion(typeSet, 0, types);
63880
63949
  if (unionReduction !== 0 /* None */) {
63881
63950
  if (includes & 3 /* AnyOrUnknown */) {
63882
- return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : unknownType;
63951
+ return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType : unknownType;
63883
63952
  }
63884
63953
  if (includes & 32768 /* Undefined */) {
63885
63954
  if (typeSet.length >= 2 && typeSet[0] === undefinedType && typeSet[1] === missingType) {
@@ -64005,6 +64074,7 @@ function createTypeChecker(host) {
64005
64074
  } else {
64006
64075
  if (flags & 3 /* AnyOrUnknown */) {
64007
64076
  if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */;
64077
+ if (isErrorType(type)) includes |= 1073741824 /* IncludesError */;
64008
64078
  } else if (strictNullChecks || !(flags & 98304 /* Nullable */)) {
64009
64079
  if (type === missingType) {
64010
64080
  includes |= 262144 /* IncludesMissingType */;
@@ -64132,7 +64202,7 @@ function createTypeChecker(host) {
64132
64202
  return neverType;
64133
64203
  }
64134
64204
  if (includes & 1 /* Any */) {
64135
- return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType;
64205
+ return includes & 8388608 /* IncludesWildcard */ ? wildcardType : includes & 1073741824 /* IncludesError */ ? errorType : anyType;
64136
64206
  }
64137
64207
  if (!strictNullChecks && includes & 98304 /* Nullable */) {
64138
64208
  return includes & 16777216 /* IncludesEmptyObject */ ? neverType : includes & 32768 /* Undefined */ ? undefinedType : nullType;
@@ -89635,6 +89705,7 @@ function createTypeChecker(host) {
89635
89705
  function getSingleReturnExpression(declaration) {
89636
89706
  let candidateExpr;
89637
89707
  if (declaration && !nodeIsMissing(declaration.body)) {
89708
+ if (getFunctionFlags(declaration) & 3 /* AsyncGenerator */) return void 0;
89638
89709
  const body = declaration.body;
89639
89710
  if (body && isBlock(body)) {
89640
89711
  forEachReturnStatement(body, (s) => {
@@ -89769,22 +89840,6 @@ function createTypeChecker(host) {
89769
89840
  }
89770
89841
  return false;
89771
89842
  }
89772
- function isNonNarrowedBindableName(node) {
89773
- if (!hasBindableName(node.parent)) {
89774
- return false;
89775
- }
89776
- const expression = node.expression;
89777
- if (!isEntityNameExpression(expression)) {
89778
- return true;
89779
- }
89780
- const type = getTypeOfExpression(expression);
89781
- const symbol = getSymbolAtLocation(expression);
89782
- if (!symbol) {
89783
- return false;
89784
- }
89785
- const declaredType = getTypeOfSymbol(symbol);
89786
- return declaredType === type;
89787
- }
89788
89843
  function literalTypeToNode(type, enclosing, tracker) {
89789
89844
  const enumResult = type.flags & 1056 /* EnumLike */ ? nodeBuilder.symbolToExpression(
89790
89845
  type.symbol,
@@ -89903,7 +89958,6 @@ function createTypeChecker(host) {
89903
89958
  return node && getExternalModuleFileFromDeclaration(node);
89904
89959
  },
89905
89960
  isLiteralConstDeclaration,
89906
- isNonNarrowedBindableName,
89907
89961
  isLateBound: (nodeIn) => {
89908
89962
  const node = getParseTreeNode(nodeIn, isDeclaration);
89909
89963
  const symbol = node && getSymbolOfDeclaration(node);
@@ -97235,10 +97289,9 @@ function transformClassFields(context) {
97235
97289
  }
97236
97290
  }
97237
97291
  }
97238
- function getClassThis() {
97292
+ function tryGetClassThis() {
97239
97293
  const lex = getClassLexicalEnvironment();
97240
- const classThis = lex.classThis ?? lex.classConstructor ?? (currentClassContainer == null ? void 0 : currentClassContainer.name);
97241
- return Debug.checkDefined(classThis);
97294
+ return lex.classThis ?? lex.classConstructor ?? (currentClassContainer == null ? void 0 : currentClassContainer.name);
97242
97295
  }
97243
97296
  function transformAutoAccessor(node) {
97244
97297
  const commentRange = getCommentRange(node);
@@ -97266,7 +97319,7 @@ function transformClassFields(context) {
97266
97319
  setOriginalNode(backingField, node);
97267
97320
  setEmitFlags(backingField, 3072 /* NoComments */);
97268
97321
  setSourceMapRange(backingField, sourceMapRange);
97269
- const receiver = isStatic(node) ? getClassThis() : factory2.createThis();
97322
+ const receiver = isStatic(node) ? tryGetClassThis() ?? factory2.createThis() : factory2.createThis();
97270
97323
  const getter = createAccessorPropertyGetRedirector(factory2, node, modifiers, getterName, receiver);
97271
97324
  setOriginalNode(getter, node);
97272
97325
  setCommentRange(getter, commentRange);
@@ -97832,7 +97885,7 @@ function transformClassFields(context) {
97832
97885
  var _a;
97833
97886
  let facts = 0 /* None */;
97834
97887
  const original = getOriginalNode(node);
97835
- if (isClassDeclaration(original) && classOrConstructorParameterIsDecorated(legacyDecorators, original)) {
97888
+ if (isClassLike(original) && classOrConstructorParameterIsDecorated(legacyDecorators, original)) {
97836
97889
  facts |= 1 /* ClassWasDecorated */;
97837
97890
  }
97838
97891
  if (shouldTransformPrivateElementsOrClassStaticBlocks && (classHasClassThisAssignment(node) || classHasExplicitlyAssignedName(node))) {
@@ -115005,7 +115058,7 @@ function createGetIsolatedDeclarationErrors(resolver) {
115005
115058
  [260 /* VariableDeclaration */]: Diagnostics.Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
115006
115059
  [172 /* PropertyDeclaration */]: Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
115007
115060
  [171 /* PropertySignature */]: Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
115008
- [167 /* ComputedPropertyName */]: Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations,
115061
+ [167 /* ComputedPropertyName */]: Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations,
115009
115062
  [305 /* SpreadAssignment */]: Diagnostics.Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations,
115010
115063
  [304 /* ShorthandPropertyAssignment */]: Diagnostics.Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations,
115011
115064
  [209 /* ArrayLiteralExpression */]: Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations,
@@ -115018,6 +115071,9 @@ function createGetIsolatedDeclarationErrors(resolver) {
115018
115071
  if (heritageClause) {
115019
115072
  return createDiagnosticForNode(node, Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations);
115020
115073
  }
115074
+ if ((isPartOfTypeNode(node) || isTypeQueryNode(node.parent)) && (isEntityName(node) || isEntityNameExpression(node))) {
115075
+ return createEntityInTypeNodeError(node);
115076
+ }
115021
115077
  Debug.type(node);
115022
115078
  switch (node.kind) {
115023
115079
  case 177 /* GetAccessor */:
@@ -115053,8 +115109,13 @@ function createGetIsolatedDeclarationErrors(resolver) {
115053
115109
  }
115054
115110
  }
115055
115111
  function findNearestDeclaration(node) {
115056
- const result = findAncestor(node, (n) => isExportAssignment(n) || (isStatement(n) ? "quit" : isVariableDeclaration(n) || isPropertyDeclaration(n) || isParameter(n)));
115057
- return result;
115112
+ const result = findAncestor(node, (n) => isExportAssignment(n) || isStatement(n) || isVariableDeclaration(n) || isPropertyDeclaration(n) || isParameter(n));
115113
+ if (!result) return void 0;
115114
+ if (isExportAssignment(result)) return result;
115115
+ if (isReturnStatement(result)) {
115116
+ return findAncestor(result, (n) => isFunctionLikeDeclaration(n) && !isConstructorDeclaration(n));
115117
+ }
115118
+ return isStatement(result) ? void 0 : result;
115058
115119
  }
115059
115120
  function createAccessorTypeError(node) {
115060
115121
  const { getAccessor, setAccessor } = getAllAccessorDeclarations(node.symbol.declarations, node);
@@ -115068,11 +115129,10 @@ function createGetIsolatedDeclarationErrors(resolver) {
115068
115129
  }
115069
115130
  return diag2;
115070
115131
  }
115071
- function createObjectLiteralError(node) {
115072
- const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
115132
+ function addParentDeclarationRelatedInfo(node, diag2) {
115073
115133
  const parentDeclaration = findNearestDeclaration(node);
115074
115134
  if (parentDeclaration) {
115075
- const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
115135
+ const targetStr = isExportAssignment(parentDeclaration) || !parentDeclaration.name ? "" : getTextOfNode(
115076
115136
  parentDeclaration.name,
115077
115137
  /*includeTrivia*/
115078
115138
  false
@@ -115081,30 +115141,19 @@ function createGetIsolatedDeclarationErrors(resolver) {
115081
115141
  }
115082
115142
  return diag2;
115083
115143
  }
115144
+ function createObjectLiteralError(node) {
115145
+ const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
115146
+ addParentDeclarationRelatedInfo(node, diag2);
115147
+ return diag2;
115148
+ }
115084
115149
  function createArrayLiteralError(node) {
115085
115150
  const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
115086
- const parentDeclaration = findNearestDeclaration(node);
115087
- if (parentDeclaration) {
115088
- const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
115089
- parentDeclaration.name,
115090
- /*includeTrivia*/
115091
- false
115092
- );
115093
- addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
115094
- }
115151
+ addParentDeclarationRelatedInfo(node, diag2);
115095
115152
  return diag2;
115096
115153
  }
115097
115154
  function createReturnTypeError(node) {
115098
115155
  const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
115099
- const parentDeclaration = findNearestDeclaration(node);
115100
- if (parentDeclaration) {
115101
- const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
115102
- parentDeclaration.name,
115103
- /*includeTrivia*/
115104
- false
115105
- );
115106
- addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
115107
- }
115156
+ addParentDeclarationRelatedInfo(node, diag2);
115108
115157
  addRelatedInfo(diag2, createDiagnosticForNode(node, relatedSuggestionByDeclarationKind[node.kind]));
115109
115158
  return diag2;
115110
115159
  }
@@ -115142,11 +115191,20 @@ function createGetIsolatedDeclarationErrors(resolver) {
115142
115191
  function createClassExpressionError(node) {
115143
115192
  return createExpressionError(node, Diagnostics.Inference_from_class_expressions_is_not_supported_with_isolatedDeclarations);
115144
115193
  }
115194
+ function createEntityInTypeNodeError(node) {
115195
+ const diag2 = createDiagnosticForNode(node, Diagnostics.Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations, getTextOfNode(
115196
+ node,
115197
+ /*includeTrivia*/
115198
+ false
115199
+ ));
115200
+ addParentDeclarationRelatedInfo(node, diag2);
115201
+ return diag2;
115202
+ }
115145
115203
  function createExpressionError(node, diagnosticMessage) {
115146
115204
  const parentDeclaration = findNearestDeclaration(node);
115147
115205
  let diag2;
115148
115206
  if (parentDeclaration) {
115149
- const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
115207
+ const targetStr = isExportAssignment(parentDeclaration) || !parentDeclaration.name ? "" : getTextOfNode(
115150
115208
  parentDeclaration.name,
115151
115209
  /*includeTrivia*/
115152
115210
  false
@@ -115871,8 +115929,11 @@ function transformDeclarations(context) {
115871
115929
  if (shouldStripInternal(input)) return;
115872
115930
  if (isDeclaration(input)) {
115873
115931
  if (isDeclarationAndNotVisible(input)) return;
115874
- if (hasDynamicName(input) && !resolver.isLateBound(getParseTreeNode(input))) {
115875
- if (isolatedDeclarations && isClassDeclaration(input.parent) && isEntityNameExpression(input.name.expression) && resolver.isEntityNameVisible(input.name.expression, input.parent).accessibility === 0 /* Accessible */ && !resolver.isNonNarrowedBindableName(input.name)) {
115932
+ if (hasDynamicName(input)) {
115933
+ if (isolatedDeclarations && (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent))) {
115934
+ context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
115935
+ }
115936
+ if (isolatedDeclarations && (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)) {
115876
115937
  context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
115877
115938
  }
115878
115939
  if (!isEntityNameExpression(input.name.expression)) {
@@ -117816,7 +117877,6 @@ var notImplementedResolver = {
117816
117877
  isArgumentsLocalBinding: notImplemented,
117817
117878
  getExternalModuleFileFromDeclaration: notImplemented,
117818
117879
  isLiteralConstDeclaration: notImplemented,
117819
- isNonNarrowedBindableName: notImplemented,
117820
117880
  getJsxFactoryEntity: notImplemented,
117821
117881
  getJsxFragmentFactoryEntity: notImplemented,
117822
117882
  isBindingCapturedByNode: notImplemented,
@@ -134240,7 +134300,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
134240
134300
  expression,
134241
134301
  /*includeBigInt*/
134242
134302
  false
134243
- ) && !isEntityNameExpression(expression)) {
134303
+ )) {
134244
134304
  context.tracker.reportInferenceFallback(prop.name);
134245
134305
  result = false;
134246
134306
  }
@@ -134254,21 +134314,6 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
134254
134314
  for (const prop of objectLiteral.properties) {
134255
134315
  Debug.assert(!isShorthandPropertyAssignment(prop) && !isSpreadAssignment(prop));
134256
134316
  const name = prop.name;
134257
- if (prop.name.kind === 167 /* ComputedPropertyName */) {
134258
- if (!resolver.isNonNarrowedBindableName(prop.name)) {
134259
- context.tracker.reportInferenceFallback(prop.name);
134260
- } else if (isEntityNameExpression(prop.name.expression)) {
134261
- const visibilityResult = resolver.isEntityNameVisible(
134262
- prop.name.expression,
134263
- context.enclosingDeclaration,
134264
- /*shouldComputeAliasToMakeVisible*/
134265
- false
134266
- );
134267
- if (visibilityResult.accessibility !== 0 /* Accessible */) {
134268
- context.tracker.reportInferenceFallback(prop.name);
134269
- }
134270
- }
134271
- }
134272
134317
  switch (prop.kind) {
134273
134318
  case 174 /* MethodDeclaration */:
134274
134319
  canInferObjectLiteral = !!typeFromObjectLiteralMethod(prop, name, context) && canInferObjectLiteral;
@@ -134349,6 +134394,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
134349
134394
  function typeFromSingleReturnExpression(declaration, context) {
134350
134395
  let candidateExpr;
134351
134396
  if (declaration && !nodeIsMissing(declaration.body)) {
134397
+ if (getFunctionFlags(declaration) & 3 /* AsyncGenerator */) return void 0;
134352
134398
  const body = declaration.body;
134353
134399
  if (body && isBlock(body)) {
134354
134400
  forEachReturnStatement(body, (s) => {
@@ -142924,7 +142970,7 @@ registerRefactor(refactorNameForMoveToFile, {
142924
142970
  if (!interactiveRefactorArguments) {
142925
142971
  return emptyArray;
142926
142972
  }
142927
- if (context.endPosition !== void 0) {
142973
+ if (context.triggerReason === "implicit" && context.endPosition !== void 0) {
142928
142974
  const startNodeAncestor = findAncestor(getTokenAtPosition(file, context.startPosition), isBlockLike);
142929
142975
  const endNodeAncestor = findAncestor(getTokenAtPosition(file, context.endPosition), isBlockLike);
142930
142976
  if (startNodeAncestor && !isSourceFile(startNodeAncestor) && endNodeAncestor && !isSourceFile(endNodeAncestor)) {
@@ -143915,11 +143961,19 @@ registerRefactor(refactorName5, {
143915
143961
  kinds: [moveToNewFileAction.kind],
143916
143962
  getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
143917
143963
  const statements = getStatementsToMove(context);
143964
+ const file = context.file;
143965
+ if (context.triggerReason === "implicit" && context.endPosition !== void 0) {
143966
+ const startNodeAncestor = findAncestor(getTokenAtPosition(file, context.startPosition), isBlockLike);
143967
+ const endNodeAncestor = findAncestor(getTokenAtPosition(file, context.endPosition), isBlockLike);
143968
+ if (startNodeAncestor && !isSourceFile(startNodeAncestor) && endNodeAncestor && !isSourceFile(endNodeAncestor)) {
143969
+ return emptyArray;
143970
+ }
143971
+ }
143918
143972
  if (context.preferences.allowTextChangesInNewFiles && statements) {
143919
- const file = context.file;
143973
+ const file2 = context.file;
143920
143974
  const affectedTextRange = {
143921
- start: { line: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).line, offset: getLineAndCharacterOfPosition(file, statements.all[0].getStart(file)).character },
143922
- end: { line: getLineAndCharacterOfPosition(file, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file, last(statements.all).end).character }
143975
+ start: { line: getLineAndCharacterOfPosition(file2, statements.all[0].getStart(file2)).line, offset: getLineAndCharacterOfPosition(file2, statements.all[0].getStart(file2)).character },
143976
+ end: { line: getLineAndCharacterOfPosition(file2, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file2, last(statements.all).end).character }
143923
143977
  };
143924
143978
  return [{ name: refactorName5, description: description2, actions: [{ ...moveToNewFileAction, range: affectedTextRange }] }];
143925
143979
  }
@@ -149423,6 +149477,16 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
149423
149477
  const sourceFile = getValidSourceFile(fileName);
149424
149478
  return ts_InlayHints_exports.provideInlayHints(getInlayHintsContext(sourceFile, span, preferences));
149425
149479
  }
149480
+ function mapCode2(sourceFile, contents, focusLocations, formatOptions, preferences) {
149481
+ return ts_MapCode_exports.mapCode(
149482
+ syntaxTreeCache.getCurrentSourceFile(sourceFile),
149483
+ contents,
149484
+ focusLocations,
149485
+ host,
149486
+ ts_formatting_exports.getFormatContext(formatOptions, host),
149487
+ preferences
149488
+ );
149489
+ }
149426
149490
  const ls = {
149427
149491
  dispose,
149428
149492
  cleanupSemanticCache,
@@ -149493,7 +149557,8 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
149493
149557
  uncommentSelection,
149494
149558
  provideInlayHints: provideInlayHints2,
149495
149559
  getSupportedCodeFixes,
149496
- getPasteEdits
149560
+ getPasteEdits,
149561
+ mapCode: mapCode2
149497
149562
  };
149498
149563
  switch (languageServiceMode) {
149499
149564
  case 0 /* Semantic */:
@@ -158080,6 +158145,7 @@ var errorCodes47 = [
158080
158145
  Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations.code,
158081
158146
  Diagnostics.Expression_type_can_t_be_inferred_with_isolatedDeclarations.code,
158082
158147
  Diagnostics.Binding_elements_can_t_be_exported_directly_with_isolatedDeclarations.code,
158148
+ Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations.code,
158083
158149
  Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations.code,
158084
158150
  Diagnostics.Enum_member_initializers_must_be_computable_without_references_to_external_symbols_with_isolatedDeclarations.code,
158085
158151
  Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations.code,
@@ -158090,6 +158156,7 @@ var errorCodes47 = [
158090
158156
  Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations.code,
158091
158157
  Diagnostics.Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations_Add_an_explicit_declaration_for_the_properties_assigned_to_this_function.code,
158092
158158
  Diagnostics.Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_supported_with_isolatedDeclarations.code,
158159
+ Diagnostics.Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations.code,
158093
158160
  Diagnostics.Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit.code
158094
158161
  ];
158095
158162
  var canHaveTypeAnnotation = /* @__PURE__ */ new Set([
@@ -158250,7 +158317,7 @@ function withContext(context, typePrintMode, cb) {
158250
158317
  if (findAncestor(targetNode, isEnumMember)) {
158251
158318
  return void 0;
158252
158319
  }
158253
- if (isExpressionTarget && findAncestor(targetNode, isHeritageClause)) {
158320
+ if (isExpressionTarget && (findAncestor(targetNode, isHeritageClause) || findAncestor(targetNode, isTypeNode))) {
158254
158321
  return void 0;
158255
158322
  }
158256
158323
  if (isSpreadElement(targetNode)) {
@@ -170779,6 +170846,213 @@ function getRightHandSideOfAssignment(rightHandSide) {
170779
170846
  }
170780
170847
  }
170781
170848
 
170849
+ // src/services/_namespaces/ts.MapCode.ts
170850
+ var ts_MapCode_exports = {};
170851
+ __export(ts_MapCode_exports, {
170852
+ mapCode: () => mapCode
170853
+ });
170854
+
170855
+ // src/services/mapCode.ts
170856
+ function mapCode(sourceFile, contents, focusLocations, host, formatContext, preferences) {
170857
+ return ts_textChanges_exports.ChangeTracker.with(
170858
+ { host, formatContext, preferences },
170859
+ (changeTracker) => {
170860
+ const parsed = contents.map((c) => parse(sourceFile, c));
170861
+ const flattenedLocations = focusLocations && flatten(focusLocations);
170862
+ for (const nodes of parsed) {
170863
+ placeNodeGroup(
170864
+ sourceFile,
170865
+ changeTracker,
170866
+ nodes,
170867
+ flattenedLocations
170868
+ );
170869
+ }
170870
+ }
170871
+ );
170872
+ }
170873
+ function parse(sourceFile, content) {
170874
+ const nodeKinds = [
170875
+ {
170876
+ parse: () => createSourceFile(
170877
+ "__mapcode_content_nodes.ts",
170878
+ content,
170879
+ sourceFile.languageVersion,
170880
+ /*setParentNodes*/
170881
+ true,
170882
+ sourceFile.scriptKind
170883
+ ),
170884
+ body: (sf) => sf.statements
170885
+ },
170886
+ {
170887
+ parse: () => createSourceFile(
170888
+ "__mapcode_class_content_nodes.ts",
170889
+ `class __class {
170890
+ ${content}
170891
+ }`,
170892
+ sourceFile.languageVersion,
170893
+ /*setParentNodes*/
170894
+ true,
170895
+ sourceFile.scriptKind
170896
+ ),
170897
+ body: (cw) => cw.statements[0].members
170898
+ }
170899
+ ];
170900
+ const parsedNodes = [];
170901
+ for (const { parse: parse2, body: body2 } of nodeKinds) {
170902
+ const sourceFile2 = parse2();
170903
+ const bod = body2(sourceFile2);
170904
+ if (bod.length && sourceFile2.parseDiagnostics.length === 0) {
170905
+ return bod;
170906
+ } else if (bod.length) {
170907
+ parsedNodes.push({ sourceFile: sourceFile2, body: bod });
170908
+ }
170909
+ }
170910
+ const { body } = parsedNodes.sort(
170911
+ (a, b) => a.sourceFile.parseDiagnostics.length - b.sourceFile.parseDiagnostics.length
170912
+ )[0];
170913
+ return body;
170914
+ }
170915
+ function placeNodeGroup(originalFile, changeTracker, changes, focusLocations) {
170916
+ if (isClassElement(changes[0]) || isTypeElement(changes[0])) {
170917
+ placeClassNodeGroup(
170918
+ originalFile,
170919
+ changeTracker,
170920
+ changes,
170921
+ focusLocations
170922
+ );
170923
+ } else {
170924
+ placeStatements(
170925
+ originalFile,
170926
+ changeTracker,
170927
+ changes,
170928
+ focusLocations
170929
+ );
170930
+ }
170931
+ }
170932
+ function placeClassNodeGroup(originalFile, changeTracker, changes, focusLocations) {
170933
+ let classOrInterface;
170934
+ if (!focusLocations || !focusLocations.length) {
170935
+ classOrInterface = find(originalFile.statements, or(isClassLike, isInterfaceDeclaration));
170936
+ } else {
170937
+ classOrInterface = forEach(focusLocations, (location) => findAncestor(
170938
+ getTokenAtPosition(originalFile, location.start),
170939
+ or(isClassLike, isInterfaceDeclaration)
170940
+ ));
170941
+ }
170942
+ if (!classOrInterface) {
170943
+ return;
170944
+ }
170945
+ const firstMatch = classOrInterface.members.find((member) => changes.some((change) => matchNode(change, member)));
170946
+ if (firstMatch) {
170947
+ const lastMatch = findLast(
170948
+ classOrInterface.members,
170949
+ (member) => changes.some((change) => matchNode(change, member))
170950
+ );
170951
+ forEach(changes, wipeNode);
170952
+ changeTracker.replaceNodeRangeWithNodes(
170953
+ originalFile,
170954
+ firstMatch,
170955
+ lastMatch,
170956
+ changes
170957
+ );
170958
+ return;
170959
+ }
170960
+ forEach(changes, wipeNode);
170961
+ changeTracker.insertNodesAfter(
170962
+ originalFile,
170963
+ classOrInterface.members[classOrInterface.members.length - 1],
170964
+ changes
170965
+ );
170966
+ }
170967
+ function placeStatements(originalFile, changeTracker, changes, focusLocations) {
170968
+ if (!(focusLocations == null ? void 0 : focusLocations.length)) {
170969
+ changeTracker.insertNodesAtEndOfFile(
170970
+ originalFile,
170971
+ changes,
170972
+ /*blankLineBetween*/
170973
+ false
170974
+ );
170975
+ return;
170976
+ }
170977
+ for (const location of focusLocations) {
170978
+ const scope = findAncestor(
170979
+ getTokenAtPosition(originalFile, location.start),
170980
+ (block) => or(isBlock, isSourceFile)(block) && some(block.statements, (origStmt) => changes.some((newStmt) => matchNode(newStmt, origStmt)))
170981
+ );
170982
+ if (scope) {
170983
+ const start = scope.statements.find((stmt) => changes.some((node) => matchNode(node, stmt)));
170984
+ if (start) {
170985
+ const end = findLast(scope.statements, (stmt) => changes.some((node) => matchNode(node, stmt)));
170986
+ forEach(changes, wipeNode);
170987
+ changeTracker.replaceNodeRangeWithNodes(
170988
+ originalFile,
170989
+ start,
170990
+ end,
170991
+ changes
170992
+ );
170993
+ return;
170994
+ }
170995
+ }
170996
+ }
170997
+ let scopeStatements = originalFile.statements;
170998
+ for (const location of focusLocations) {
170999
+ const block = findAncestor(
171000
+ getTokenAtPosition(originalFile, location.start),
171001
+ isBlock
171002
+ );
171003
+ if (block) {
171004
+ scopeStatements = block.statements;
171005
+ break;
171006
+ }
171007
+ }
171008
+ forEach(changes, wipeNode);
171009
+ changeTracker.insertNodesAfter(
171010
+ originalFile,
171011
+ scopeStatements[scopeStatements.length - 1],
171012
+ changes
171013
+ );
171014
+ }
171015
+ function matchNode(a, b) {
171016
+ var _a, _b, _c, _d, _e, _f;
171017
+ if (a.kind !== b.kind) {
171018
+ return false;
171019
+ }
171020
+ if (a.kind === 176 /* Constructor */) {
171021
+ return a.kind === b.kind;
171022
+ }
171023
+ if (isNamedDeclaration(a) && isNamedDeclaration(b)) {
171024
+ return a.name.getText() === b.name.getText();
171025
+ }
171026
+ if (isIfStatement(a) && isIfStatement(b)) {
171027
+ return a.expression.getText() === b.expression.getText();
171028
+ }
171029
+ if (isWhileStatement(a) && isWhileStatement(b)) {
171030
+ return a.expression.getText() === b.expression.getText();
171031
+ }
171032
+ if (isForStatement(a) && isForStatement(b)) {
171033
+ return ((_a = a.initializer) == null ? void 0 : _a.getText()) === ((_b = b.initializer) == null ? void 0 : _b.getText()) && ((_c = a.incrementor) == null ? void 0 : _c.getText()) === ((_d = b.incrementor) == null ? void 0 : _d.getText()) && ((_e = a.condition) == null ? void 0 : _e.getText()) === ((_f = b.condition) == null ? void 0 : _f.getText());
171034
+ }
171035
+ if (isForInOrOfStatement(a) && isForInOrOfStatement(b)) {
171036
+ return a.expression.getText() === b.expression.getText() && a.initializer.getText() === b.initializer.getText();
171037
+ }
171038
+ if (isLabeledStatement(a) && isLabeledStatement(b)) {
171039
+ return a.label.getText() === b.label.getText();
171040
+ }
171041
+ if (a.getText() === b.getText()) {
171042
+ return true;
171043
+ }
171044
+ return false;
171045
+ }
171046
+ function wipeNode(node) {
171047
+ resetNodePositions(node);
171048
+ node.parent = void 0;
171049
+ }
171050
+ function resetNodePositions(node) {
171051
+ node.pos = -1;
171052
+ node.end = -1;
171053
+ node.forEachChild(resetNodePositions);
171054
+ }
171055
+
170782
171056
  // src/services/_namespaces/ts.OrganizeImports.ts
170783
171057
  var ts_OrganizeImports_exports = {};
170784
171058
  __export(ts_OrganizeImports_exports, {
@@ -173071,7 +173345,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
173071
173345
  typeChecker,
173072
173346
  resolvedSymbol,
173073
173347
  getSourceFileOfNode(resolvedNode),
173074
- resolvedNode,
173348
+ enclosingDeclaration,
173075
173349
  declarationName,
173076
173350
  type,
173077
173351
  semanticMeaning,
@@ -177566,6 +177840,7 @@ __export(ts_exports2, {
177566
177840
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
177567
177841
  ListFormat: () => ListFormat,
177568
177842
  LogLevel: () => LogLevel,
177843
+ MapCode: () => ts_MapCode_exports,
177569
177844
  MemberOverrideStatus: () => MemberOverrideStatus,
177570
177845
  ModifierFlags: () => ModifierFlags,
177571
177846
  ModuleDetectionKind: () => ModuleDetectionKind,
@@ -180747,6 +181022,7 @@ var CommandTypes = /* @__PURE__ */ ((CommandTypes2) => {
180747
181022
  CommandTypes2["ProvideCallHierarchyOutgoingCalls"] = "provideCallHierarchyOutgoingCalls";
180748
181023
  CommandTypes2["ProvideInlayHints"] = "provideInlayHints";
180749
181024
  CommandTypes2["WatchChange"] = "watchChange";
181025
+ CommandTypes2["MapCode"] = "mapCode";
180750
181026
  return CommandTypes2;
180751
181027
  })(CommandTypes || {});
180752
181028
  var WatchFileKind2 = /* @__PURE__ */ ((WatchFileKind3) => {
@@ -188687,6 +188963,9 @@ var Session3 = class _Session {
188687
188963
  },
188688
188964
  ["provideInlayHints" /* ProvideInlayHints */]: (request) => {
188689
188965
  return this.requiredResponse(this.provideInlayHints(request.arguments));
188966
+ },
188967
+ ["mapCode" /* MapCode */]: (request) => {
188968
+ return this.requiredResponse(this.mapCode(request.arguments));
188690
188969
  }
188691
188970
  }));
188692
188971
  this.host = opts.host;
@@ -189549,6 +189828,25 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
189549
189828
  };
189550
189829
  });
189551
189830
  }
189831
+ mapCode(args) {
189832
+ var _a;
189833
+ const formatOptions = this.getHostFormatOptions();
189834
+ const preferences = this.getHostPreferences();
189835
+ const { file, languageService } = this.getFileAndLanguageServiceForSyntacticOperation(args);
189836
+ const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
189837
+ const focusLocations = (_a = args.mapping.focusLocations) == null ? void 0 : _a.map((spans) => {
189838
+ return spans.map((loc) => {
189839
+ const start = scriptInfo.lineOffsetToPosition(loc.start.line, loc.start.offset);
189840
+ const end = scriptInfo.lineOffsetToPosition(loc.end.line, loc.end.offset);
189841
+ return {
189842
+ start,
189843
+ length: end - start
189844
+ };
189845
+ });
189846
+ });
189847
+ const changes = languageService.mapCode(file, args.mapping.contents, focusLocations, formatOptions, preferences);
189848
+ return this.mapTextChangesToCodeEdits(changes);
189849
+ }
189552
189850
  setCompilerOptionsForInferredProjects(args) {
189553
189851
  this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
189554
189852
  }
@@ -191973,6 +192271,7 @@ if (typeof console !== "undefined") {
191973
192271
  LexicalEnvironmentFlags,
191974
192272
  ListFormat,
191975
192273
  LogLevel,
192274
+ MapCode,
191976
192275
  MemberOverrideStatus,
191977
192276
  ModifierFlags,
191978
192277
  ModuleDetectionKind,