typescript 5.0.2 → 5.0.3

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.
@@ -19,4 +19,4 @@ and limitations under the License.
19
19
  declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
20
20
  declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
21
21
  declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
22
- declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
22
+ declare type ParameterDecorator = (target: Object, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
package/lib/tsc.js CHANGED
@@ -23,7 +23,7 @@ var __export = (target, all) => {
23
23
 
24
24
  // src/compiler/corePublic.ts
25
25
  var versionMajorMinor = "5.0";
26
- var version = "5.0.2";
26
+ var version = "5.0.3";
27
27
 
28
28
  // src/compiler/core.ts
29
29
  var emptyArray = [];
@@ -37424,7 +37424,7 @@ function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, hos
37424
37424
  }
37425
37425
  function nodeNextJsonConfigResolver(moduleName, containingFile, host) {
37426
37426
  return nodeModuleNameResolverWorker(
37427
- 8 /* Exports */,
37427
+ 30 /* NodeNextDefault */,
37428
37428
  moduleName,
37429
37429
  getDirectoryPath(containingFile),
37430
37430
  { moduleResolution: 99 /* NodeNext */ },
@@ -53129,9 +53129,10 @@ function createTypeChecker(host) {
53129
53129
  setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, emptyArray);
53130
53130
  const typeParameter = getTypeParameterFromMappedType(type);
53131
53131
  const constraintType = getConstraintTypeFromMappedType(type);
53132
- const nameType = getNameTypeFromMappedType(type.target || type);
53133
- const isFilteringMappedType = nameType && isTypeAssignableTo(nameType, typeParameter);
53134
- const templateType = getTemplateTypeFromMappedType(type.target || type);
53132
+ const mappedType = type.target || type;
53133
+ const nameType = getNameTypeFromMappedType(mappedType);
53134
+ const shouldLinkPropDeclarations = !nameType || isFilteringMappedType(mappedType);
53135
+ const templateType = getTemplateTypeFromMappedType(mappedType);
53135
53136
  const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
53136
53137
  const templateModifiers = getMappedTypeModifiers(type);
53137
53138
  const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
@@ -53168,7 +53169,7 @@ function createTypeChecker(host) {
53168
53169
  prop.links.keyType = keyType;
53169
53170
  if (modifiersProp) {
53170
53171
  prop.links.syntheticOrigin = modifiersProp;
53171
- prop.declarations = !nameType || isFilteringMappedType ? modifiersProp.declarations : void 0;
53172
+ prop.declarations = shouldLinkPropDeclarations ? modifiersProp.declarations : void 0;
53172
53173
  }
53173
53174
  members.set(propName, prop);
53174
53175
  }
@@ -53274,6 +53275,10 @@ function createTypeChecker(host) {
53274
53275
  }
53275
53276
  return false;
53276
53277
  }
53278
+ function isFilteringMappedType(type) {
53279
+ const nameType = getNameTypeFromMappedType(type);
53280
+ return !!nameType && isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type));
53281
+ }
53277
53282
  function resolveStructuredTypeMembers(type) {
53278
53283
  if (!type.members) {
53279
53284
  if (type.flags & 524288 /* Object */) {
@@ -55778,6 +55783,12 @@ function createTypeChecker(host) {
55778
55783
  i--;
55779
55784
  const source = types[i];
55780
55785
  if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) {
55786
+ if (source.flags & 262144 /* TypeParameter */ && getBaseConstraintOrType(source).flags & 1048576 /* Union */) {
55787
+ if (isTypeRelatedTo(source, getUnionType(map(types, (t) => t === source ? neverType : t)), strictSubtypeRelation)) {
55788
+ orderedRemoveItemAt(types, i);
55789
+ }
55790
+ continue;
55791
+ }
55781
55792
  const keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? find(getPropertiesOfType(source), (p) => isUnitType(getTypeOfSymbol(p))) : void 0;
55782
55793
  const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty));
55783
55794
  for (const target of types) {
@@ -56815,8 +56826,7 @@ function createTypeChecker(host) {
56815
56826
  }
56816
56827
  }
56817
56828
  if (isGenericMappedType(objectType)) {
56818
- const nameType = getNameTypeFromMappedType(objectType);
56819
- if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) {
56829
+ if (!getNameTypeFromMappedType(objectType) || isFilteringMappedType(objectType)) {
56820
56830
  return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing));
56821
56831
  }
56822
56832
  }
