typescript 5.0.0-dev.20230111 → 5.0.0-dev.20230112

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
@@ -42,7 +42,7 @@ var ts = (() => {
42
42
  "src/compiler/corePublic.ts"() {
43
43
  "use strict";
44
44
  versionMajorMinor = "5.0";
45
- version = `${versionMajorMinor}.0-dev.20230111`;
45
+ version = `${versionMajorMinor}.0-dev.20230112`;
46
46
  Comparison = /* @__PURE__ */ ((Comparison3) => {
47
47
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
48
48
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -9527,7 +9527,8 @@ ${lanes.join("\n")}
9527
9527
  return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion);
9528
9528
  }
9529
9529
  function isIdentifierPart(ch, languageVersion, identifierVariant) {
9530
- return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || (identifierVariant === 1 /* JSX */ ? ch === 45 /* minus */ || ch === 58 /* colon */ : false) || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
9530
+ return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || // "-" and ":" are valid in JSX Identifiers
9531
+ (identifierVariant === 1 /* JSX */ ? ch === 45 /* minus */ || ch === 58 /* colon */ : false) || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
9531
9532
  }
9532
9533
  function isIdentifierText(name, languageVersion, identifierVariant) {
9533
9534
  let ch = codePointAt(name, 0);
@@ -34991,7 +34992,8 @@ ${lanes.join("\n")}
34991
34992
  if (returnValue) {
34992
34993
  result[keyText] = value;
34993
34994
  }
34994
- if (jsonConversionNotifier && (parentOption || isRootOptionMap(knownOptions))) {
34995
+ if (jsonConversionNotifier && // Current callbacks are only on known parent option or if we are setting values in the root
34996
+ (parentOption || isRootOptionMap(knownOptions))) {
34995
34997
  const isValidOptionValue = isCompilerOptionsValue(option, value);
34996
34998
  if (parentOption) {
34997
34999
  if (isValidOptionValue) {
@@ -42967,8 +42969,12 @@ ${lanes.join("\n")}
42967
42969
  return false;
42968
42970
  }
42969
42971
  if (currentFlow === unreachableFlow) {
42970
- const reportError = isStatementButNotDeclaration(node) && node.kind !== 239 /* EmptyStatement */ || // report error on class declarations
42971
- node.kind === 260 /* ClassDeclaration */ || node.kind === 264 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node);
42972
+ const reportError = (
42973
+ // report error on all statements except empty ones
42974
+ isStatementButNotDeclaration(node) && node.kind !== 239 /* EmptyStatement */ || // report error on class declarations
42975
+ node.kind === 260 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set
42976
+ node.kind === 264 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)
42977
+ );
42972
42978
  if (reportError) {
42973
42979
  currentFlow = reportedUnreachableFlow;
42974
42980
  if (!options.allowUnreachableCode) {
@@ -48731,7 +48737,8 @@ ${lanes.join("\n")}
48731
48737
  const isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol
48732
48738
  forEach(symbol.declarations, (declaration) => declaration.parent.kind === 308 /* SourceFile */ || declaration.parent.kind === 265 /* ModuleBlock */));
48733
48739
  if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
48734
- return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a4 = context.visitedTypes) == null ? void 0 : _a4.has(typeId))) && (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration));
48740
+ return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a4 = context.visitedTypes) == null ? void 0 : _a4.has(typeId))) && // it is type of the symbol uses itself recursively
48741
+ (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration));
48735
48742
  }
48736
48743
  }
48737
48744
  }
@@ -48823,7 +48830,9 @@ ${lanes.join("\n")}
48823
48830
  const abstractSignatures = filter(resolved.constructSignatures, (signature) => !!(signature.flags & 4 /* Abstract */));
