typescript 5.3.0-dev.20231005 → 5.3.0-dev.20231007

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.3";
21
- var version = `${versionMajorMinor}.0-dev.20231005`;
21
+ var version = `${versionMajorMinor}.0-dev.20231007`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -45518,7 +45518,7 @@ function createTypeChecker(host) {
45518
45518
  return resolved;
45519
45519
  }
45520
45520
  function isSyntacticDefault(node) {
45521
- return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node);
45521
+ return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node);
45522
45522
  }
45523
45523
  function getUsageModeForExpression(usage) {
45524
45524
  return isStringLiteralLike(usage) ? getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
@@ -48476,6 +48476,28 @@ function createTypeChecker(host) {
48476
48476
  const propertyName = getPropertyNameNodeForSymbol(propertySymbol, context);
48477
48477
  context.enclosingDeclaration = saveEnclosingDeclaration;
48478
48478
  context.approximateLength += symbolName(propertySymbol).length + 1;
48479
+ if (propertySymbol.flags & 98304 /* Accessor */) {
48480
+ const writeType = getWriteTypeOfSymbol(propertySymbol);
48481
+ if (propertyType !== writeType) {
48482
+ const getterDeclaration = getDeclarationOfKind(propertySymbol, 177 /* GetAccessor */);
48483
+ const getterSignature = getSignatureFromDeclaration(getterDeclaration);
48484
+ typeElements.push(
48485
+ setCommentRange(
48486
+ signatureToSignatureDeclarationHelper(getterSignature, 177 /* GetAccessor */, context, { name: propertyName }),
48487
+ getterDeclaration
48488
+ )
48489
+ );
48490
+ const setterDeclaration = getDeclarationOfKind(propertySymbol, 178 /* SetAccessor */);
48491
+ const setterSignature = getSignatureFromDeclaration(setterDeclaration);
48492
+ typeElements.push(
48493
+ setCommentRange(
48494
+ signatureToSignatureDeclarationHelper(setterSignature, 178 /* SetAccessor */, context, { name: propertyName }),
48495
+ setterDeclaration
48496
+ )
48497
+ );
48498
+ return;
48499
+ }
48500
+ }
48479
48501
  const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0;
48480
48502
  if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
48481
48503
  const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */);
@@ -48513,9 +48535,9 @@ function createTypeChecker(host) {
48513
48535
  typeElements.push(preserveCommentsOn(propertySignature));
48514
48536
  function preserveCommentsOn(node) {
48515
48537
  var _a2;
48516
- if (some(propertySymbol.declarations, (d) => d.kind === 355 /* JSDocPropertyTag */)) {
48517
- const d = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d2) => d2.kind === 355 /* JSDocPropertyTag */);
48518
- const commentText = getTextOfJSDocComment(d.comment);
48538
+ const jsdocPropertyTag = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d) => d.kind === 355 /* JSDocPropertyTag */);
48539
+ if (jsdocPropertyTag) {
48540
+ const commentText = getTextOfJSDocComment(jsdocPropertyTag.comment);
48519
48541
  if (commentText) {
48520
48542
  setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
48521
48543
  }
@@ -50822,7 +50844,15 @@ function createTypeChecker(host) {
50822
50844
  const ctxSrc = getSourceFileOfNode(context.enclosingDeclaration);
50823
50845
  return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class
50824
50846
  !!(length(filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK
50825
- !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => isIdentifierText(symbolName(p), languageVersion));
50847
+ !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => {
50848
+ if (!isIdentifierText(symbolName(p), languageVersion)) {
50849
+ return false;
50850
+ }
50851
+ if (!(p.flags & 98304 /* Accessor */)) {
50852
+ return true;
50853
+ }
50854
+ return getNonMissingTypeOfSymbol(p) === getWriteTypeOfSymbol(p);
50855
+ });
50826
50856
  }
50827
50857
  function makeSerializePropertySymbol(createProperty2, methodKind, useAccessors) {
50828
50858
  return function serializePropertySymbol(p, isStatic2, baseType) {
@@ -65710,16 +65740,7 @@ function createTypeChecker(host) {
65710
65740
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
65711
65741
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
65712
65742
  } else if (expr.kind === 112 /* TrueKeyword */) {
65713
- const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart);
65714
- const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0;
65715
- if (clauseExpression) {
65716
- type = narrowType(
65717
- type,
65718
- clauseExpression,
65719
- /*assumeTrue*/
65720
- true
65721
- );
65722
- }
65743
+ type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
65723
65744
  } else {
65724
65745
  if (strictNullChecks) {
65725
65746
  if (optionalChainContainsReference(expr, reference)) {
@@ -66265,6 +66286,42 @@ function createTypeChecker(host) {
66265
66286
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
66266
66287
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
66267
66288
  }
66289
+ function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
66290
+ const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
66291
+ const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
66292
+ for (let i = 0; i < clauseStart; i++) {
66293
+ const clause = switchStatement.caseBlock.clauses[i];
66294
+ if (clause.kind === 296 /* CaseClause */) {
66295
+ type = narrowType(
66296
+ type,
66297
+ clause.expression,
66298
+ /*assumeTrue*/
66299
+ false
66300
+ );
66301
+ }
66302
+ }
66303
+ if (hasDefaultClause) {
66304
+ for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) {
66305
+ const clause = switchStatement.caseBlock.clauses[i];
66306
+ if (clause.kind === 296 /* CaseClause */) {
66307
+ type = narrowType(
66308
+ type,
66309
+ clause.expression,
66310
+ /*assumeTrue*/
66311
+ false
66312
+ );
66313
+ }
66314
+ }
66315
+ return type;
66316
+ }
66317
+ const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
66318
+ return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
66319
+ type,
66320
+ clause.expression,
66321
+ /*assumeTrue*/
66322
+ true
66323
+ ) : neverType));
66324
+ }
66268
66325
  function isMatchingConstructorReference(expr) {
66269
66326
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
66270
66327
  }