@@ -61315,7 +61325,7 @@ function createTypeChecker(host) {
61315
61325
  const targetHasStringIndex = some(indexInfos, (info) => info.keyType === stringType);
61316
61326
  let result2 = -1 /* True */;
61317
61327
  for (const targetInfo of indexInfos) {
61318
- const related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState);
61328
+ const related = relation !== strictSubtypeRelation && !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState);
61319
61329
  if (!related) {
61320
61330
  return 0 /* False */;
61321
61331
  }
@@ -78983,14 +78993,14 @@ function createTypeChecker(host) {
78983
78993
  markAliasReferenced(sym, id);
78984
78994
  if (getAllSymbolFlags(sym) & 111551 /* Value */) {
78985
78995
  checkExpressionCached(id);
78986
- if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
78996
+ if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
78987
78997
  error(
78988
78998
  id,
78989
78999
  node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration,
78990
79000
  idText(id)
78991
79001
  );
78992
79002
  }
78993
- } else if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax) {
79003
+ } else if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax) {
78994
79004
  error(
78995
79005
  id,
78996
79006
  node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type : Diagnostics.An_export_default_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type,
@@ -91030,10 +91040,14 @@ function transformESDecorators(context) {
91030
91040
  visitor
91031
91041
  );
91032
91042
  const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart);
91033
- const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0;
91034
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0));
91035
- addRange(statements, initializerStatements);
91036
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper));
91043
+ if (superStatementIndex >= 0) {
91044
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart));
91045
+ addRange(statements, initializerStatements);
91046
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1));
91047
+ } else {
91048
+ addRange(statements, initializerStatements);
91049
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement));
91050
+ }
91037
91051
  body = factory2.createBlock(
91038
91052
  statements,
91039
91053
  /*multiLine*/
@@ -119815,7 +119829,6 @@ function createWatchProgram(host) {
119815
119829
  );
119816
119830
  }
