@typescript-deploys/pr-build 5.4.0-pr-56392-10 → 5.4.0-pr-56859-8

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/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.4";
21
- var version = `${versionMajorMinor}.0-insiders.20240104`;
21
+ var version = `${versionMajorMinor}.0-insiders.20240105`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -45010,11 +45010,7 @@ function createTypeChecker(host) {
45010
45010
  if (errorBindingElement) {
45011
45011
  return findAncestor(errorBindingElement, isBindingElement) !== findAncestor(declaration, isBindingElement) || declaration.pos < errorBindingElement.pos;
45012
45012
  }
45013
- const rootDeclaration = getRootDeclaration(declaration);
45014
- if (rootDeclaration.kind !== 260 /* VariableDeclaration */) {
45015
- return true;
45016
- }
45017
- return isBlockScopedNameDeclaredBeforeUse(rootDeclaration, usage);
45013
+ return isBlockScopedNameDeclaredBeforeUse(getAncestor(declaration, 260 /* VariableDeclaration */), usage);
45018
45014
  } else if (declaration.kind === 260 /* VariableDeclaration */) {
45019
45015
  return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
45020
45016
  } else if (isClassLike(declaration)) {
@@ -65339,9 +65335,29 @@ function createTypeChecker(host) {
65339
65335
  /*ignoreErrors*/
65340
65336
  true
65341
65337
  );
65342
- if (!symbol || symbol.valueDeclaration && !isBlockScopedNameDeclaredBeforeUse(symbol.valueDeclaration, node))
65338
+ if (!symbol || !(isConstantVariable(symbol) || symbol.flags & 8 /* EnumMember */))
65339
+ return void 0;
65340
+ const declaration = symbol.valueDeclaration;
65341
+ if (declaration === void 0)
65343
65342
  return void 0;
65344
- return tryGetNameFromType(getTypeOfExpression(node));
65343
+ const type = tryGetTypeFromEffectiveTypeNode(declaration);
65344
+ if (type) {
65345
+ const name = tryGetNameFromType(type);
65346
+ if (name !== void 0) {
65347
+ return name;
65348
+ }
65349
+ }
65350
+ if (hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node)) {
65351
+ const initializer = getEffectiveInitializer(declaration);
65352
+ if (initializer) {
65353
+ const initializerType = isBindingPattern(declaration.parent) ? getTypeForBindingElement(declaration) : getTypeOfExpression(initializer);
65354
+ return initializerType && tryGetNameFromType(initializerType);
65355
+ }
65356
+ if (isEnumMember(declaration)) {
65357
+ return getTextOfPropertyName(declaration.name);
65358
+ }
65359
+ }
65360
+ return void 0;
65345
65361
  }
65346
65362
  function containsMatchingReference(source, target) {
65347
65363
  while (isAccessExpression(source)) {
@@ -73871,6 +73887,9 @@ function createTypeChecker(host) {
73871
73887
  let fallbackReturnType = voidType;
73872
73888
  if (func.body.kind !== 241 /* Block */) {
73873
73889
  returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */);
73890
+ if (isConstContext(func.body)) {
73891
+ returnType = getRegularTypeOfLiteralType(returnType);
73892
+ }
73874
73893
  if (isAsync) {
73875
73894
  returnType = unwrapAwaitedType(checkAwaitedType(
73876
73895
  returnType,
@@ -74003,7 +74022,10 @@ function createTypeChecker(host) {
74003
74022
  const nextTypes = [];
74004
74023
  const isAsync = (getFunctionFlags(func) & 2 /* Async */) !== 0;
74005
74024
  forEachYieldExpression(func.body, (yieldExpression) => {
74006
- const yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
74025
+ let yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
74026
+ if (yieldExpression.expression && isConstContext(yieldExpression.expression)) {
74027
+ yieldExpressionType = getRegularTypeOfLiteralType(yieldExpressionType);
74028
+ }
74007
74029
  pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync));
74008
74030
  let nextType;
74009
74031
  if (yieldExpression.asteriskToken) {
@@ -74118,7 +74140,7 @@ function createTypeChecker(host) {
74118
74140
  if (type.flags & 131072 /* Never */) {
74119
74141
  hasReturnOfTypeNever = true;
74120
74142
  }
74121
- pushIfUnique(aggregatedTypes, type);
74143
+ pushIfUnique(aggregatedTypes, isConstContext(expr) ? getRegularTypeOfLiteralType(type) : type);
74122
74144
  } else {
74123
74145
  hasReturnWithNoExpression = true;
74124
74146
  }
package/lib/tsserver.js CHANGED
@@ -2341,7 +2341,7 @@ module.exports = __toCommonJS(server_exports);
2341
2341
 
2342
2342
  // src/compiler/corePublic.ts
2343
2343
  var versionMajorMinor = "5.4";
2344
- var version = `${versionMajorMinor}.0-insiders.20240104`;
2344
+ var version = `${versionMajorMinor}.0-insiders.20240105`;
2345
2345
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2346
2346
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2347
2347
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -49738,11 +49738,7 @@ function createTypeChecker(host) {
49738
49738
  if (errorBindingElement) {
49739
49739
  return findAncestor(errorBindingElement, isBindingElement) !== findAncestor(declaration, isBindingElement) || declaration.pos < errorBindingElement.pos;
49740
49740
  }
49741
- const rootDeclaration = getRootDeclaration(declaration);
49742
- if (rootDeclaration.kind !== 260 /* VariableDeclaration */) {
49743
- return true;
49744
- }
49745
- return isBlockScopedNameDeclaredBeforeUse(rootDeclaration, usage);
49741
+ return isBlockScopedNameDeclaredBeforeUse(getAncestor(declaration, 260 /* VariableDeclaration */), usage);
49746
49742
  } else if (declaration.kind === 260 /* VariableDeclaration */) {
49747
49743
  return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
49748
49744
  } else if (isClassLike(declaration)) {
@@ -70067,9 +70063,29 @@ function createTypeChecker(host) {
70067
70063
  /*ignoreErrors*/
70068
70064
  true
70069
70065
  );
70070
- if (!symbol || symbol.valueDeclaration && !isBlockScopedNameDeclaredBeforeUse(symbol.valueDeclaration, node))
70066
+ if (!symbol || !(isConstantVariable(symbol) || symbol.flags & 8 /* EnumMember */))
70067
+ return void 0;
70068
+ const declaration = symbol.valueDeclaration;
70069
+ if (declaration === void 0)
70071
70070
  return void 0;
70072
- return tryGetNameFromType(getTypeOfExpression(node));
70071
+ const type = tryGetTypeFromEffectiveTypeNode(declaration);
70072
+ if (type) {
70073
+ const name = tryGetNameFromType(type);
70074
+ if (name !== void 0) {
70075
+ return name;
70076
+ }
70077
+ }
70078
+ if (hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node)) {
70079
+ const initializer = getEffectiveInitializer(declaration);
70080
+ if (initializer) {
70081
+ const initializerType = isBindingPattern(declaration.parent) ? getTypeForBindingElement(declaration) : getTypeOfExpression(initializer);
70082
+ return initializerType && tryGetNameFromType(initializerType);
70083
+ }
70084
+ if (isEnumMember(declaration)) {
70085
+ return getTextOfPropertyName(declaration.name);
70086
+ }
70087
+ }
70088
+ return void 0;
70073
70089
  }
70074
70090
  function containsMatchingReference(source, target) {
70075
70091
  while (isAccessExpression(source)) {
@@ -78599,6 +78615,9 @@ function createTypeChecker(host) {
78599
78615
  let fallbackReturnType = voidType;
78600
78616
  if (func.body.kind !== 241 /* Block */) {
78601
78617
  returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */);
78618
+ if (isConstContext(func.body)) {
78619
+ returnType = getRegularTypeOfLiteralType(returnType);
78620
+ }
78602
78621
  if (isAsync) {
78603
78622
  returnType = unwrapAwaitedType(checkAwaitedType(
78604
78623
  returnType,
@@ -78731,7 +78750,10 @@ function createTypeChecker(host) {
78731
78750
  const nextTypes = [];
78732
78751
  const isAsync = (getFunctionFlags(func) & 2 /* Async */) !== 0;
78733
78752
  forEachYieldExpression(func.body, (yieldExpression) => {
78734
- const yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
78753
+ let yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
78754
+ if (yieldExpression.expression && isConstContext(yieldExpression.expression)) {
78755
+ yieldExpressionType = getRegularTypeOfLiteralType(yieldExpressionType);
78756
+ }
78735
78757
  pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync));
78736
78758
  let nextType;
78737
78759
  if (yieldExpression.asteriskToken) {
@@ -78846,7 +78868,7 @@ function createTypeChecker(host) {
78846
78868
  if (type.flags & 131072 /* Never */) {
78847
78869
  hasReturnOfTypeNever = true;
78848
78870
  }
78849
- pushIfUnique(aggregatedTypes, type);
78871
+ pushIfUnique(aggregatedTypes, isConstContext(expr) ? getRegularTypeOfLiteralType(type) : type);
78850
78872
  } else {
78851
78873
  hasReturnWithNoExpression = true;
78852
78874
  }
@@ -139946,11 +139968,9 @@ registerRefactor(refactorName3, {
139946
139968
  function getRangeToExtract(context, considerEmptySpans = true) {
139947
139969
  const { file, startPosition } = context;
139948
139970
  const isJS = isSourceFileJS(file);
139949
- const current = getTokenAtPosition(file, startPosition);
139950
139971
  const range = createTextRangeFromSpan(getRefactorContextSpan(context));
139951
- const cursorRequest = range.pos === range.end && considerEmptySpans;
139952
- const overlappingRange = nodeOverlapsWithStartEnd(current, file, range.pos, range.end);
139953
- const firstType = findAncestor(current, (node) => node.parent && isTypeNode(node) && !rangeContainsSkipTrivia(range, node.parent, file) && (cursorRequest || overlappingRange));
139972
+ const isCursorRequest = range.pos === range.end && considerEmptySpans;
139973
+ const firstType = getFirstTypeAt(file, startPosition, range, isCursorRequest);
139954
139974
  if (!firstType || !isTypeNode(firstType))
139955
139975
  return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) };
139956
139976
  const checker = context.program.getTypeChecker();
@@ -139976,6 +139996,21 @@ function getRangeToExtract(context, considerEmptySpans = true) {
139976
139996
  const typeElements = flattenTypeLiteralNodeReference(checker, selection);
139977
139997
  return { isJS, selection, enclosingNode, typeParameters, typeElements };
139978
139998
  }
139999
+ function getFirstTypeAt(file, startPosition, range, isCursorRequest) {
140000
+ const currentNodes = [
140001
+ () => getTokenAtPosition(file, startPosition),
140002
+ () => getTouchingToken(file, startPosition, () => true)
140003
+ ];
140004
+ for (const f of currentNodes) {
140005
+ const current = f();
140006
+ const overlappingRange = nodeOverlapsWithStartEnd(current, file, range.pos, range.end);
140007
+ const firstType = findAncestor(current, (node) => node.parent && isTypeNode(node) && !rangeContainsSkipTrivia(range, node.parent, file) && (isCursorRequest || overlappingRange));
140008
+ if (firstType) {
140009
+ return firstType;
140010
+ }
140011
+ }
140012
+ return void 0;
140013
+ }
139979
140014
  function flattenTypeLiteralNodeReference(checker, selection) {
139980
140015
  if (!selection)
139981
140016
  return void 0;
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.4";
38
- version = `${versionMajorMinor}.0-insiders.20240104`;
38
+ version = `${versionMajorMinor}.0-insiders.20240105`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -47492,11 +47492,7 @@ ${lanes.join("\n")}
47492
47492
  if (errorBindingElement) {
47493
47493
  return findAncestor(errorBindingElement, isBindingElement) !== findAncestor(declaration, isBindingElement) || declaration.pos < errorBindingElement.pos;
47494
47494
  }
47495
- const rootDeclaration = getRootDeclaration(declaration);
47496
- if (rootDeclaration.kind !== 260 /* VariableDeclaration */) {
47497
- return true;
47498
- }
47499
- return isBlockScopedNameDeclaredBeforeUse(rootDeclaration, usage);
47495
+ return isBlockScopedNameDeclaredBeforeUse(getAncestor(declaration, 260 /* VariableDeclaration */), usage);
47500
47496
  } else if (declaration.kind === 260 /* VariableDeclaration */) {
47501
47497
  return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
47502
47498
  } else if (isClassLike(declaration)) {
@@ -67821,9 +67817,29 @@ ${lanes.join("\n")}
67821
67817
  /*ignoreErrors*/
67822
67818
  true
67823
67819
  );
67824
- if (!symbol || symbol.valueDeclaration && !isBlockScopedNameDeclaredBeforeUse(symbol.valueDeclaration, node))
67820
+ if (!symbol || !(isConstantVariable(symbol) || symbol.flags & 8 /* EnumMember */))
67821
+ return void 0;
67822
+ const declaration = symbol.valueDeclaration;
67823
+ if (declaration === void 0)
67825
67824
  return void 0;
67826
- return tryGetNameFromType(getTypeOfExpression(node));
67825
+ const type = tryGetTypeFromEffectiveTypeNode(declaration);
67826
+ if (type) {
67827
+ const name = tryGetNameFromType(type);
67828
+ if (name !== void 0) {
67829
+ return name;
67830
+ }
67831
+ }
67832
+ if (hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node)) {
67833
+ const initializer = getEffectiveInitializer(declaration);
67834
+ if (initializer) {
67835
+ const initializerType = isBindingPattern(declaration.parent) ? getTypeForBindingElement(declaration) : getTypeOfExpression(initializer);
67836
+ return initializerType && tryGetNameFromType(initializerType);
67837
+ }
67838
+ if (isEnumMember(declaration)) {
67839
+ return getTextOfPropertyName(declaration.name);
67840
+ }
67841
+ }
67842
+ return void 0;
67827
67843
  }
67828
67844
  function containsMatchingReference(source, target) {
67829
67845
  while (isAccessExpression(source)) {
@@ -76353,6 +76369,9 @@ ${lanes.join("\n")}
76353
76369
  let fallbackReturnType = voidType;
76354
76370
  if (func.body.kind !== 241 /* Block */) {
76355
76371
  returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */);
76372
+ if (isConstContext(func.body)) {
76373
+ returnType = getRegularTypeOfLiteralType(returnType);
76374
+ }
76356
76375
  if (isAsync) {
76357
76376
  returnType = unwrapAwaitedType(checkAwaitedType(
76358
76377
  returnType,
@@ -76485,7 +76504,10 @@ ${lanes.join("\n")}
76485
76504
  const nextTypes = [];
76486
76505
  const isAsync = (getFunctionFlags(func) & 2 /* Async */) !== 0;
76487
76506
  forEachYieldExpression(func.body, (yieldExpression) => {
76488
- const yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
76507
+ let yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
76508
+ if (yieldExpression.expression && isConstContext(yieldExpression.expression)) {
76509
+ yieldExpressionType = getRegularTypeOfLiteralType(yieldExpressionType);
76510
+ }
76489
76511
  pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync));
76490
76512
  let nextType;
76491
76513
  if (yieldExpression.asteriskToken) {
@@ -76600,7 +76622,7 @@ ${lanes.join("\n")}
76600
76622
  if (type.flags & 131072 /* Never */) {
76601
76623
  hasReturnOfTypeNever = true;
76602
76624
  }
76603
- pushIfUnique(aggregatedTypes, type);
76625
+ pushIfUnique(aggregatedTypes, isConstContext(expr) ? getRegularTypeOfLiteralType(type) : type);
76604
76626
  } else {
76605
76627
  hasReturnWithNoExpression = true;
76606
76628
  }
@@ -138244,11 +138266,9 @@ ${lanes.join("\n")}
138244
138266
  function getRangeToExtract(context, considerEmptySpans = true) {
138245
138267
  const { file, startPosition } = context;
138246
138268
  const isJS = isSourceFileJS(file);
138247
- const current = getTokenAtPosition(file, startPosition);
138248
138269
  const range = createTextRangeFromSpan(getRefactorContextSpan(context));
138249
- const cursorRequest = range.pos === range.end && considerEmptySpans;
138250
- const overlappingRange = nodeOverlapsWithStartEnd(current, file, range.pos, range.end);
138251
- const firstType = findAncestor(current, (node) => node.parent && isTypeNode(node) && !rangeContainsSkipTrivia(range, node.parent, file) && (cursorRequest || overlappingRange));
138270
+ const isCursorRequest = range.pos === range.end && considerEmptySpans;
138271
+ const firstType = getFirstTypeAt(file, startPosition, range, isCursorRequest);
138252
138272
  if (!firstType || !isTypeNode(firstType))
138253
138273
  return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) };
138254
138274
  const checker = context.program.getTypeChecker();
@@ -138274,6 +138294,21 @@ ${lanes.join("\n")}
138274
138294
  const typeElements = flattenTypeLiteralNodeReference(checker, selection);
138275
138295
  return { isJS, selection, enclosingNode, typeParameters, typeElements };
138276
138296
  }
138297
+ function getFirstTypeAt(file, startPosition, range, isCursorRequest) {
138298
+ const currentNodes = [
138299
+ () => getTokenAtPosition(file, startPosition),
138300
+ () => getTouchingToken(file, startPosition, () => true)
138301
+ ];
138302
+ for (const f of currentNodes) {
138303
+ const current = f();
138304
+ const overlappingRange = nodeOverlapsWithStartEnd(current, file, range.pos, range.end);
138305
+ const firstType = findAncestor(current, (node) => node.parent && isTypeNode(node) && !rangeContainsSkipTrivia(range, node.parent, file) && (isCursorRequest || overlappingRange));
138306
+ if (firstType) {
138307
+ return firstType;
138308
+ }
138309
+ }
138310
+ return void 0;
138311
+ }
138277
138312
  function flattenTypeLiteralNodeReference(checker, selection) {
138278
138313
  if (!selection)
138279
138314
  return void 0;
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.4";
57
- var version = `${versionMajorMinor}.0-insiders.20240104`;
57
+ var version = `${versionMajorMinor}.0-insiders.20240105`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typescript-deploys/pr-build",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.4.0-pr-56392-10",
5
+ "version": "5.4.0-pr-56859-8",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -114,5 +114,5 @@
114
114
  "node": "20.1.0",
115
115
  "npm": "8.19.4"
116
116
  },
117
- "gitHead": "61dc1bc3d564f6e826f3e71906739e211c36705b"
117
+ "gitHead": "8f655f85c9fd59b743309dc0ade1e183c9f8ffc2"
118
118
  }