48824
48831
  if (some(abstractSignatures)) {
48825
48832
  const types = map(abstractSignatures, getOrCreateTypeFromSignature);
48826
- const typeElementCount = resolved.callSignatures.length + (resolved.constructSignatures.length - abstractSignatures.length) + resolved.indexInfos.length + (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? countWhere(resolved.properties, (p) => !(p.flags & 4194304 /* Prototype */)) : length(resolved.properties));
48833
+ const typeElementCount = resolved.callSignatures.length + (resolved.constructSignatures.length - abstractSignatures.length) + resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per
48834
+ // the logic in `createTypeNodesFromResolvedType`.
48835
+ (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? countWhere(resolved.properties, (p) => !(p.flags & 4194304 /* Prototype */)) : length(resolved.properties));
48827
48836
  if (typeElementCount) {
48828
48837
  types.push(getResolvedTypeWithoutAbstractConstructSignatures(resolved));
48829
48838
  }
@@ -49485,9 +49494,11 @@ ${lanes.join("\n")}
49485
49494
  if (accessibleSymbolChain) {
49486
49495
  return accessibleSymbolChain;
49487
49496
  }
49488
- if (// If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
49489
- endOfChain || // If a parent symbol is an anonymous type, don't write it.
49490
- !(symbol2.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) {
49497
+ if (
49498
+ // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
49499
+ endOfChain || // If a parent symbol is an anonymous type, don't write it.
49500
+ !(symbol2.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))
49501
+ ) {
49491
49502
  if (!endOfChain && !yieldModuleSymbol && !!forEach(symbol2.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
49492
49503
  return;
49493
49504
  }
@@ -50109,7 +50120,8 @@ ${lanes.join("\n")}
50109
50120
  }
50110
50121
  if (isLiteralImportTypeNode(node)) {
50111
50122
  const nodeSymbol = getNodeLinks(node).resolvedSymbol;
50112
- if (isInJSDoc(node) && nodeSymbol && (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
50123
+ if (isInJSDoc(node) && nodeSymbol && // The import type resolved using jsdoc fallback logic
50124
+ (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
50113
50125
  !(length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
50114
50126
  return setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
50115
50127
  }
@@ -51626,8 +51638,10 @@ ${lanes.join("\n")}
51626
51638
  }
51627
51639
  }
51628
51640
  function getNameOfSymbolAsWritten(symbol, context) {
51629
- if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && (!(context.flags & 16777216 /* InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default`
51630
- !symbol.declarations || context.enclosingDeclaration && findAncestor(symbol.declarations[0], isDefaultBindingContext) !== findAncestor(context.enclosingDeclaration, isDefaultBindingContext))) {
51641
+ if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default`
51642
+ (!(context.flags & 16777216 /* InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default`
51643
+ !symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default`
51644
+ context.enclosingDeclaration && findAncestor(symbol.declarations[0], isDefaultBindingContext) !== findAncestor(context.enclosingDeclaration, isDefaultBindingContext))) {
51631
51645
  return "default";
51632
51646
  }
51633
51647
  if (symbol.declarations && symbol.declarations.length) {
@@ -52954,7 +52968,10 @@ ${lanes.join("\n")}
52954
52968
  function getWriteTypeOfSymbol(symbol) {
52955
52969
  const checkFlags = getCheckFlags(symbol);
52956
52970
  if (symbol.flags & 4 /* Property */) {
52957
- return checkFlags & 2 /* SyntheticProperty */ ? checkFlags & 65536 /* DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : symbol.links.writeType || symbol.links.type : getTypeOfSymbol(symbol);
52971
+ return checkFlags & 2 /* SyntheticProperty */ ? checkFlags & 65536 /* DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : (
52972
+ // NOTE: cast to TransientSymbol should be safe because only TransientSymbols can have CheckFlags.SyntheticProperty
52973
+ symbol.links.writeType || symbol.links.type
52974
+ ) : getTypeOfSymbol(symbol);
52958
52975
  }
52959
52976
  if (symbol.flags & 98304 /* Accessor */) {
52960
52977
  return checkFlags & 1 /* Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol);
@@ -61371,7 +61388,11 @@ ${lanes.join("\n")}
61371
61388
  if (variances === emptyArray) {
61372
61389
  return 1 /* Unknown */;
61373
61390
  }
61374
- const varianceResult = relateVariances(source2.aliasTypeArguments, target2.aliasTypeArguments, variances, intersectionState);
61391
+ const params = getSymbolLinks(source2.aliasSymbol).typeParameters;
61392
+ const minParams = getMinTypeArgumentCount(params);
61393
+ const sourceTypes = fillMissingTypeArguments(source2.aliasTypeArguments, params, minParams, isInJSFile(source2.aliasSymbol.valueDeclaration));
61394
+ const targetTypes = fillMissingTypeArguments(target2.aliasTypeArguments, params, minParams, isInJSFile(source2.aliasSymbol.valueDeclaration));
61395
+ const varianceResult = relateVariances(sourceTypes, targetTypes, variances, intersectionState);
61375
61396
  if (varianceResult !== void 0) {
61376
61397
  return varianceResult;
61377
61398
  }
@@ -63828,7 +63849,11 @@ ${lanes.join("\n")}
63828
63849
  }
63829
63850
  if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) {
63830
63851
  if (source.aliasTypeArguments) {
63831
- inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
63852
+ const params = getSymbolLinks(source.aliasSymbol).typeParameters;
63853
+ const minParams = getMinTypeArgumentCount(params);
63854
+ const sourceTypes = fillMissingTypeArguments(source.aliasTypeArguments, params, minParams, isInJSFile(source.aliasSymbol.valueDeclaration));
63855
+ const targetTypes = fillMissingTypeArguments(target.aliasTypeArguments, params, minParams, isInJSFile(source.aliasSymbol.valueDeclaration));
63856
+ inferFromTypeArguments(sourceTypes, targetTypes, getAliasVariances(source.aliasSymbol));
63832
63857
  }
63833
63858
  return;
63834
63859
  }
@@ -66235,18 +66260,20 @@ ${lanes.join("\n")}
66235
66260
  return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */);
66236
66261
  }
66237
66262
  function narrowTypeByTypeFacts(type, impliedType, facts) {
66238
- return mapType(type, (t) => // We first check if a constituent is a subtype of the implied type. If so, we either keep or eliminate
66239
- // the constituent based on its type facts. We use the strict subtype relation because it treats `object`
66240
- // as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
66241
- // but are classified as "function" according to `typeof`.
66242
- isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? getTypeFacts(t) & facts ? t : neverType : (
66243
- // We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
66244
- // type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
66245
- isTypeSubtypeOf(impliedType, t) ? impliedType : (
66246
- // Neither the constituent nor the implied type is a subtype of the other, however their domains may still
66247
- // overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
66248
- // possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
66249
- getTypeFacts(t) & facts ? getIntersectionType([t, impliedType]) : neverType
66263
+ return mapType(type, (t) => (
66264
+ // We first check if a constituent is a subtype of the implied type. If so, we either keep or eliminate
66265
+ // the constituent based on its type facts. We use the strict subtype relation because it treats `object`
66266
+ // as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
66267
+ // but are classified as "function" according to `typeof`.
66268
+ isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? getTypeFacts(t) & facts ? t : neverType : (
66269
+ // We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
66270
+ // type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
66271
+ isTypeSubtypeOf(impliedType, t) ? impliedType : (
66272
+ // Neither the constituent nor the implied type is a subtype of the other, however their domains may still
66273
+ // overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
66274
+ // possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
66275
+ getTypeFacts(t) & facts ? getIntersectionType([t, impliedType]) : neverType
66276
+ )
66250
66277
  )
66251
66278
  ));
66252
66279
  }
@@ -73817,7 +73844,8 @@ ${lanes.join("\n")}
73817
73844
  }
73818
73845
  }
73819
73846
  function isIndirectCall(node) {
73820
- return node.parent.kind === 214 /* ParenthesizedExpression */ && isNumericLiteral(node.left) && node.left.text === "0" && (isCallExpression(node.parent.parent) && node.parent.parent.expression === node.parent || node.parent.parent.kind === 212 /* TaggedTemplateExpression */) && (isAccessExpression(node.right) || isIdentifier(node.right) && node.right.escapedText === "eval");
73847
+ return node.parent.kind === 214 /* ParenthesizedExpression */ && isNumericLiteral(node.left) && node.left.text === "0" && (isCallExpression(node.parent.parent) && node.parent.parent.expression === node.parent || node.parent.parent.kind === 212 /* TaggedTemplateExpression */) && // special-case for "eval" because it's the only non-access case where an indirect call actually affects behavior.
73848
+ (isAccessExpression(node.right) || isIdentifier(node.right) && node.right.escapedText === "eval");
73821
73849
  }
73822
73850
  function checkForDisallowedESSymbolOperand(operator2) {
73823
73851
  const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : void 0;
@@ -80902,7 +80930,12 @@ ${lanes.join("\n")}
80902
80930
  return false;
80903
80931
  const symbol = getSymbolOfDeclaration(node);
80904
80932
  const signaturesOfSymbol = getSignaturesOfSymbol(symbol);
80905
- return signaturesOfSymbol.length > 1 || signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node;
80933
+ return signaturesOfSymbol.length > 1 || // If there is single signature for the symbol, it is overload if that signature isn't coming from the node
80934
+ // e.g.: function foo(a: string): string;
80935
+ // function foo(a: any) { // This is implementation of the overloads
80936
+ // return a;
80937
+ // }
80938
+ signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node;
80906
80939
  }
80907
80940
  return false;
80908
80941
  }
@@ -111760,7 +111793,8 @@ ${lanes.join("\n")}
111760
111793
  const oldSourceFiles = oldProgram.getSourceFiles();
111761
111794
  for (const oldSourceFile of oldSourceFiles) {
111762
111795
  const newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
111763
- if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path) {
111796
+ if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || // old file wasn't redirect but new file is
111797
+ oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path) {
111764
111798
  host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
111765
111799
  }
111766
111800
  }
@@ -116646,7 +116680,8 @@ ${lanes.join("\n")}
116646
116680
  const name = loader.nameAndMode.getName(entry);
116647
116681
  const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
116648
116682
  let resolution = resolutionsInFile.get(name, mode);
116649
- if (!seenNamesInFile.has(name, mode) && unmatchedRedirects || !resolution || resolution.isInvalidated || hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution)) {
116683
+ if (!seenNamesInFile.has(name, mode) && unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate
116684
+ hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution)) {
116650
116685
  const existingResolution = resolution;
116651
116686
  resolution = loader.resolve(name, mode);
116652
116687
  if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
@@ -122319,7 +122354,11 @@ ${lanes.join("\n")}
122319
122354
  return n;
122320
122355
  }
122321
122356
  return firstDefined(n.getChildren(sourceFile), (child) => {
122322
- const shouldDiveInChildNode = child.pos <= previousToken.pos && child.end > previousToken.end || child.pos === previousToken.end;
122357
+ const shouldDiveInChildNode = (
122358
+ // previous token is enclosed somewhere in the child
122359
+ child.pos <= previousToken.pos && child.end > previousToken.end || // previous token ends exactly at the beginning of child
122360
+ child.pos === previousToken.end
122361
+ );
122323
122362
  return shouldDiveInChildNode && nodeHasTokens(child, sourceFile) ? find2(child) : void 0;
122324
122363
  });
122325
122364
  }
@@ -135990,15 +136029,17 @@ ${lanes.join("\n")}
135990
136029
  return fixes[0];
135991
136030
  }