119817
119831
  function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions2, watchType) {
119818
- Debug.assert(configFileName);
119819
119832
  updateSharedExtendedConfigFileWatcher(
119820
119833
  forProjectPath,
119821
119834
  options,
@@ -119831,7 +119844,7 @@ function createWatchProgram(host) {
119831
119844
  if (!(projects == null ? void 0 : projects.size))
119832
119845
  return;
119833
119846
  projects.forEach((projectPath) => {
119834
- if (toPath3(configFileName) === projectPath) {
119847
+ if (configFileName && toPath3(configFileName) === projectPath) {
119835
119848
  reloadLevel = 2 /* Full */;
119836
119849
  } else {
119837
119850
  const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath);
package/lib/tsserver.js CHANGED
@@ -2286,7 +2286,7 @@ module.exports = __toCommonJS(server_exports);
2286
2286
 
2287
2287
  // src/compiler/corePublic.ts
2288
2288
  var versionMajorMinor = "5.0";
2289
- var version = "5.0.2";
2289
+ var version = "5.0.3";
2290
2290
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2291
2291
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2292
2292
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -41868,7 +41868,7 @@ function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, hos
41868
41868
  }
41869
41869
  function nodeNextJsonConfigResolver(moduleName, containingFile, host) {
41870
41870
  return nodeModuleNameResolverWorker(
41871
- 8 /* Exports */,
41871
+ 30 /* NodeNextDefault */,
41872
41872
  moduleName,
41873
41873
  getDirectoryPath(containingFile),
41874
41874
  { moduleResolution: 99 /* NodeNext */ },
@@ -57728,9 +57728,10 @@ function createTypeChecker(host) {
57728
57728
  setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, emptyArray);
57729
57729
  const typeParameter = getTypeParameterFromMappedType(type);
57730
57730
  const constraintType = getConstraintTypeFromMappedType(type);
57731
- const nameType = getNameTypeFromMappedType(type.target || type);
57732
- const isFilteringMappedType = nameType && isTypeAssignableTo(nameType, typeParameter);
57733
- const templateType = getTemplateTypeFromMappedType(type.target || type);
57731
+ const mappedType = type.target || type;
57732
+ const nameType = getNameTypeFromMappedType(mappedType);
57733
+ const shouldLinkPropDeclarations = !nameType || isFilteringMappedType(mappedType);
57734
+ const templateType = getTemplateTypeFromMappedType(mappedType);
57734
57735
  const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
57735
57736
  const templateModifiers = getMappedTypeModifiers(type);
57736
57737
  const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
@@ -57767,7 +57768,7 @@ function createTypeChecker(host) {
57767
57768
  prop.links.keyType = keyType;
57768
57769
  if (modifiersProp) {
57769
57770
  prop.links.syntheticOrigin = modifiersProp;
57770
- prop.declarations = !nameType || isFilteringMappedType ? modifiersProp.declarations : void 0;
57771
+ prop.declarations = shouldLinkPropDeclarations ? modifiersProp.declarations : void 0;
57771
57772
  }
57772
57773
  members.set(propName, prop);
57773
57774
  }
@@ -57873,6 +57874,10 @@ function createTypeChecker(host) {
57873
57874
  }
57874
57875
  return false;
57875
57876
  }
57877
+ function isFilteringMappedType(type) {
57878
+ const nameType = getNameTypeFromMappedType(type);
57879
+ return !!nameType && isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type));
57880
+ }
57876
57881
  function resolveStructuredTypeMembers(type) {
57877
57882
  if (!type.members) {
57878
57883
  if (type.flags & 524288 /* Object */) {
@@ -60377,6 +60382,12 @@ function createTypeChecker(host) {
60377
60382
  i--;
60378
60383
  const source = types[i];
60379
60384
  if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) {
60385
+ if (source.flags & 262144 /* TypeParameter */ && getBaseConstraintOrType(source).flags & 1048576 /* Union */) {
60386
+ if (isTypeRelatedTo(source, getUnionType(map(types, (t) => t === source ? neverType : t)), strictSubtypeRelation)) {
60387
+ orderedRemoveItemAt(types, i);
60388
+ }
60389
+ continue;
60390
+ }
60380
60391
  const keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? find(getPropertiesOfType(source), (p) => isUnitType(getTypeOfSymbol(p))) : void 0;
60381
60392
  const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty));
60382
60393
  for (const target of types) {
@@ -61414,8 +61425,7 @@ function createTypeChecker(host) {
61414
61425
  }
61415
61426
  }
61416
61427
  if (isGenericMappedType(objectType)) {
61417
- const nameType = getNameTypeFromMappedType(objectType);
61418
- if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) {
61428
+ if (!getNameTypeFromMappedType(objectType) || isFilteringMappedType(objectType)) {
61419
61429
  return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing));
61420
61430
  }
61421
61431
  }
@@ -65914,7 +65924,7 @@ function createTypeChecker(host) {
65914
65924
  const targetHasStringIndex = some(indexInfos, (info) => info.keyType === stringType);
65915
65925
  let result2 = -1 /* True */;
65916
65926
  for (const targetInfo of indexInfos) {
65917
- const related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState);
65927
+ const related = relation !== strictSubtypeRelation && !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState);
65918
65928
  if (!related) {
65919
65929
  return 0 /* False */;
65920
65930
  }
@@ -83582,14 +83592,14 @@ function createTypeChecker(host) {
83582
83592
  markAliasReferenced(sym, id);
83583
83593
  if (getAllSymbolFlags(sym) & 111551 /* Value */) {
83584
83594
  checkExpressionCached(id);
83585
- if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
83595
+ if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
83586
83596
  error(
83587
83597
  id,
83588
83598
  node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration,
83589
83599
  idText(id)
83590
83600
  );
83591
83601
  }
83592
- } else if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax) {
83602
+ } else if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax) {
83593
83603
  error(
83594
83604
  id,
83595
83605
  node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type : Diagnostics.An_export_default_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type,
@@ -95800,10 +95810,14 @@ function transformESDecorators(context) {
95800
95810
  visitor
95801
95811
  );
95802
95812
  const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart);
95803
- const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0;
95804
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0));
95805
- addRange(statements, initializerStatements);
95806
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper));
95813
+ if (superStatementIndex >= 0) {
95814
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart));
95815
+ addRange(statements, initializerStatements);
95816
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1));
95817
+ } else {
95818
+ addRange(statements, initializerStatements);
95819
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement));
95820
+ }
95807
95821
  body = factory2.createBlock(
95808
95822
  statements,
95809
95823
  /*multiLine*/
@@ -124707,7 +124721,6 @@ function createWatchProgram(host) {
124707
124721
  );
124708
124722
  }