package/lib/tsserver.js CHANGED
@@ -2328,7 +2328,7 @@ module.exports = __toCommonJS(server_exports);
2328
2328
 
2329
2329
  // src/compiler/corePublic.ts
2330
2330
  var versionMajorMinor = "5.3";
2331
- var version = `${versionMajorMinor}.0-dev.20231005`;
2331
+ var version = `${versionMajorMinor}.0-dev.20231007`;
2332
2332
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2333
2333
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2334
2334
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -50230,7 +50230,7 @@ function createTypeChecker(host) {
50230
50230
  return resolved;
50231
50231
  }
50232
50232
  function isSyntacticDefault(node) {
50233
- return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node);
50233
+ return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node);
50234
50234
  }
50235
50235
  function getUsageModeForExpression(usage) {
50236
50236
  return isStringLiteralLike(usage) ? getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
@@ -53188,6 +53188,28 @@ function createTypeChecker(host) {
53188
53188
  const propertyName = getPropertyNameNodeForSymbol(propertySymbol, context);
53189
53189
  context.enclosingDeclaration = saveEnclosingDeclaration;
53190
53190
  context.approximateLength += symbolName(propertySymbol).length + 1;
53191
+ if (propertySymbol.flags & 98304 /* Accessor */) {
53192
+ const writeType = getWriteTypeOfSymbol(propertySymbol);
53193
+ if (propertyType !== writeType) {
53194
+ const getterDeclaration = getDeclarationOfKind(propertySymbol, 177 /* GetAccessor */);
53195
+ const getterSignature = getSignatureFromDeclaration(getterDeclaration);
53196
+ typeElements.push(
53197
+ setCommentRange(
53198
+ signatureToSignatureDeclarationHelper(getterSignature, 177 /* GetAccessor */, context, { name: propertyName }),
53199
+ getterDeclaration
53200
+ )
53201
+ );
53202
+ const setterDeclaration = getDeclarationOfKind(propertySymbol, 178 /* SetAccessor */);
53203
+ const setterSignature = getSignatureFromDeclaration(setterDeclaration);
53204
+ typeElements.push(
53205
+ setCommentRange(
53206
+ signatureToSignatureDeclarationHelper(setterSignature, 178 /* SetAccessor */, context, { name: propertyName }),
53207
+ setterDeclaration
53208
+ )
53209
+ );
53210
+ return;
53211
+ }
53212
+ }
53191
53213
  const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0;
53192
53214
  if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
53193
53215
  const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */);
@@ -53225,9 +53247,9 @@ function createTypeChecker(host) {
53225
53247
  typeElements.push(preserveCommentsOn(propertySignature));
53226
53248
  function preserveCommentsOn(node) {
53227
53249
  var _a2;
53228
- if (some(propertySymbol.declarations, (d) => d.kind === 355 /* JSDocPropertyTag */)) {
53229
- const d = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d2) => d2.kind === 355 /* JSDocPropertyTag */);
53230
- const commentText = getTextOfJSDocComment(d.comment);
53250
+ const jsdocPropertyTag = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d) => d.kind === 355 /* JSDocPropertyTag */);
53251
+ if (jsdocPropertyTag) {
53252
+ const commentText = getTextOfJSDocComment(jsdocPropertyTag.comment);
53231
53253
  if (commentText) {
53232
53254
  setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
53233
53255
  }
@@ -55534,7 +55556,15 @@ function createTypeChecker(host) {
55534
55556
  const ctxSrc = getSourceFileOfNode(context.enclosingDeclaration);
55535
55557
  return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class
55536
55558
  !!(length(filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK
55537
- !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => isIdentifierText(symbolName(p), languageVersion));
55559
+ !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => {
55560
+ if (!isIdentifierText(symbolName(p), languageVersion)) {
55561
+ return false;
55562
+ }
55563
+ if (!(p.flags & 98304 /* Accessor */)) {
55564
+ return true;
55565
+ }
55566
+ return getNonMissingTypeOfSymbol(p) === getWriteTypeOfSymbol(p);
55567
+ });
55538
55568
  }
55539
55569
  function makeSerializePropertySymbol(createProperty2, methodKind, useAccessors) {
55540
55570
  return function serializePropertySymbol(p, isStatic2, baseType) {
@@ -70422,16 +70452,7 @@ function createTypeChecker(host) {
70422
70452
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
70423
70453
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
70424
70454
  } else if (expr.kind === 112 /* TrueKeyword */) {
70425
- const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart);
70426
- const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0;
70427
- if (clauseExpression) {
70428
- type = narrowType(
70429
- type,
70430
- clauseExpression,
70431
- /*assumeTrue*/
70432
- true
70433
- );
70434
- }
70455
+ type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
70435
70456
  } else {
70436
70457
  if (strictNullChecks) {
70437
70458
  if (optionalChainContainsReference(expr, reference)) {
@@ -70977,6 +70998,42 @@ function createTypeChecker(host) {
70977
70998
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
70978
70999
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
70979
71000
  }
71001
+ function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
71002
+ const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
71003
+ const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
71004
+ for (let i = 0; i < clauseStart; i++) {
71005
+ const clause = switchStatement.caseBlock.clauses[i];
71006
+ if (clause.kind === 296 /* CaseClause */) {
71007
+ type = narrowType(
71008
+ type,
71009
+ clause.expression,
71010
+ /*assumeTrue*/
71011
+ false
71012
+ );
71013
+ }
71014
+ }
71015
+ if (hasDefaultClause) {
71016
+ for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) {
71017
+ const clause = switchStatement.caseBlock.clauses[i];
71018
+ if (clause.kind === 296 /* CaseClause */) {
71019
+ type = narrowType(
71020
+ type,
71021
+ clause.expression,
71022
+ /*assumeTrue*/
71023
+ false
71024
+ );
71025
+ }
71026
+ }
71027
+ return type;
71028
+ }
71029
+ const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
71030
+ return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
71031
+ type,
71032
+ clause.expression,
71033
+ /*assumeTrue*/
71034
+ true
71035
+ ) : neverType));
71036
+ }
70980
71037
  function isMatchingConstructorReference(expr) {
70981
71038
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
70982
71039
  }
@@ -157235,7 +157292,7 @@ function completionInfoFromData(sourceFile, host, program, compilerOptions, log,
157235
157292
  );
157236
157293
  if (keywordFilters !== 0 /* None */) {
157237
157294
  for (const keywordEntry of getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && isSourceFileJS(sourceFile))) {
157238
- if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) {
157295
+ if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)) || !isTypeOnlyLocation && isContextualKeywordInAutoImportableExpressionSpace(keywordEntry.name) || !uniqueNames.has(keywordEntry.name)) {
157239
157296
  uniqueNames.add(keywordEntry.name);
157240
157297
  insertSorted(
157241
157298
  entries,
@@ -160424,6 +160481,9 @@ function toUpperCharCode(charCode) {
160424
160481
  }
160425
160482
  return charCode;
160426
160483
  }
160484
+ function isContextualKeywordInAutoImportableExpressionSpace(keyword) {
160485
+ return keyword === "abstract" || keyword === "async" || keyword === "await" || keyword === "declare" || keyword === "module" || keyword === "namespace" || keyword === "type";
160486
+ }
160427
160487
 
160428
160488
  // src/services/_namespaces/ts.Completions.StringCompletions.ts
160429
160489
  var ts_Completions_StringCompletions_exports = {};
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.3";
38
- version = `${versionMajorMinor}.0-dev.20231005`;
38
+ version = `${versionMajorMinor}.0-dev.20231007`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -47997,7 +47997,7 @@ ${lanes.join("\n")}
47997
47997
  return resolved;
47998
47998
  }
47999
47999
  function isSyntacticDefault(node) {
48000
- return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node);
48000
+ return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 1024 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node);
48001
48001
  }
48002
48002
  function getUsageModeForExpression(usage) {
48003
48003
  return isStringLiteralLike(usage) ? getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
@@ -50955,6 +50955,28 @@ ${lanes.join("\n")}
50955
50955
  const propertyName = getPropertyNameNodeForSymbol(propertySymbol, context);
50956
50956
  context.enclosingDeclaration = saveEnclosingDeclaration;
50957
50957
  context.approximateLength += symbolName(propertySymbol).length + 1;
50958
+ if (propertySymbol.flags & 98304 /* Accessor */) {
50959
+ const writeType = getWriteTypeOfSymbol(propertySymbol);
50960
+ if (propertyType !== writeType) {
50961
+ const getterDeclaration = getDeclarationOfKind(propertySymbol, 177 /* GetAccessor */);
50962
+ const getterSignature = getSignatureFromDeclaration(getterDeclaration);
50963
+ typeElements.push(
50964
+ setCommentRange(
50965
+ signatureToSignatureDeclarationHelper(getterSignature, 177 /* GetAccessor */, context, { name: propertyName }),
50966
+ getterDeclaration
50967
+ )
50968
+ );
50969
+ const setterDeclaration = getDeclarationOfKind(propertySymbol, 178 /* SetAccessor */);
50970
+ const setterSignature = getSignatureFromDeclaration(setterDeclaration);
50971
+ typeElements.push(
50972
+ setCommentRange(
50973
+ signatureToSignatureDeclarationHelper(setterSignature, 178 /* SetAccessor */, context, { name: propertyName }),
50974
+ setterDeclaration
50975
+ )
50976
+ );
50977
+ return;
50978
+ }
50979
+ }
50958
50980
  const optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0;
50959
50981
  if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
50960
50982
  const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */);
@@ -50992,9 +51014,9 @@ ${lanes.join("\n")}
50992
51014
  typeElements.push(preserveCommentsOn(propertySignature));
50993
51015
  function preserveCommentsOn(node) {
50994
51016
  var _a2;
50995
- if (some(propertySymbol.declarations, (d) => d.kind === 355 /* JSDocPropertyTag */)) {
50996
- const d = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d2) => d2.kind === 355 /* JSDocPropertyTag */);
50997
- const commentText = getTextOfJSDocComment(d.comment);
51017
+ const jsdocPropertyTag = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d) => d.kind === 355 /* JSDocPropertyTag */);
51018
+ if (jsdocPropertyTag) {
51019
+ const commentText = getTextOfJSDocComment(jsdocPropertyTag.comment);
50998
51020
  if (commentText) {
50999
51021
  setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
51000
51022
  }
@@ -53301,7 +53323,15 @@ ${lanes.join("\n")}
53301
53323
  const ctxSrc = getSourceFileOfNode(context.enclosingDeclaration);
53302
53324
  return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class
53303
53325
  !!(length(filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK
53304
- !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => isIdentifierText(symbolName(p), languageVersion));
53326
+ !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => {
53327
+ if (!isIdentifierText(symbolName(p), languageVersion)) {
53328
+ return false;
53329
+ }
53330
+ if (!(p.flags & 98304 /* Accessor */)) {
53331
+ return true;
53332
+ }
53333
+ return getNonMissingTypeOfSymbol(p) === getWriteTypeOfSymbol(p);
53334
+ });
53305
53335
  }
53306
53336
  function makeSerializePropertySymbol(createProperty2, methodKind, useAccessors) {
53307
53337
  return function serializePropertySymbol(p, isStatic2, baseType) {
@@ -68189,16 +68219,7 @@ ${lanes.join("\n")}
68189
68219
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
68190
68220
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
68191
68221
  } else if (expr.kind === 112 /* TrueKeyword */) {
68192
- const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart);
68193
- const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0;
68194
- if (clauseExpression) {
68195
- type = narrowType(
68196
- type,
68197
- clauseExpression,
68198
- /*assumeTrue*/
68199
- true
68200
- );
68201
- }
68222
+ type = narrowTypeBySwitchOnTrue(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
68202
68223
  } else {
68203
68224
  if (strictNullChecks) {
68204
68225
  if (optionalChainContainsReference(expr, reference)) {
@@ -68744,6 +68765,42 @@ ${lanes.join("\n")}
68744
68765
  const clauseWitnesses = witnesses.slice(clauseStart, clauseEnd);
68745
68766
  return getUnionType(map(clauseWitnesses, (text) => text ? narrowTypeByTypeName(type, text) : neverType));
68746
68767
  }
68768
+ function narrowTypeBySwitchOnTrue(type, switchStatement, clauseStart, clauseEnd) {
68769
+ const defaultIndex = findIndex(switchStatement.caseBlock.clauses, (clause) => clause.kind === 297 /* DefaultClause */);
68770
+ const hasDefaultClause = clauseStart === clauseEnd || defaultIndex >= clauseStart && defaultIndex < clauseEnd;
68771
+ for (let i = 0; i < clauseStart; i++) {
68772
+ const clause = switchStatement.caseBlock.clauses[i];
68773
+ if (clause.kind === 296 /* CaseClause */) {
68774
+ type = narrowType(
68775
+ type,
68776
+ clause.expression,
68777
+ /*assumeTrue*/
68778
+ false
68779
+ );
68780
+ }
68781
+ }
68782
+ if (hasDefaultClause) {
68783
+ for (let i = clauseEnd; i < switchStatement.caseBlock.clauses.length; i++) {
68784
+ const clause = switchStatement.caseBlock.clauses[i];
68785
+ if (clause.kind === 296 /* CaseClause */) {
68786
+ type = narrowType(
68787
+ type,
68788
+ clause.expression,
68789
+ /*assumeTrue*/
68790
+ false
68791
+ );
68792
+ }
68793
+ }
68794
+ return type;
68795
+ }
68796
+ const clauses = switchStatement.caseBlock.clauses.slice(clauseStart, clauseEnd);
68797
+ return getUnionType(map(clauses, (clause) => clause.kind === 296 /* CaseClause */ ? narrowType(
68798
+ type,
68799
+ clause.expression,
68800
+ /*assumeTrue*/
68801
+ true
68802
+ ) : neverType));
68803
+ }
68747
68804
  function isMatchingConstructorReference(expr) {
68748
68805
  return (isPropertyAccessExpression(expr) && idText(expr.name) === "constructor" || isElementAccessExpression(expr) && isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && isMatchingReference(reference, expr.expression);
68749
68806
  }
@@ -156459,7 +156516,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
156459
156516
  );
156460
156517
  if (keywordFilters !== 0 /* None */) {
156461
156518
  for (const keywordEntry of getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && isSourceFileJS(sourceFile))) {
156462
- if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) {
156519
+ if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)) || !isTypeOnlyLocation && isContextualKeywordInAutoImportableExpressionSpace(keywordEntry.name) || !uniqueNames.has(keywordEntry.name)) {
156463
156520
  uniqueNames.add(keywordEntry.name);
156464
156521
  insertSorted(
156465
156522
  entries,
@@ -159626,6 +159683,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
159626
159683
  }
159627
159684
  return charCode;
159628
159685
  }
159686
+ function isContextualKeywordInAutoImportableExpressionSpace(keyword) {
159687
+ return keyword === "abstract" || keyword === "async" || keyword === "await" || keyword === "declare" || keyword === "module" || keyword === "namespace" || keyword === "type";
159688
+ }
159629
159689
  var moduleSpecifierResolutionLimit, moduleSpecifierResolutionCacheAttemptLimit, SortText, CompletionSource, SymbolOriginInfoKind, CompletionKind, _keywordCompletions, allKeywordsCompletions;
159630
159690
  var init_completions = __esm({
159631
159691
  "src/services/completions.ts"() {
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.3";
57
- var version = `${versionMajorMinor}.0-dev.20231005`;
57
+ var version = `${versionMajorMinor}.0-dev.20231007`;
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.3.0-dev.20231005",
5
+ "version": "5.3.0-dev.20231007",
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": "20.1.0",
114
114
  "npm": "8.19.4"
115
115
  },
116
- "gitHead": "e9f68cb2969751ce2a6df8b5ee9bbfb08afb41e1"
116
+ "gitHead": "d1a2e7e730cb8ebd44662ece6b263e2d4d885da2"
117
117
  }