135992
136031
  return fixes.reduce(
135993
- (best, fix) => // Takes true branch of conditional if `fix` is better than `best`
135994
- compareModuleSpecifiers(
135995
- fix,
135996
- best,
135997
- sourceFile,
135998
- program,
135999
- packageJsonImportFilter.allowsImportingSpecifier,
136000
- (fileName) => toPath(fileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host))
136001
- ) === -1 /* LessThan */ ? fix : best
136032
+ (best, fix) => (
136033
+ // Takes true branch of conditional if `fix` is better than `best`
136034
+ compareModuleSpecifiers(
136035
+ fix,
136036
+ best,
136037
+ sourceFile,
136038
+ program,
136039
+ packageJsonImportFilter.allowsImportingSpecifier,
136040
+ (fileName) => toPath(fileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host))
136041
+ ) === -1 /* LessThan */ ? fix : best
136042
+ )
136002
136043
  );
136003
136044
  }
136004
136045
  function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath3) {
@@ -145494,7 +145535,10 @@ ${lanes.join("\n")}
145494
145535
  return containingNodeKind === 257 /* VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken2) || containingNodeKind === 240 /* VariableStatement */ || containingNodeKind === 263 /* EnumDeclaration */ || // enum a { foo, |
145495
145536
  isFunctionLikeButNotConstructor(containingNodeKind) || containingNodeKind === 261 /* InterfaceDeclaration */ || // interface A<T, |
145496
145537
  containingNodeKind === 204 /* ArrayBindingPattern */ || // var [x, y|
145497
- containingNodeKind === 262 /* TypeAliasDeclaration */ || isClassLike(parent2) && !!parent2.typeParameters && parent2.typeParameters.end >= contextToken2.pos;
145538
+ containingNodeKind === 262 /* TypeAliasDeclaration */ || // type Map, K, |
145539
+ // class A<T, |
145540
+ // var C = class D<T, |
145541
+ isClassLike(parent2) && !!parent2.typeParameters && parent2.typeParameters.end >= contextToken2.pos;
145498
145542
  case 24 /* DotToken */:
145499
145543
  return containingNodeKind === 204 /* ArrayBindingPattern */;
145500
145544
  case 58 /* ColonToken */:
@@ -147511,8 +147555,10 @@ ${lanes.join("\n")}
147511
147555
  return map2;
147512
147556
  }