124709
124723
  function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions2, watchType) {
124710
- Debug.assert(configFileName);
124711
124724
  updateSharedExtendedConfigFileWatcher(
124712
124725
  forProjectPath,
124713
124726
  options,
@@ -124723,7 +124736,7 @@ function createWatchProgram(host) {
124723
124736
  if (!(projects == null ? void 0 : projects.size))
124724
124737
  return;
124725
124738
  projects.forEach((projectPath) => {
124726
- if (toPath3(configFileName) === projectPath) {
124739
+ if (configFileName && toPath3(configFileName) === projectPath) {
124727
124740
  reloadLevel = 2 /* Full */;
124728
124741
  } else {
124729
124742
  const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath);
@@ -152027,7 +152040,7 @@ function getStringLiteralCompletionEntries(sourceFile, node, position, typeCheck
152027
152040
  const literals = contextualTypes.types.filter((literal) => !tracker.hasValue(literal.value));
152028
152041
  return { kind: 2 /* Types */, types: literals, isNewIdentifier: false };
152029
152042
  default:
152030
- return fromContextualType();
152043
+ return fromContextualType() || fromContextualType(0 /* None */);
152031
152044
  }
152032
152045
  function fromContextualType(contextFlags = 4 /* Completions */) {
152033
152046
  const types = getStringLiteralTypes(getContextualTypeFromParent(node, typeChecker, contextFlags));
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.0";
38
- version = "5.0.2";
38
+ version = "5.0.3";
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -39756,7 +39756,7 @@ ${lanes.join("\n")}
39756
39756
  }
39757
39757
  function nodeNextJsonConfigResolver(moduleName, containingFile, host) {
39758
39758
  return nodeModuleNameResolverWorker(
39759
- 8 /* Exports */,
39759
+ 30 /* NodeNextDefault */,
39760
39760
  moduleName,
39761
39761
  getDirectoryPath(containingFile),
39762
39762
  { moduleResolution: 99 /* NodeNext */ },
@@ -55538,9 +55538,10 @@ ${lanes.join("\n")}
55538
55538
  setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, emptyArray);
55539
55539
  const typeParameter = getTypeParameterFromMappedType(type);
55540
55540
  const constraintType = getConstraintTypeFromMappedType(type);
55541
- const nameType = getNameTypeFromMappedType(type.target || type);
55542
- const isFilteringMappedType = nameType && isTypeAssignableTo(nameType, typeParameter);
55543
- const templateType = getTemplateTypeFromMappedType(type.target || type);
55541
+ const mappedType = type.target || type;
55542
+ const nameType = getNameTypeFromMappedType(mappedType);
55543
+ const shouldLinkPropDeclarations = !nameType || isFilteringMappedType(mappedType);
55544
+ const templateType = getTemplateTypeFromMappedType(mappedType);
55544
55545
  const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
55545
55546
  const templateModifiers = getMappedTypeModifiers(type);
55546
55547
  const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
@@ -55577,7 +55578,7 @@ ${lanes.join("\n")}
55577
55578
  prop.links.keyType = keyType;
55578
55579
  if (modifiersProp) {
55579
55580
  prop.links.syntheticOrigin = modifiersProp;
55580
- prop.declarations = !nameType || isFilteringMappedType ? modifiersProp.declarations : void 0;
55581
+ prop.declarations = shouldLinkPropDeclarations ? modifiersProp.declarations : void 0;
55581
55582
  }
55582
55583
  members.set(propName, prop);
55583
55584
  }
@@ -55683,6 +55684,10 @@ ${lanes.join("\n")}
55683
55684
  }
55684
55685
  return false;
55685
55686
  }
55687
+ function isFilteringMappedType(type) {
55688
+ const nameType = getNameTypeFromMappedType(type);
55689
+ return !!nameType && isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type));
55690
+ }
55686
55691
  function resolveStructuredTypeMembers(type) {
55687
55692
  if (!type.members) {
55688
55693
  if (type.flags & 524288 /* Object */) {
@@ -58187,6 +58192,12 @@ ${lanes.join("\n")}
58187
58192
  i--;
58188
58193
  const source = types[i];
58189
58194
  if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) {
58195
+ if (source.flags & 262144 /* TypeParameter */ && getBaseConstraintOrType(source).flags & 1048576 /* Union */) {
58196
+ if (isTypeRelatedTo(source, getUnionType(map(types, (t) => t === source ? neverType : t)), strictSubtypeRelation)) {
58197
+ orderedRemoveItemAt(types, i);
58198
+ }
58199
+ continue;
58200
+ }
58190
58201
  const keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? find(getPropertiesOfType(source), (p) => isUnitType(getTypeOfSymbol(p))) : void 0;
58191
58202
  const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty));
58192
58203
  for (const target of types) {
@@ -59224,8 +59235,7 @@ ${lanes.join("\n")}
59224
59235
  }
59225
59236
  }
59226
59237
  if (isGenericMappedType(objectType)) {
59227
- const nameType = getNameTypeFromMappedType(objectType);
59228
- if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) {
59238
+ if (!getNameTypeFromMappedType(objectType) || isFilteringMappedType(objectType)) {
59229
59239
  return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing));
59230
59240
  }
59231
59241
  }
@@ -63724,7 +63734,7 @@ ${lanes.join("\n")}
63724
63734
  const targetHasStringIndex = some(indexInfos, (info) => info.keyType === stringType);
63725
63735
  let result2 = -1 /* True */;
63726
63736
  for (const targetInfo of indexInfos) {
63727
- const related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState);
63737
+ const related = relation !== strictSubtypeRelation && !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState);
63728
63738
  if (!related) {
63729
63739
  return 0 /* False */;
63730
63740
  }
@@ -81392,14 +81402,14 @@ ${lanes.join("\n")}
81392
81402
  markAliasReferenced(sym, id);
81393
81403
  if (getAllSymbolFlags(sym) & 111551 /* Value */) {
81394
81404
  checkExpressionCached(id);
81395
- if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
81405
+ if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
81396
81406
  error(
81397
81407
  id,
81398
81408
  node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration,
81399
81409
  idText(id)
81400
81410
  );
81401
81411
  }
81402
- } else if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax) {
81412
+ } else if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax) {
81403
81413
  error(
81404
81414
  id,
81405
81415
  node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type : Diagnostics.An_export_default_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type,
@@ -93803,10 +93813,14 @@ ${lanes.join("\n")}
93803
93813
  visitor
93804
93814
  );
93805
93815
  const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart);
93806
- const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0;
93807
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0));
93808
- addRange(statements, initializerStatements);
93809
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper));
93816
+ if (superStatementIndex >= 0) {
93817
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart));
93818
+ addRange(statements, initializerStatements);
93819
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1));
93820
+ } else {
93821
+ addRange(statements, initializerStatements);
93822
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement));
93823
+ }
93810
93824
  body = factory2.createBlock(
93811
93825
  statements,
93812
93826
  /*multiLine*/
@@ -122897,7 +122911,6 @@ ${lanes.join("\n")}
122897
122911
  );
122898
122912
  }
122899
122913
  function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions2, watchType) {
122900
- Debug.assert(configFileName);
122901
122914
  updateSharedExtendedConfigFileWatcher(
122902
122915
  forProjectPath,
122903
122916
  options,
@@ -122913,7 +122926,7 @@ ${lanes.join("\n")}
122913
122926
  if (!(projects == null ? void 0 : projects.size))
122914
122927
  return;
122915
122928
  projects.forEach((projectPath) => {
122916
- if (toPath3(configFileName) === projectPath) {
122929
+ if (configFileName && toPath3(configFileName) === projectPath) {
122917
122930
  reloadLevel = 2 /* Full */;
122918
122931
  } else {
122919
122932
  const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath);
@@ -151124,7 +151137,7 @@ ${lanes.join("\n")}
151124
151137
  const literals = contextualTypes.types.filter((literal) => !tracker.hasValue(literal.value));
151125
151138
  return { kind: 2 /* Types */, types: literals, isNewIdentifier: false };
151126
151139
  default:
151127
- return fromContextualType();
151140
+ return fromContextualType() || fromContextualType(0 /* None */);
151128
151141
  }
151129
151142
  function fromContextualType(contextFlags = 4 /* Completions */) {
151130
151143
  const types = getStringLiteralTypes(getContextualTypeFromParent(node, typeChecker, contextFlags));
package/lib/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.0";
38
- version = "5.0.2";
38
+ version = "5.0.3";
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -39756,7 +39756,7 @@ ${lanes.join("\n")}
39756
39756
  }
39757
39757
  function nodeNextJsonConfigResolver(moduleName, containingFile, host) {
39758
39758
  return nodeModuleNameResolverWorker(
39759
- 8 /* Exports */,
39759
+ 30 /* NodeNextDefault */,
39760
39760
  moduleName,
39761
39761
  getDirectoryPath(containingFile),
39762
39762
  { moduleResolution: 99 /* NodeNext */ },
@@ -55538,9 +55538,10 @@ ${lanes.join("\n")}
55538
55538
  setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, emptyArray);
55539
55539
  const typeParameter = getTypeParameterFromMappedType(type);
55540
55540
  const constraintType = getConstraintTypeFromMappedType(type);
55541
- const nameType = getNameTypeFromMappedType(type.target || type);
55542
- const isFilteringMappedType = nameType && isTypeAssignableTo(nameType, typeParameter);
55543
- const templateType = getTemplateTypeFromMappedType(type.target || type);
55541
+ const mappedType = type.target || type;
55542
+ const nameType = getNameTypeFromMappedType(mappedType);
55543
+ const shouldLinkPropDeclarations = !nameType || isFilteringMappedType(mappedType);
55544
+ const templateType = getTemplateTypeFromMappedType(mappedType);
55544
55545
  const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
55545
55546
  const templateModifiers = getMappedTypeModifiers(type);
55546
55547
  const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
@@ -55577,7 +55578,7 @@ ${lanes.join("\n")}
55577
55578
  prop.links.keyType = keyType;
55578
55579
  if (modifiersProp) {
55579
55580
  prop.links.syntheticOrigin = modifiersProp;
55580
- prop.declarations = !nameType || isFilteringMappedType ? modifiersProp.declarations : void 0;
55581
+ prop.declarations = shouldLinkPropDeclarations ? modifiersProp.declarations : void 0;
55581
55582
  }
55582
55583
  members.set(propName, prop);
55583
55584
  }
@@ -55683,6 +55684,10 @@ ${lanes.join("\n")}
55683
55684
  }
55684
55685
  return false;
55685
55686
  }
55687
+ function isFilteringMappedType(type) {
55688
+ const nameType = getNameTypeFromMappedType(type);
55689
+ return !!nameType && isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type));
55690
+ }
55686
55691
  function resolveStructuredTypeMembers(type) {
55687
55692
  if (!type.members) {
55688
55693
  if (type.flags & 524288 /* Object */) {
@@ -58187,6 +58192,12 @@ ${lanes.join("\n")}
58187
58192
  i--;
58188
58193
  const source = types[i];
58189
58194
  if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) {
58195
+ if (source.flags & 262144 /* TypeParameter */ && getBaseConstraintOrType(source).flags & 1048576 /* Union */) {
58196
+ if (isTypeRelatedTo(source, getUnionType(map(types, (t) => t === source ? neverType : t)), strictSubtypeRelation)) {
58197
+ orderedRemoveItemAt(types, i);
58198
+ }
58199
+ continue;
58200
+ }
58190
58201
  const keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? find(getPropertiesOfType(source), (p) => isUnitType(getTypeOfSymbol(p))) : void 0;
58191
58202
  const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty));
58192
58203
  for (const target of types) {
@@ -59224,8 +59235,7 @@ ${lanes.join("\n")}
59224
59235
  }
59225
59236
  }
59226
59237
  if (isGenericMappedType(objectType)) {
59227
- const nameType = getNameTypeFromMappedType(objectType);
59228
- if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) {
59238
+ if (!getNameTypeFromMappedType(objectType) || isFilteringMappedType(objectType)) {
59229
59239
  return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing));
59230
59240
  }
59231
59241
  }
@@ -63724,7 +63734,7 @@ ${lanes.join("\n")}
63724
63734
  const targetHasStringIndex = some(indexInfos, (info) => info.keyType === stringType);
63725
63735
  let result2 = -1 /* True */;
63726
63736
  for (const targetInfo of indexInfos) {
63727
- const related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState);
63737
+ const related = relation !== strictSubtypeRelation && !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState);
63728
63738
  if (!related) {
63729
63739
  return 0 /* False */;
63730
63740
  }
@@ -81392,14 +81402,14 @@ ${lanes.join("\n")}
81392
81402
  markAliasReferenced(sym, id);
81393
81403
  if (getAllSymbolFlags(sym) & 111551 /* Value */) {
81394
81404
  checkExpressionCached(id);
81395
- if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
81405
+ if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
81396
81406
  error(
81397
81407
  id,
81398
81408
  node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration,
81399
81409
  idText(id)
81400
81410
  );
81401
81411
  }
81402
- } else if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax) {
81412
+ } else if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax) {
81403
81413
  error(
81404
81414
  id,
81405
81415
  node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type : Diagnostics.An_export_default_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type,
@@ -93803,10 +93813,14 @@ ${lanes.join("\n")}
93803
93813
  visitor
93804
93814
  );
93805
93815
  const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart);
93806
- const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0;
93807
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0));
93808
- addRange(statements, initializerStatements);
93809
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper));
93816
+ if (superStatementIndex >= 0) {
93817
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart));
93818
+ addRange(statements, initializerStatements);
93819
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1));
93820
+ } else {
93821
+ addRange(statements, initializerStatements);
93822
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement));
93823
+ }
93810
93824
  body = factory2.createBlock(
93811
93825
  statements,
93812
93826
  /*multiLine*/
@@ -122897,7 +122911,6 @@ ${lanes.join("\n")}
122897
122911
  );
122898
122912
  }
122899
122913
  function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions2, watchType) {
122900
- Debug.assert(configFileName);
122901
122914
  updateSharedExtendedConfigFileWatcher(
122902
122915
  forProjectPath,
122903
122916
  options,
@@ -122913,7 +122926,7 @@ ${lanes.join("\n")}
122913
122926
  if (!(projects == null ? void 0 : projects.size))
122914
122927
  return;
122915
122928
  projects.forEach((projectPath) => {
122916
- if (toPath3(configFileName) === projectPath) {
122929
+ if (configFileName && toPath3(configFileName) === projectPath) {
122917
122930
  reloadLevel = 2 /* Full */;
122918
122931
  } else {
122919
122932
  const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath);
@@ -151138,7 +151151,7 @@ ${lanes.join("\n")}
151138
151151
  const literals = contextualTypes.types.filter((literal) => !tracker.hasValue(literal.value));
151139
151152
  return { kind: 2 /* Types */, types: literals, isNewIdentifier: false };
151140
151153
  default:
151141
- return fromContextualType();
151154
+ return fromContextualType() || fromContextualType(0 /* None */);
151142
151155
  }
151143
151156
  function fromContextualType(contextFlags = 4 /* Completions */) {
151144
151157
  const types = getStringLiteralTypes(getContextualTypeFromParent(node, typeChecker, contextFlags));
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.0";
57
- var version = "5.0.2";
57
+ var version = "5.0.3";
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.0.2",
5
+ "version": "5.0.3",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [