typescript 5.1.0-dev.20230327 → 5.1.0-dev.20230328

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.1";
21
- var version = `${versionMajorMinor}.0-dev.20230327`;
21
+ var version = `${versionMajorMinor}.0-dev.20230328`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -49912,6 +49912,7 @@ function createTypeChecker(host) {
49912
49912
  ), 0 /* None */);
49913
49913
  }
49914
49914
  function serializeMaybeAliasAssignment(symbol) {
49915
+ var _a2;
49915
49916
  if (symbol.flags & 4194304 /* Prototype */) {
49916
49917
  return false;
49917
49918
  }
@@ -49991,7 +49992,7 @@ function createTypeChecker(host) {
49991
49992
  void 0,
49992
49993
  serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)
49993
49994
  )
49994
- ], 2 /* Const */)
49995
+ ], ((_a2 = context.enclosingDeclaration) == null ? void 0 : _a2.kind) === 265 /* ModuleDeclaration */ ? 1 /* Let */ : 2 /* Const */)
49995
49996
  );
49996
49997
  addResult(
49997
49998
  statement,
@@ -50027,7 +50028,7 @@ function createTypeChecker(host) {
50027
50028
  if (isStatic2 && p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) {
50028
50029
  return [];
50029
50030
  }
50030
- if (p.flags & 4194304 /* Prototype */ || baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName))) {
50031
+ if (p.flags & 4194304 /* Prototype */ || p.escapedName === "constructor" || baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName))) {
50031
50032
  return [];
50032
50033
  }
50033
50034
  const flag = modifierFlags & ~512 /* Async */ | (isStatic2 ? 32 /* Static */ : 0);
@@ -53527,6 +53528,9 @@ function createTypeChecker(host) {
53527
53528
  return type.resolvedDefaultConstraint;
53528
53529
  }
53529
53530
  function getConstraintOfDistributiveConditionalType(type) {
53531
+ if (type.resolvedConstraintOfDistributive !== void 0) {
53532
+ return type.resolvedConstraintOfDistributive || void 0;
53533
+ }
53530
53534
  if (type.root.isDistributive && type.restrictiveInstantiation !== type) {
53531
53535
  const simplified = getSimplifiedType(
53532
53536
  type.checkType,
@@ -53537,10 +53541,12 @@ function createTypeChecker(host) {
53537
53541
  if (constraint && constraint !== type.checkType) {
53538
53542
  const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
53539
53543
  if (!(instantiated.flags & 131072 /* Never */)) {
53544
+ type.resolvedConstraintOfDistributive = instantiated;
53540
53545
  return instantiated;
53541
53546
  }
53542
53547
  }
53543
53548
  }
53549
+ type.resolvedConstraintOfDistributive = false;
53544
53550
  return void 0;
53545
53551
  }
53546
53552
  function getConstraintFromConditionalType(type) {
@@ -72228,7 +72234,7 @@ function createTypeChecker(host) {
72228
72234
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
72229
72235
  const functionFlags = getFunctionFlags(func);
72230
72236
  const type = returnType && unwrapReturnType(returnType, functionFlags);
72231
- if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
72237
+ if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */ | 2 /* Unknown */)) {
72232
72238
  return;
72233
72239
  }
72234
72240
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -91318,10 +91324,14 @@ function transformESDecorators(context) {
91318
91324
  visitor
91319
91325
  );
91320
91326
  const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart);
91321
- const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0;
91322
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0));
91323
- addRange(statements, initializerStatements);
91324
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper));
91327
+ if (superStatementIndex >= 0) {
91328
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart));
91329
+ addRange(statements, initializerStatements);
91330
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1));
91331
+ } else {
91332
+ addRange(statements, initializerStatements);
91333
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement));
91334
+ }
91325
91335
  body = factory2.createBlock(
91326
91336
  statements,
91327
91337
  /*multiLine*/
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.1";
2289
- var version = `${versionMajorMinor}.0-dev.20230327`;
2289
+ var version = `${versionMajorMinor}.0-dev.20230328`;
2290
2290
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2291
2291
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2292
2292
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -54554,6 +54554,7 @@ function createTypeChecker(host) {
54554
54554
  ), 0 /* None */);
54555
54555
  }
54556
54556
  function serializeMaybeAliasAssignment(symbol) {
54557
+ var _a2;
54557
54558
  if (symbol.flags & 4194304 /* Prototype */) {
54558
54559
  return false;
54559
54560
  }
@@ -54633,7 +54634,7 @@ function createTypeChecker(host) {
54633
54634
  void 0,
54634
54635
  serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)
54635
54636
  )
54636
- ], 2 /* Const */)
54637
+ ], ((_a2 = context.enclosingDeclaration) == null ? void 0 : _a2.kind) === 265 /* ModuleDeclaration */ ? 1 /* Let */ : 2 /* Const */)
54637
54638
  );
54638
54639
  addResult(
54639
54640
  statement,
@@ -54669,7 +54670,7 @@ function createTypeChecker(host) {
54669
54670
  if (isStatic2 && p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) {
54670
54671
  return [];
54671
54672
  }
54672
- if (p.flags & 4194304 /* Prototype */ || baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName))) {
54673
+ if (p.flags & 4194304 /* Prototype */ || p.escapedName === "constructor" || baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName))) {
54673
54674
  return [];
54674
54675
  }
54675
54676
  const flag = modifierFlags & ~512 /* Async */ | (isStatic2 ? 32 /* Static */ : 0);
@@ -58169,6 +58170,9 @@ function createTypeChecker(host) {
58169
58170
  return type.resolvedDefaultConstraint;
58170
58171
  }
58171
58172
  function getConstraintOfDistributiveConditionalType(type) {
58173
+ if (type.resolvedConstraintOfDistributive !== void 0) {
58174
+ return type.resolvedConstraintOfDistributive || void 0;
58175
+ }
58172
58176
  if (type.root.isDistributive && type.restrictiveInstantiation !== type) {
58173
58177
  const simplified = getSimplifiedType(
58174
58178
  type.checkType,
@@ -58179,10 +58183,12 @@ function createTypeChecker(host) {
58179
58183
  if (constraint && constraint !== type.checkType) {
58180
58184
  const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
58181
58185
  if (!(instantiated.flags & 131072 /* Never */)) {
58186
+ type.resolvedConstraintOfDistributive = instantiated;
58182
58187
  return instantiated;
58183
58188
  }
58184
58189
  }
58185
58190
  }
58191
+ type.resolvedConstraintOfDistributive = false;
58186
58192
  return void 0;
58187
58193
  }
58188
58194
  function getConstraintFromConditionalType(type) {
@@ -76870,7 +76876,7 @@ function createTypeChecker(host) {
76870
76876
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
76871
76877
  const functionFlags = getFunctionFlags(func);
76872
76878
  const type = returnType && unwrapReturnType(returnType, functionFlags);
76873
- if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
76879
+ if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */ | 2 /* Unknown */)) {
76874
76880
  return;
76875
76881
  }
76876
76882
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -96131,10 +96137,14 @@ function transformESDecorators(context) {
96131
96137
  visitor
96132
96138
  );
96133
96139
  const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart);
96134
- const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0;
96135
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0));
96136
- addRange(statements, initializerStatements);
96137
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper));
96140
+ if (superStatementIndex >= 0) {
96141
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart));
96142
+ addRange(statements, initializerStatements);
96143
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1));
96144
+ } else {
96145
+ addRange(statements, initializerStatements);
96146
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement));
96147
+ }
96138
96148
  body = factory2.createBlock(
96139
96149
  statements,
96140
96150
  /*multiLine*/
@@ -152526,7 +152536,7 @@ function getStringLiteralCompletionEntries(sourceFile, node, position, typeCheck
152526
152536
  const literals = contextualTypes.types.filter((literal) => !tracker.hasValue(literal.value));
152527
152537
  return { kind: 2 /* Types */, types: literals, isNewIdentifier: false };
152528
152538
  default:
152529
- return fromContextualType();
152539
+ return fromContextualType() || fromContextualType(0 /* None */);
152530
152540
  }
152531
152541
  function fromContextualType(contextFlags = 4 /* Completions */) {
152532
152542
  const types = getStringLiteralTypes(getContextualTypeFromParent(node, typeChecker, contextFlags));
@@ -161591,9 +161601,9 @@ function extractFunctionInScope(node, scope, { usages: usagesInScope, typeParame
161591
161601
  }
161592
161602
  callArguments.push(factory.createIdentifier(name));
161593
161603
  });
161594
- const typeParametersAndDeclarations = arrayFrom(typeParameterUsages.values(), (type) => ({ type, declaration: getFirstDeclaration(type) }));
161604
+ const typeParametersAndDeclarations = arrayFrom(typeParameterUsages.values(), (type) => ({ type, declaration: getFirstDeclarationBeforePosition(type, context.startPosition) }));
161595
161605
  const sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder);
161596
- const typeParameters = sortedTypeParametersAndDeclarations.length === 0 ? void 0 : sortedTypeParametersAndDeclarations.map((t) => t.declaration);
161606
+ const typeParameters = sortedTypeParametersAndDeclarations.length === 0 ? void 0 : mapDefined(sortedTypeParametersAndDeclarations, ({ declaration }) => declaration);
161597
161607
  const callTypeArguments = typeParameters !== void 0 ? typeParameters.map((decl) => factory.createTypeReferenceNode(
161598
161608
  decl.name,
161599
161609
  /*typeArguments*/
@@ -162070,12 +162080,12 @@ function getContainingVariableDeclarationIfInList(node, scope) {
162070
162080
  node = node.parent;
162071
162081
  }
162072
162082
  }
162073
- function getFirstDeclaration(type) {
162083
+ function getFirstDeclarationBeforePosition(type, position) {
162074
162084
  let firstDeclaration;
162075
162085
  const symbol = type.symbol;
162076
162086
  if (symbol && symbol.declarations) {
162077
162087
  for (const declaration of symbol.declarations) {
162078
- if (firstDeclaration === void 0 || declaration.pos < firstDeclaration.pos) {
162088
+ if ((firstDeclaration === void 0 || declaration.pos < firstDeclaration.pos) && declaration.pos < position) {
162079
162089
  firstDeclaration = declaration;
162080
162090
  }
162081
162091
  }
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230327`;
38
+ version = `${versionMajorMinor}.0-dev.20230328`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -52362,6 +52362,7 @@ ${lanes.join("\n")}
52362
52362
  ), 0 /* None */);
52363
52363
  }
52364
52364
  function serializeMaybeAliasAssignment(symbol) {
52365
+ var _a2;
52365
52366
  if (symbol.flags & 4194304 /* Prototype */) {
52366
52367
  return false;
52367
52368
  }
@@ -52441,7 +52442,7 @@ ${lanes.join("\n")}
52441
52442
  void 0,
52442
52443
  serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)
52443
52444
  )
52444
- ], 2 /* Const */)
52445
+ ], ((_a2 = context.enclosingDeclaration) == null ? void 0 : _a2.kind) === 265 /* ModuleDeclaration */ ? 1 /* Let */ : 2 /* Const */)
52445
52446
  );
52446
52447
  addResult(
52447
52448
  statement,
@@ -52477,7 +52478,7 @@ ${lanes.join("\n")}
52477
52478
  if (isStatic2 && p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) {
52478
52479
  return [];
52479
52480
  }
52480
- if (p.flags & 4194304 /* Prototype */ || baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName))) {
52481
+ if (p.flags & 4194304 /* Prototype */ || p.escapedName === "constructor" || baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName))) {
52481
52482
  return [];
52482
52483
  }
52483
52484
  const flag = modifierFlags & ~512 /* Async */ | (isStatic2 ? 32 /* Static */ : 0);
@@ -55977,6 +55978,9 @@ ${lanes.join("\n")}
55977
55978
  return type.resolvedDefaultConstraint;
55978
55979
  }
55979
55980
  function getConstraintOfDistributiveConditionalType(type) {
55981
+ if (type.resolvedConstraintOfDistributive !== void 0) {
55982
+ return type.resolvedConstraintOfDistributive || void 0;
55983
+ }
55980
55984
  if (type.root.isDistributive && type.restrictiveInstantiation !== type) {
55981
55985
  const simplified = getSimplifiedType(
55982
55986
  type.checkType,
@@ -55987,10 +55991,12 @@ ${lanes.join("\n")}
55987
55991
  if (constraint && constraint !== type.checkType) {
55988
55992
  const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
55989
55993
  if (!(instantiated.flags & 131072 /* Never */)) {
55994
+ type.resolvedConstraintOfDistributive = instantiated;
55990
55995
  return instantiated;
55991
55996
  }
55992
55997
  }
55993
55998
  }
55999
+ type.resolvedConstraintOfDistributive = false;
55994
56000
  return void 0;
55995
56001
  }
55996
56002
  function getConstraintFromConditionalType(type) {
@@ -74678,7 +74684,7 @@ ${lanes.join("\n")}
74678
74684
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
74679
74685
  const functionFlags = getFunctionFlags(func);
74680
74686
  const type = returnType && unwrapReturnType(returnType, functionFlags);
74681
- if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
74687
+ if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */ | 2 /* Unknown */)) {
74682
74688
  return;
74683
74689
  }
74684
74690
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -94132,10 +94138,14 @@ ${lanes.join("\n")}
94132
94138
  visitor
94133
94139
  );
94134
94140
  const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart);
94135
- const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0;
94136
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0));
94137
- addRange(statements, initializerStatements);
94138
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper));
94141
+ if (superStatementIndex >= 0) {
94142
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart));
94143
+ addRange(statements, initializerStatements);
94144
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1));
94145
+ } else {
94146
+ addRange(statements, initializerStatements);
94147
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement));
94148
+ }
94139
94149
  body = factory2.createBlock(
94140
94150
  statements,
94141
94151
  /*multiLine*/
@@ -151623,7 +151633,7 @@ ${lanes.join("\n")}
151623
151633
  const literals = contextualTypes.types.filter((literal) => !tracker.hasValue(literal.value));
151624
151634
  return { kind: 2 /* Types */, types: literals, isNewIdentifier: false };
151625
151635
  default:
151626
- return fromContextualType();
151636
+ return fromContextualType() || fromContextualType(0 /* None */);
151627
151637
  }
151628
151638
  function fromContextualType(contextFlags = 4 /* Completions */) {
151629
151639
  const types = getStringLiteralTypes(getContextualTypeFromParent(node, typeChecker, contextFlags));
@@ -160861,9 +160871,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
160861
160871
  }
160862
160872
  callArguments.push(factory.createIdentifier(name));
160863
160873
  });
160864
- const typeParametersAndDeclarations = arrayFrom(typeParameterUsages.values(), (type) => ({ type, declaration: getFirstDeclaration(type) }));
160874
+ const typeParametersAndDeclarations = arrayFrom(typeParameterUsages.values(), (type) => ({ type, declaration: getFirstDeclarationBeforePosition(type, context.startPosition) }));
160865
160875
  const sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder);
160866
- const typeParameters = sortedTypeParametersAndDeclarations.length === 0 ? void 0 : sortedTypeParametersAndDeclarations.map((t) => t.declaration);
160876
+ const typeParameters = sortedTypeParametersAndDeclarations.length === 0 ? void 0 : mapDefined(sortedTypeParametersAndDeclarations, ({ declaration }) => declaration);
160867
160877
  const callTypeArguments = typeParameters !== void 0 ? typeParameters.map((decl) => factory.createTypeReferenceNode(
160868
160878
  decl.name,
160869
160879
  /*typeArguments*/
@@ -161340,12 +161350,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
161340
161350
  node = node.parent;
161341
161351
  }
161342
161352
  }
161343
- function getFirstDeclaration(type) {
161353
+ function getFirstDeclarationBeforePosition(type, position) {
161344
161354
  let firstDeclaration;
161345
161355
  const symbol = type.symbol;
161346
161356
  if (symbol && symbol.declarations) {
161347
161357
  for (const declaration of symbol.declarations) {
161348
- if (firstDeclaration === void 0 || declaration.pos < firstDeclaration.pos) {
161358
+ if ((firstDeclaration === void 0 || declaration.pos < firstDeclaration.pos) && declaration.pos < position) {
161349
161359
  firstDeclaration = declaration;
161350
161360
  }
161351
161361
  }
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.1";
38
- version = `${versionMajorMinor}.0-dev.20230327`;
38
+ version = `${versionMajorMinor}.0-dev.20230328`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -52362,6 +52362,7 @@ ${lanes.join("\n")}
52362
52362
  ), 0 /* None */);
52363
52363
  }
52364
52364
  function serializeMaybeAliasAssignment(symbol) {
52365
+ var _a2;
52365
52366
  if (symbol.flags & 4194304 /* Prototype */) {
52366
52367
  return false;
52367
52368
  }
@@ -52441,7 +52442,7 @@ ${lanes.join("\n")}
52441
52442
  void 0,
52442
52443
  serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)
52443
52444
  )
52444
- ], 2 /* Const */)
52445
+ ], ((_a2 = context.enclosingDeclaration) == null ? void 0 : _a2.kind) === 265 /* ModuleDeclaration */ ? 1 /* Let */ : 2 /* Const */)
52445
52446
  );
52446
52447
  addResult(
52447
52448
  statement,
@@ -52477,7 +52478,7 @@ ${lanes.join("\n")}
52477
52478
  if (isStatic2 && p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) {
52478
52479
  return [];
52479
52480
  }
52480
- if (p.flags & 4194304 /* Prototype */ || baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName))) {
52481
+ if (p.flags & 4194304 /* Prototype */ || p.escapedName === "constructor" || baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName))) {
52481
52482
  return [];
52482
52483
  }
52483
52484
  const flag = modifierFlags & ~512 /* Async */ | (isStatic2 ? 32 /* Static */ : 0);
@@ -55977,6 +55978,9 @@ ${lanes.join("\n")}
55977
55978
  return type.resolvedDefaultConstraint;
55978
55979
  }
55979
55980
  function getConstraintOfDistributiveConditionalType(type) {
55981
+ if (type.resolvedConstraintOfDistributive !== void 0) {
55982
+ return type.resolvedConstraintOfDistributive || void 0;
55983
+ }
55980
55984
  if (type.root.isDistributive && type.restrictiveInstantiation !== type) {
55981
55985
  const simplified = getSimplifiedType(
55982
55986
  type.checkType,
@@ -55987,10 +55991,12 @@ ${lanes.join("\n")}
55987
55991
  if (constraint && constraint !== type.checkType) {
55988
55992
  const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
55989
55993
  if (!(instantiated.flags & 131072 /* Never */)) {
55994
+ type.resolvedConstraintOfDistributive = instantiated;
55990
55995
  return instantiated;
55991
55996
  }
55992
55997
  }
55993
55998
  }
55999
+ type.resolvedConstraintOfDistributive = false;
55994
56000
  return void 0;
55995
56001
  }
55996
56002
  function getConstraintFromConditionalType(type) {
@@ -74678,7 +74684,7 @@ ${lanes.join("\n")}
74678
74684
  function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
74679
74685
  const functionFlags = getFunctionFlags(func);
74680
74686
  const type = returnType && unwrapReturnType(returnType, functionFlags);
74681
- if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */)) {
74687
+ if (type && maybeTypeOfKind(type, 32768 /* Undefined */ | 16384 /* Void */ | 1 /* Any */ | 2 /* Unknown */)) {
74682
74688
  return;
74683
74689
  }
74684
74690
  if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
@@ -94132,10 +94138,14 @@ ${lanes.join("\n")}
94132
94138
  visitor
94133
94139
  );
94134
94140
  const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart);
94135
- const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0;
94136
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0));
94137
- addRange(statements, initializerStatements);
94138
- addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper));
94141
+ if (superStatementIndex >= 0) {
94142
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart));
94143
+ addRange(statements, initializerStatements);
94144
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1));
94145
+ } else {
94146
+ addRange(statements, initializerStatements);
94147
+ addRange(statements, visitNodes2(node.body.statements, visitor, isStatement));
94148
+ }
94139
94149
  body = factory2.createBlock(
94140
94150
  statements,
94141
94151
  /*multiLine*/
@@ -151637,7 +151647,7 @@ ${lanes.join("\n")}
151637
151647
  const literals = contextualTypes.types.filter((literal) => !tracker.hasValue(literal.value));
151638
151648
  return { kind: 2 /* Types */, types: literals, isNewIdentifier: false };
151639
151649
  default:
151640
- return fromContextualType();
151650
+ return fromContextualType() || fromContextualType(0 /* None */);
151641
151651
  }
151642
151652
  function fromContextualType(contextFlags = 4 /* Completions */) {
151643
151653
  const types = getStringLiteralTypes(getContextualTypeFromParent(node, typeChecker, contextFlags));
@@ -160875,9 +160885,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
160875
160885
  }
160876
160886
  callArguments.push(factory.createIdentifier(name));
160877
160887
  });
160878
- const typeParametersAndDeclarations = arrayFrom(typeParameterUsages.values(), (type) => ({ type, declaration: getFirstDeclaration(type) }));
160888
+ const typeParametersAndDeclarations = arrayFrom(typeParameterUsages.values(), (type) => ({ type, declaration: getFirstDeclarationBeforePosition(type, context.startPosition) }));
160879
160889
  const sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder);
160880
- const typeParameters = sortedTypeParametersAndDeclarations.length === 0 ? void 0 : sortedTypeParametersAndDeclarations.map((t) => t.declaration);
160890
+ const typeParameters = sortedTypeParametersAndDeclarations.length === 0 ? void 0 : mapDefined(sortedTypeParametersAndDeclarations, ({ declaration }) => declaration);
160881
160891
  const callTypeArguments = typeParameters !== void 0 ? typeParameters.map((decl) => factory.createTypeReferenceNode(
160882
160892
  decl.name,
160883
160893
  /*typeArguments*/
@@ -161354,12 +161364,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
161354
161364
  node = node.parent;
161355
161365
  }
161356
161366
  }
161357
- function getFirstDeclaration(type) {
161367
+ function getFirstDeclarationBeforePosition(type, position) {
161358
161368
  let firstDeclaration;
161359
161369
  const symbol = type.symbol;
161360
161370
  if (symbol && symbol.declarations) {
161361
161371
  for (const declaration of symbol.declarations) {
161362
- if (firstDeclaration === void 0 || declaration.pos < firstDeclaration.pos) {
161372
+ if ((firstDeclaration === void 0 || declaration.pos < firstDeclaration.pos) && declaration.pos < position) {
161363
161373
  firstDeclaration = declaration;
161364
161374
  }
161365
161375
  }
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.1";
57
- var version = `${versionMajorMinor}.0-dev.20230327`;
57
+ var version = `${versionMajorMinor}.0-dev.20230328`;
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.1.0-dev.20230327",
5
+ "version": "5.1.0-dev.20230328",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -113,5 +113,5 @@
113
113
  "node": "14.21.1",
114
114
  "npm": "8.19.3"
115
115
  },
116
- "gitHead": "f64f40d20511d2d2a9eb4fcc1ad6750977be2d40"
116
+ "gitHead": "647c587e46418063a1b13bdd6b4758ff90a75198"
117
117
  }