147513
147557
  function forEachPossibleImportOrExportStatement(sourceFileLike, action) {
147514
- return forEach(sourceFileLike.kind === 308 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, (statement) => // TODO: GH#18217
147515
- action(statement) || isAmbientModuleDeclaration(statement) && forEach(statement.body && statement.body.statements, action));
147558
+ return forEach(sourceFileLike.kind === 308 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, (statement) => (
147559
+ // TODO: GH#18217
147560
+ action(statement) || isAmbientModuleDeclaration(statement) && forEach(statement.body && statement.body.statements, action)
147561
+ ));
147516
147562
  }
147517
147563
  function forEachImport(sourceFile, action) {
147518
147564
  if (sourceFile.externalModuleIndicator || sourceFile.imports !== void 0) {
@@ -147781,7 +147827,9 @@ ${lanes.join("\n")}
147781
147827
  return propertyName ? getContextNode(propertyName.parent) : void 0;
147782
147828
  }
147783
147829
  if (node.parent.name === node || // node is name of declaration, use parent
147784
- isConstructorDeclaration(node.parent) || isExportAssignment(node.parent) || (isImportOrExportSpecifier(node.parent) || isBindingElement(node.parent)) && node.parent.propertyName === node || node.kind === 88 /* DefaultKeyword */ && hasSyntacticModifier(node.parent, 1025 /* ExportDefault */)) {
147830
+ isConstructorDeclaration(node.parent) || isExportAssignment(node.parent) || // Property name of the import export specifier or binding pattern, use parent
147831
+ (isImportOrExportSpecifier(node.parent) || isBindingElement(node.parent)) && node.parent.propertyName === node || // Is default export
147832
+ node.kind === 88 /* DefaultKeyword */ && hasSyntacticModifier(node.parent, 1025 /* ExportDefault */)) {
147785
147833
  return getContextNode(node.parent);
147786
147834
  }
147787
147835
  return void 0;
@@ -147835,11 +147883,13 @@ ${lanes.join("\n")}
147835
147883
  const checker = program.getTypeChecker();
147836
147884
  const adjustedNode = Core.getAdjustedNode(node, options);
147837
147885
  const symbol = isDefinitionForReference(adjustedNode) ? checker.getSymbolAtLocation(adjustedNode) : void 0;
147838
- return !referencedSymbols || !referencedSymbols.length ? void 0 : mapDefined(referencedSymbols, ({ definition, references }) => // Only include referenced symbols that have a valid definition.
147839
- definition && {
147840
- definition: checker.runWithCancellationToken(cancellationToken, (checker2) => definitionToReferencedSymbolDefinitionInfo(definition, checker2, node)),
147841
- references: references.map((r) => toReferencedSymbolEntry(r, symbol))
147842
- });
147886
+ return !referencedSymbols || !referencedSymbols.length ? void 0 : mapDefined(referencedSymbols, ({ definition, references }) => (
147887
+ // Only include referenced symbols that have a valid definition.
147888
+ definition && {
147889
+ definition: checker.runWithCancellationToken(cancellationToken, (checker2) => definitionToReferencedSymbolDefinitionInfo(definition, checker2, node)),
147890
+ references: references.map((r) => toReferencedSymbolEntry(r, symbol))
147891
+ }
147892
+ ));
147843
147893
  }
147844
147894
  function isDefinitionForReference(node) {
147845
147895
  return node.kind === 88 /* DefaultKeyword */ || !!getDeclarationFromName(node) || isLiteralComputedPropertyDeclarationName(node) || node.kind === 135 /* ConstructorKeyword */ && isConstructorDeclaration(node.parent);
@@ -148877,8 +148927,10 @@ ${lanes.join("\n")}
148877
148927
  function getLabelReferencesInNode(container, targetLabel) {
148878
148928
  const sourceFile = container.getSourceFile();
148879
148929
  const labelName = targetLabel.text;
148880
- const references = mapDefined(getPossibleSymbolReferenceNodes(sourceFile, labelName, container), (node) => // Only pick labels that are either the target label, or have a target that is the target label
148881
- node === targetLabel || isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel ? nodeEntry(node) : void 0);
148930
+ const references = mapDefined(getPossibleSymbolReferenceNodes(sourceFile, labelName, container), (node) => (
148931
+ // Only pick labels that are either the target label, or have a target that is the target label
148932
+ node === targetLabel || isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel ? nodeEntry(node) : void 0
148933
+ ));
148882
148934
  return [{ definition: { type: 1 /* Label */, node: targetLabel }, references }];
148883
148935
  }
148884
148936
  function isValidReferencePosition(node, searchSymbolName) {
@@ -158019,7 +158071,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
158019
158071
  hasAddedSymbolInfo = true;
158020
158072
  hasMultipleSignatures = allSignatures.length > 1;
158021
158073
  }
158022
- } else if (isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */) || location.kind === 135 /* ConstructorKeyword */ && location.parent.kind === 173 /* Constructor */) {
158074
+ } else if (isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */) || // name of function declaration
158075
+ location.kind === 135 /* ConstructorKeyword */ && location.parent.kind === 173 /* Constructor */) {
158023
158076
  const functionDeclaration = location.parent;
158024
158077
  const locationIsSymbolDeclaration = symbol.declarations && find(symbol.declarations, (declaration) => declaration === (location.kind === 135 /* ConstructorKeyword */ ? functionDeclaration.parent : functionDeclaration));
158025
158078
  if (locationIsSymbolDeclaration) {
@@ -160357,18 +160410,12 @@ ${options.prefix}` : "\n" : options.prefix
160357
160410
  rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */),
160358
160411
  rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */),
160359
160412
  rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */),
160360
- rule(
160361
- "NoSpaceAfterCloseAngularBracket",
160362
- 31 /* GreaterThanToken */,
160363
- [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */],
160364
- [
160365
- isNonJsxSameLineTokenContext,
160366
- isTypeArgumentOrParameterOrAssertionContext,
160367
- isNotFunctionDeclContext
160368
- /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/
160369
- ],
160370
- 16 /* DeleteSpace */
160371
- ),
160413
+ rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [
160414
+ isNonJsxSameLineTokenContext,
160415
+ isTypeArgumentOrParameterOrAssertionContext,
160416
+ isNotFunctionDeclContext,
160417
+ isNonTypeAssertionContext
160418
+ ], 16 /* DeleteSpace */),
160372
160419
  // decorators
160373
160420
  rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */),
160374
160421
  rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */),
@@ -160801,6 +160848,9 @@ ${options.prefix}` : "\n" : options.prefix
160801
160848
  function isTypeAssertionContext(context) {
160802
160849
  return context.contextNode.kind === 213 /* TypeAssertionExpression */;
160803
160850
  }
160851
+ function isNonTypeAssertionContext(context) {
160852
+ return !isTypeAssertionContext(context);
160853
+ }
160804
160854
  function isVoidOpContext(context) {
160805
160855
  return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 219 /* VoidExpression */;
160806
160856
  }
@@ -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 = `${versionMajorMinor}.0-dev.20230111`;
57
+ var version = `${versionMajorMinor}.0-dev.20230112`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -7791,7 +7791,8 @@ function isIdentifierStart(ch, languageVersion) {
7791
7791
  return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion);
7792
7792
  }
7793
7793
  function isIdentifierPart(ch, languageVersion, identifierVariant) {
7794
- return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || (identifierVariant === 1 /* JSX */ ? ch === 45 /* minus */ || ch === 58 /* colon */ : false) || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
7794
+ return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || // "-" and ":" are valid in JSX Identifiers
7795
+ (identifierVariant === 1 /* JSX */ ? ch === 45 /* minus */ || ch === 58 /* colon */ : false) || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
7795
7796
  }
7796
7797
  function isIdentifierText(name, languageVersion, identifierVariant) {
7797
7798
  let ch = codePointAt(name, 0);
@@ -27760,7 +27761,8 @@ function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue,
27760
27761
  if (returnValue) {
27761
27762
  result[keyText] = value;
27762
27763
  }
27763
- if (jsonConversionNotifier && (parentOption || isRootOptionMap(knownOptions))) {
27764
+ if (jsonConversionNotifier && // Current callbacks are only on known parent option or if we are setting values in the root
27765
+ (parentOption || isRootOptionMap(knownOptions))) {
27764
27766
  const isValidOptionValue = isCompilerOptionsValue(option, value);
27765
27767
  if (parentOption) {
27766
27768
  if (isValidOptionValue) {
@@ -32352,8 +32354,12 @@ function createBinder() {
32352
32354
  return false;
32353
32355
  }
32354
32356
  if (currentFlow === unreachableFlow) {
32355
- const reportError = isStatementButNotDeclaration(node) && node.kind !== 239 /* EmptyStatement */ || // report error on class declarations
32356
- node.kind === 260 /* ClassDeclaration */ || node.kind === 264 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node);
32357
+ const reportError = (
32358
+ // report error on all statements except empty ones
32359
+ isStatementButNotDeclaration(node) && node.kind !== 239 /* EmptyStatement */ || // report error on class declarations
32360
+ node.kind === 260 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set
32361
+ node.kind === 264 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)
32362
+ );
32357
32363
  if (reportError) {
32358
32364
  currentFlow = reportedUnreachableFlow;
32359
32365
  if (!options.allowUnreachableCode) {
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.0-dev.20230111",
5
+ "version": "5.0.0-dev.20230112",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [