typescript 5.3.0-dev.20230815 → 5.3.0-dev.20230816

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.20230815`;
21
+ var version = `${versionMajorMinor}.0-dev.20230816`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -12422,16 +12422,14 @@ function createDiagnosticForNodeArrayFromMessageChain(sourceFile, nodes, message
12422
12422
  const start = skipTrivia(sourceFile.text, nodes.pos);
12423
12423
  return createFileDiagnosticFromMessageChain(sourceFile, start, nodes.end - start, messageChain, relatedInformation);
12424
12424
  }
12425
- function assertDiagnosticLocation(file, start, length2) {
12425
+ function assertDiagnosticLocation(sourceText, start, length2) {
12426
12426
  Debug.assertGreaterThanOrEqual(start, 0);
12427
12427
  Debug.assertGreaterThanOrEqual(length2, 0);
12428
- if (file) {
12429
- Debug.assertLessThanOrEqual(start, file.text.length);
12430
- Debug.assertLessThanOrEqual(start + length2, file.text.length);
12431
- }
12428
+ Debug.assertLessThanOrEqual(start, sourceText.length);
12429
+ Debug.assertLessThanOrEqual(start + length2, sourceText.length);
12432
12430
  }
12433
12431
  function createFileDiagnosticFromMessageChain(file, start, length2, messageChain, relatedInformation) {
12434
- assertDiagnosticLocation(file, start, length2);
12432
+ assertDiagnosticLocation(file.text, start, length2);
12435
12433
  return {
12436
12434
  file,
12437
12435
  start,
@@ -13288,8 +13286,8 @@ function isInExpressionContext(node) {
13288
13286
  return forStatement.initializer === node && forStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forStatement.condition === node || forStatement.incrementor === node;
13289
13287
  case 249 /* ForInStatement */:
13290
13288
  case 250 /* ForOfStatement */:
13291
- const forInStatement = parent;
13292
- return forInStatement.initializer === node && forInStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forInStatement.expression === node;
13289
+ const forInOrOfStatement = parent;
13290
+ return forInOrOfStatement.initializer === node && forInOrOfStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forInOrOfStatement.expression === node;
13293
13291
  case 216 /* TypeAssertionExpression */:
13294
13292
  case 234 /* AsExpression */:
13295
13293
  return node === parent.expression;
@@ -13950,20 +13948,23 @@ function getTypeParameterFromJsDoc(node) {
13950
13948
  const { typeParameters } = node.parent.parent.parent;
13951
13949
  return typeParameters && find(typeParameters, (p) => p.name.escapedText === name);
13952
13950
  }
13953
- function getAssignmentTargetKind(node) {
13951
+ function getAssignmentTarget(node) {
13954
13952
  let parent = node.parent;
13955
13953
  while (true) {
13956
13954
  switch (parent.kind) {
13957
13955
  case 226 /* BinaryExpression */:
13958
- const binaryOperator = parent.operatorToken.kind;
13959
- return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 64 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */;
13956
+ const binaryExpression = parent;
13957
+ const binaryOperator = binaryExpression.operatorToken.kind;
13958
+ return isAssignmentOperator(binaryOperator) && binaryExpression.left === node ? binaryExpression : void 0;
13960
13959
  case 224 /* PrefixUnaryExpression */:
13961
13960
  case 225 /* PostfixUnaryExpression */:
13962
- const unaryOperator = parent.operator;
13963
- return unaryOperator === 46 /* PlusPlusToken */ || unaryOperator === 47 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */;
13961
+ const unaryExpression = parent;
13962
+ const unaryOperator = unaryExpression.operator;
13963
+ return unaryOperator === 46 /* PlusPlusToken */ || unaryOperator === 47 /* MinusMinusToken */ ? unaryExpression : void 0;
13964
13964
  case 249 /* ForInStatement */:
13965
13965
  case 250 /* ForOfStatement */:
13966
- return parent.initializer === node ? 1 /* Definite */ : 0 /* None */;
13966
+ const forInOrOfStatement = parent;
13967
+ return forInOrOfStatement.initializer === node ? forInOrOfStatement : void 0;
13967
13968
  case 217 /* ParenthesizedExpression */:
13968
13969
  case 209 /* ArrayLiteralExpression */:
13969
13970
  case 230 /* SpreadElement */:
@@ -13975,24 +13976,53 @@ function getAssignmentTargetKind(node) {
13975
13976
  break;
13976
13977
  case 304 /* ShorthandPropertyAssignment */:
13977
13978
  if (parent.name !== node) {
13978
- return 0 /* None */;
13979
+ return void 0;
13979
13980
  }
13980
13981
  node = parent.parent;
13981
13982
  break;
13982
13983
  case 303 /* PropertyAssignment */:
13983
13984
  if (parent.name === node) {
13984
- return 0 /* None */;
13985
+ return void 0;
13985
13986
  }
13986
13987
  node = parent.parent;
13987
13988
  break;
13988
13989
  default:
13989
- return 0 /* None */;
13990
+ return void 0;
13990
13991
  }
13991
13992
  parent = node.parent;
13992
13993
  }
13993
13994
  }
13995
+ function getAssignmentTargetKind(node) {
13996
+ const target = getAssignmentTarget(node);
13997
+ if (!target) {
13998
+ return 0 /* None */;
13999
+ }
14000
+ switch (target.kind) {
14001
+ case 226 /* BinaryExpression */:
14002
+ const binaryOperator = target.operatorToken.kind;
14003
+ return binaryOperator === 64 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */;
14004
+ case 224 /* PrefixUnaryExpression */:
14005
+ case 225 /* PostfixUnaryExpression */:
14006
+ return 2 /* Compound */;
14007
+ case 249 /* ForInStatement */:
14008
+ case 250 /* ForOfStatement */:
14009
+ return 1 /* Definite */;
14010
+ }
14011
+ }
13994
14012
  function isAssignmentTarget(node) {
13995
- return getAssignmentTargetKind(node) !== 0 /* None */;
14013
+ return !!getAssignmentTarget(node);
14014
+ }
14015
+ function isCompoundLikeAssignment(assignment) {
14016
+ const right = skipParentheses(assignment.right);
14017
+ return right.kind === 226 /* BinaryExpression */ && isShiftOperatorOrHigher(right.operatorToken.kind);
14018
+ }
14019
+ function isInCompoundLikeAssignment(node) {
14020
+ const target = getAssignmentTarget(node);
14021
+ return !!target && isAssignmentExpression(
14022
+ target,
14023
+ /*excludeCompoundAssignment*/
14024
+ true
14025
+ ) && isCompoundLikeAssignment(target);
13996
14026
  }
13997
14027
  function isNodeWithPossibleHoistedDeclaration(node) {
13998
14028
  switch (node.kind) {
@@ -16047,13 +16077,11 @@ function setLocalizedDiagnosticMessages(messages) {
16047
16077
  function getLocaleSpecificMessage(message) {
16048
16078
  return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
16049
16079
  }
16050
- function createDetachedDiagnostic(fileName, start, length2, message, ...args) {
16051
- assertDiagnosticLocation(
16052
- /*file*/
16053
- void 0,
16054
- start,
16055
- length2
16056
- );
16080
+ function createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args) {
16081
+ if (start + length2 > sourceText.length) {
16082
+ length2 = sourceText.length - start;
16083
+ }
16084
+ assertDiagnosticLocation(sourceText, start, length2);
16057
16085
  let text = getLocaleSpecificMessage(message);
16058
16086
  if (some(args)) {
16059
16087
  text = formatStringFromArgs(text, args);
@@ -16109,7 +16137,7 @@ function attachFileToDiagnostics(diagnostics, file) {
16109
16137
  return diagnosticsWithLocation;
16110
16138
  }
16111
16139
  function createFileDiagnostic(file, start, length2, message, ...args) {
16112
- assertDiagnosticLocation(file, start, length2);
16140
+ assertDiagnosticLocation(file.text, start, length2);
16113
16141
  let text = getLocaleSpecificMessage(message);
16114
16142
  if (some(args)) {
16115
16143
  text = formatStringFromArgs(text, args);
@@ -26639,7 +26667,7 @@ var Parser;
26639
26667
  }
26640
26668
  return sourceFile;
26641
26669
  function reportPragmaDiagnostic(pos, end, diagnostic) {
26642
- parseDiagnostics.push(createDetachedDiagnostic(fileName, pos, end, diagnostic));
26670
+ parseDiagnostics.push(createDetachedDiagnostic(fileName, sourceText, pos, end, diagnostic));
26643
26671
  }
26644
26672
  }
26645
26673
  let hasDeprecatedTag = false;
@@ -26879,7 +26907,7 @@ var Parser;
26879
26907
  const lastError = lastOrUndefined(parseDiagnostics);
26880
26908
  let result;
26881
26909
  if (!lastError || start !== lastError.start) {
26882
- result = createDetachedDiagnostic(fileName, start, length2, message, ...args);
26910
+ result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
26883
26911
  parseDiagnostics.push(result);
26884
26912
  }
26885
26913
  parseErrorBeforeNextFinishedNode = true;
@@ -27107,7 +27135,7 @@ var Parser;
27107
27135
  if (lastError) {
27108
27136
  addRelatedInfo(
27109
27137
  lastError,
27110
- createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
27138
+ createDetachedDiagnostic(fileName, sourceText, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
27111
27139
  );
27112
27140
  }
27113
27141
  }
@@ -28706,7 +28734,7 @@ var Parser;
28706
28734
  if (lastError && lastError.code === Diagnostics._0_expected.code) {
28707
28735
  addRelatedInfo(
28708
28736
  lastError,
28709
- createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
28737
+ createDetachedDiagnostic(fileName, sourceText, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
28710
28738
  );
28711
28739
  }
28712
28740
  }
@@ -31823,7 +31851,7 @@ var Parser;
31823
31851
  if (lastError && lastError.code === Diagnostics._0_expected.code) {
31824
31852
  addRelatedInfo(
31825
31853
  lastError,
31826
- createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
31854
+ createDetachedDiagnostic(fileName, sourceText, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
31827
31855
  );
31828
31856
  }
31829
31857
  }
@@ -32802,7 +32830,7 @@ var Parser;
32802
32830
  if (childTypeTag) {
32803
32831
  const lastError = parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
32804
32832
  if (lastError) {
32805
- addRelatedInfo(lastError, createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here));
32833
+ addRelatedInfo(lastError, createDetachedDiagnostic(fileName, sourceText, 0, 0, Diagnostics.The_tag_was_first_specified_here));
32806
32834
  }
32807
32835
  break;
32808
32836
  } else {
@@ -52302,7 +52330,7 @@ function createTypeChecker(host) {
52302
52330
  return checkFlags & 2 /* SyntheticProperty */ ? checkFlags & 65536 /* DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : (
52303
52331
  // NOTE: cast to TransientSymbol should be safe because only TransientSymbols can have CheckFlags.SyntheticProperty
52304
52332
  symbol.links.writeType || symbol.links.type
52305
- ) : getTypeOfSymbol(symbol);
52333
+ ) : removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */));
52306
52334
  }
52307
52335
  if (symbol.flags & 98304 /* Accessor */) {
52308
52336
  return checkFlags & 1 /* Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol);
@@ -63513,7 +63541,6 @@ function createTypeChecker(host) {
63513
63541
  let bivariant = false;
63514
63542
  let propagationType;
63515
63543
  let inferencePriority = 2048 /* MaxValue */;
63516
- let allowComplexConstraintInference = true;
63517
63544
  let visited;
63518
63545
  let sourceStack;
63519
63546
  let targetStack;
@@ -63668,8 +63695,7 @@ function createTypeChecker(host) {
63668
63695
  source = getReducedType(source);
63669
63696
  if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) {
63670
63697
  const apparentSource = getApparentType(source);
63671
- if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) {
63672
- allowComplexConstraintInference = false;
63698
+ if (apparentSource !== source && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) {
63673
63699
  return inferFromTypes(apparentSource, target);
63674
63700
  }
63675
63701
  source = apparentSource;
@@ -65313,10 +65339,11 @@ function createTypeChecker(host) {
65313
65339
  const assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow));
65314
65340
  return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
65315
65341
  }
65316
- if (declaredType.flags & 1048576 /* Union */) {
65317
- return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
65342
+ const t = isInCompoundLikeAssignment(node) ? getBaseTypeOfLiteralType(declaredType) : declaredType;
65343
+ if (t.flags & 1048576 /* Union */) {
65344
+ return getAssignmentReducedType(t, getInitialOrAssignedType(flow));
65318
65345
  }
65319
- return declaredType;
65346
+ return t;
65320
65347
  }
65321
65348
  if (containsMatchingReference(reference, node)) {
65322
65349
  if (!isReachableFlowNode(flow)) {
@@ -66179,7 +66206,15 @@ function createTypeChecker(host) {
66179
66206
  location = location.parent;
66180
66207
  }
66181
66208
  if (isExpressionNode(location) && (!isAssignmentTarget(location) || isWriteAccess(location))) {
66182
- const type = removeOptionalTypeMarker(getTypeOfExpression(location));
66209
+ const type = removeOptionalTypeMarker(
66210
+ isWriteAccess(location) && location.kind === 211 /* PropertyAccessExpression */ ? checkPropertyAccessExpression(
66211
+ location,
66212
+ /*checkMode*/
66213
+ void 0,
66214
+ /*writeOnly*/
66215
+ true
66216
+ ) : getTypeOfExpression(location)
66217
+ );
66183
66218
  if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
66184
66219
  return type;
66185
66220
  }
@@ -66440,7 +66475,7 @@ function createTypeChecker(host) {
66440
66475
  const isAlias = localOrExportSymbol.flags & 2097152 /* Alias */;
66441
66476
  if (localOrExportSymbol.flags & 3 /* Variable */) {
66442
66477
  if (assignmentKind === 1 /* Definite */) {
66443
- return type;
66478
+ return isInCompoundLikeAssignment(node) ? getBaseTypeOfLiteralType(type) : type;
66444
66479
  }
66445
66480
  } else if (isAlias) {
66446
66481
  declaration = getDeclarationOfAliasSymbol(symbol);
@@ -67535,8 +67570,19 @@ function createTypeChecker(host) {
67535
67570
  contextualType,
67536
67571
  concatenate(
67537
67572
  map(
67538
- filter(node.properties, (p) => !!p.symbol && p.kind === 303 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName)),
67539
- (prop) => [() => getContextFreeTypeOfExpression(prop.initializer), prop.symbol.escapedName]
67573
+ filter(node.properties, (p) => {
67574
+ if (!p.symbol) {
67575
+ return false;
67576
+ }
67577
+ if (p.kind === 303 /* PropertyAssignment */) {
67578
+ return isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName);
67579
+ }
67580
+ if (p.kind === 304 /* ShorthandPropertyAssignment */) {
67581
+ return isDiscriminantProperty(contextualType, p.symbol.escapedName);
67582
+ }
67583
+ return false;
67584
+ }),
67585
+ (prop) => [() => getContextFreeTypeOfExpression(prop.kind === 303 /* PropertyAssignment */ ? prop.initializer : prop.name), prop.symbol.escapedName]
67540
67586
  ),
67541
67587
  map(
67542
67588
  filter(getPropertiesOfType(contextualType), (s) => {
package/lib/tsserver.js CHANGED
@@ -1416,6 +1416,7 @@ __export(server_exports, {
1416
1416
  isImportTypeNode: () => isImportTypeNode,
1417
1417
  isImportableFile: () => isImportableFile,
1418
1418
  isInComment: () => isInComment,
1419
+ isInCompoundLikeAssignment: () => isInCompoundLikeAssignment,
1419
1420
  isInExpressionContext: () => isInExpressionContext,
1420
1421
  isInJSDoc: () => isInJSDoc,
1421
1422
  isInJSFile: () => isInJSFile,
@@ -1709,6 +1710,7 @@ __export(server_exports, {
1709
1710
  isSetAccessor: () => isSetAccessor,
1710
1711
  isSetAccessorDeclaration: () => isSetAccessorDeclaration,
1711
1712
  isShebangTrivia: () => isShebangTrivia,
1713
+ isShiftOperatorOrHigher: () => isShiftOperatorOrHigher,
1712
1714
  isShorthandAmbientModuleSymbol: () => isShorthandAmbientModuleSymbol,
1713
1715
  isShorthandPropertyAssignment: () => isShorthandPropertyAssignment,
1714
1716
  isSignedNumericLiteral: () => isSignedNumericLiteral,
@@ -2331,7 +2333,7 @@ module.exports = __toCommonJS(server_exports);
2331
2333
 
2332
2334
  // src/compiler/corePublic.ts
2333
2335
  var versionMajorMinor = "5.3";
2334
- var version = `${versionMajorMinor}.0-dev.20230815`;
2336
+ var version = `${versionMajorMinor}.0-dev.20230816`;
2335
2337
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2336
2338
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2337
2339
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -16244,16 +16246,14 @@ function createDiagnosticForNodeArrayFromMessageChain(sourceFile, nodes, message
16244
16246
  const start2 = skipTrivia(sourceFile.text, nodes.pos);
16245
16247
  return createFileDiagnosticFromMessageChain(sourceFile, start2, nodes.end - start2, messageChain, relatedInformation);
16246
16248
  }
16247
- function assertDiagnosticLocation(file, start2, length2) {
16249
+ function assertDiagnosticLocation(sourceText, start2, length2) {
16248
16250
  Debug.assertGreaterThanOrEqual(start2, 0);
16249
16251
  Debug.assertGreaterThanOrEqual(length2, 0);
16250
- if (file) {
16251
- Debug.assertLessThanOrEqual(start2, file.text.length);
16252
- Debug.assertLessThanOrEqual(start2 + length2, file.text.length);
16253
- }
16252
+ Debug.assertLessThanOrEqual(start2, sourceText.length);
16253
+ Debug.assertLessThanOrEqual(start2 + length2, sourceText.length);
16254
16254
  }
16255
16255
  function createFileDiagnosticFromMessageChain(file, start2, length2, messageChain, relatedInformation) {
16256
- assertDiagnosticLocation(file, start2, length2);
16256
+ assertDiagnosticLocation(file.text, start2, length2);
16257
16257
  return {
16258
16258
  file,
16259
16259
  start: start2,
@@ -17128,8 +17128,8 @@ function isInExpressionContext(node) {
17128
17128
  return forStatement.initializer === node && forStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forStatement.condition === node || forStatement.incrementor === node;
17129
17129
  case 249 /* ForInStatement */:
17130
17130
  case 250 /* ForOfStatement */:
17131
- const forInStatement = parent2;
17132
- return forInStatement.initializer === node && forInStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forInStatement.expression === node;
17131
+ const forInOrOfStatement = parent2;
17132
+ return forInOrOfStatement.initializer === node && forInOrOfStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forInOrOfStatement.expression === node;
17133
17133
  case 216 /* TypeAssertionExpression */:
17134
17134
  case 234 /* AsExpression */:
17135
17135
  return node === parent2.expression;
@@ -17825,20 +17825,23 @@ var AssignmentKind = /* @__PURE__ */ ((AssignmentKind2) => {
17825
17825
  AssignmentKind2[AssignmentKind2["Compound"] = 2] = "Compound";
17826
17826
  return AssignmentKind2;
17827
17827
  })(AssignmentKind || {});
17828
- function getAssignmentTargetKind(node) {
17828
+ function getAssignmentTarget(node) {
17829
17829
  let parent2 = node.parent;
17830
17830
  while (true) {
17831
17831
  switch (parent2.kind) {
17832
17832
  case 226 /* BinaryExpression */:
17833
- const binaryOperator = parent2.operatorToken.kind;
17834
- return isAssignmentOperator(binaryOperator) && parent2.left === node ? binaryOperator === 64 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */;
17833
+ const binaryExpression = parent2;
17834
+ const binaryOperator = binaryExpression.operatorToken.kind;
17835
+ return isAssignmentOperator(binaryOperator) && binaryExpression.left === node ? binaryExpression : void 0;
17835
17836
  case 224 /* PrefixUnaryExpression */:
17836
17837
  case 225 /* PostfixUnaryExpression */:
17837
- const unaryOperator = parent2.operator;
17838
- return unaryOperator === 46 /* PlusPlusToken */ || unaryOperator === 47 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */;
17838
+ const unaryExpression = parent2;
17839
+ const unaryOperator = unaryExpression.operator;
17840
+ return unaryOperator === 46 /* PlusPlusToken */ || unaryOperator === 47 /* MinusMinusToken */ ? unaryExpression : void 0;
17839
17841
  case 249 /* ForInStatement */:
17840
17842
  case 250 /* ForOfStatement */:
17841
- return parent2.initializer === node ? 1 /* Definite */ : 0 /* None */;
17843
+ const forInOrOfStatement = parent2;
17844
+ return forInOrOfStatement.initializer === node ? forInOrOfStatement : void 0;
17842
17845
  case 217 /* ParenthesizedExpression */:
17843
17846
  case 209 /* ArrayLiteralExpression */:
17844
17847
  case 230 /* SpreadElement */:
@@ -17850,24 +17853,53 @@ function getAssignmentTargetKind(node) {
17850
17853
  break;
17851
17854
  case 304 /* ShorthandPropertyAssignment */:
17852
17855
  if (parent2.name !== node) {
17853
- return 0 /* None */;
17856
+ return void 0;
17854
17857
  }
17855
17858
  node = parent2.parent;
17856
17859
  break;
17857
17860
  case 303 /* PropertyAssignment */:
17858
17861
  if (parent2.name === node) {
17859
- return 0 /* None */;
17862
+ return void 0;
17860
17863
  }
17861
17864
  node = parent2.parent;
17862
17865
  break;
17863
17866
  default:
17864
- return 0 /* None */;
17867
+ return void 0;
17865
17868
  }
17866
17869
  parent2 = node.parent;
17867
17870
  }
17868
17871
  }
17872
+ function getAssignmentTargetKind(node) {
17873
+ const target = getAssignmentTarget(node);
17874
+ if (!target) {
17875
+ return 0 /* None */;
17876
+ }
17877
+ switch (target.kind) {
17878
+ case 226 /* BinaryExpression */:
17879
+ const binaryOperator = target.operatorToken.kind;
17880
+ return binaryOperator === 64 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */;
17881
+ case 224 /* PrefixUnaryExpression */:
17882
+ case 225 /* PostfixUnaryExpression */:
17883
+ return 2 /* Compound */;
17884
+ case 249 /* ForInStatement */:
17885
+ case 250 /* ForOfStatement */:
17886
+ return 1 /* Definite */;
17887
+ }
17888
+ }
17869
17889
  function isAssignmentTarget(node) {
17870
- return getAssignmentTargetKind(node) !== 0 /* None */;
17890
+ return !!getAssignmentTarget(node);
17891
+ }
17892
+ function isCompoundLikeAssignment(assignment) {
17893
+ const right = skipParentheses(assignment.right);
17894
+ return right.kind === 226 /* BinaryExpression */ && isShiftOperatorOrHigher(right.operatorToken.kind);
17895
+ }
17896
+ function isInCompoundLikeAssignment(node) {
17897
+ const target = getAssignmentTarget(node);
17898
+ return !!target && isAssignmentExpression(
17899
+ target,
17900
+ /*excludeCompoundAssignment*/
17901
+ true
17902
+ ) && isCompoundLikeAssignment(target);
17871
17903
  }
17872
17904
  function isNodeWithPossibleHoistedDeclaration(node) {
17873
17905
  switch (node.kind) {
@@ -20183,13 +20215,11 @@ function maybeSetLocalizedDiagnosticMessages(getMessages) {
20183
20215
  function getLocaleSpecificMessage(message) {
20184
20216
  return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
20185
20217
  }
20186
- function createDetachedDiagnostic(fileName, start2, length2, message, ...args) {
20187
- assertDiagnosticLocation(
20188
- /*file*/
20189
- void 0,
20190
- start2,
20191
- length2
20192
- );
20218
+ function createDetachedDiagnostic(fileName, sourceText, start2, length2, message, ...args) {
20219
+ if (start2 + length2 > sourceText.length) {
20220
+ length2 = sourceText.length - start2;
20221
+ }
20222
+ assertDiagnosticLocation(sourceText, start2, length2);
20193
20223
  let text = getLocaleSpecificMessage(message);
20194
20224
  if (some(args)) {
20195
20225
  text = formatStringFromArgs(text, args);
@@ -20245,7 +20275,7 @@ function attachFileToDiagnostics(diagnostics, file) {
20245
20275
  return diagnosticsWithLocation;
20246
20276
  }
20247
20277
  function createFileDiagnostic(file, start2, length2, message, ...args) {
20248
- assertDiagnosticLocation(file, start2, length2);
20278
+ assertDiagnosticLocation(file.text, start2, length2);
20249
20279
  let text = getLocaleSpecificMessage(message);
20250
20280
  if (some(args)) {
20251
20281
  text = formatStringFromArgs(text, args);
@@ -31039,7 +31069,7 @@ var Parser;
31039
31069
  }
31040
31070
  return sourceFile;
31041
31071
  function reportPragmaDiagnostic(pos, end, diagnostic) {
31042
- parseDiagnostics.push(createDetachedDiagnostic(fileName, pos, end, diagnostic));
31072
+ parseDiagnostics.push(createDetachedDiagnostic(fileName, sourceText, pos, end, diagnostic));
31043
31073
  }
31044
31074
  }
31045
31075
  let hasDeprecatedTag = false;
@@ -31279,7 +31309,7 @@ var Parser;
31279
31309
  const lastError = lastOrUndefined(parseDiagnostics);
31280
31310
  let result;
31281
31311
  if (!lastError || start2 !== lastError.start) {
31282
- result = createDetachedDiagnostic(fileName, start2, length2, message, ...args);
31312
+ result = createDetachedDiagnostic(fileName, sourceText, start2, length2, message, ...args);
31283
31313
  parseDiagnostics.push(result);
31284
31314
  }
31285
31315
  parseErrorBeforeNextFinishedNode = true;
@@ -31507,7 +31537,7 @@ var Parser;
31507
31537
  if (lastError) {
31508
31538
  addRelatedInfo(
31509
31539
  lastError,
31510
- createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
31540
+ createDetachedDiagnostic(fileName, sourceText, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
31511
31541
  );
31512
31542
  }
31513
31543
  }
@@ -33106,7 +33136,7 @@ var Parser;
33106
33136
  if (lastError && lastError.code === Diagnostics._0_expected.code) {
33107
33137
  addRelatedInfo(
33108
33138
  lastError,
33109
- createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
33139
+ createDetachedDiagnostic(fileName, sourceText, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
33110
33140
  );
33111
33141
  }
33112
33142
  }
@@ -36223,7 +36253,7 @@ var Parser;
36223
36253
  if (lastError && lastError.code === Diagnostics._0_expected.code) {
36224
36254
  addRelatedInfo(
36225
36255
  lastError,
36226
- createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
36256
+ createDetachedDiagnostic(fileName, sourceText, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
36227
36257
  );
36228
36258
  }
36229
36259
  }
@@ -37202,7 +37232,7 @@ var Parser;
37202
37232
  if (childTypeTag) {
37203
37233
  const lastError = parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
37204
37234
  if (lastError) {
37205
- addRelatedInfo(lastError, createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here));
37235
+ addRelatedInfo(lastError, createDetachedDiagnostic(fileName, sourceText, 0, 0, Diagnostics.The_tag_was_first_specified_here));
37206
37236
  }
37207
37237
  break;
37208
37238
  } else {
@@ -57011,7 +57041,7 @@ function createTypeChecker(host) {
57011
57041
  return checkFlags & 2 /* SyntheticProperty */ ? checkFlags & 65536 /* DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : (
57012
57042
  // NOTE: cast to TransientSymbol should be safe because only TransientSymbols can have CheckFlags.SyntheticProperty
57013
57043
  symbol.links.writeType || symbol.links.type
57014
- ) : getTypeOfSymbol(symbol);
57044
+ ) : removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */));
57015
57045
  }
57016
57046
  if (symbol.flags & 98304 /* Accessor */) {
57017
57047
  return checkFlags & 1 /* Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol);
@@ -68222,7 +68252,6 @@ function createTypeChecker(host) {
68222
68252
  let bivariant = false;
68223
68253
  let propagationType;
68224
68254
  let inferencePriority = 2048 /* MaxValue */;
68225
- let allowComplexConstraintInference = true;
68226
68255
  let visited;
68227
68256
  let sourceStack;
68228
68257
  let targetStack;
@@ -68377,8 +68406,7 @@ function createTypeChecker(host) {
68377
68406
  source = getReducedType(source);
68378
68407
  if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) {
68379
68408
  const apparentSource = getApparentType(source);
68380
- if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) {
68381
- allowComplexConstraintInference = false;
68409
+ if (apparentSource !== source && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) {
68382
68410
  return inferFromTypes(apparentSource, target);
68383
68411
  }
68384
68412
  source = apparentSource;
@@ -70022,10 +70050,11 @@ function createTypeChecker(host) {
70022
70050
  const assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow));
70023
70051
  return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
70024
70052
  }
70025
- if (declaredType.flags & 1048576 /* Union */) {
70026
- return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
70053
+ const t = isInCompoundLikeAssignment(node) ? getBaseTypeOfLiteralType(declaredType) : declaredType;
70054
+ if (t.flags & 1048576 /* Union */) {
70055
+ return getAssignmentReducedType(t, getInitialOrAssignedType(flow));
70027
70056
  }
70028
- return declaredType;
70057
+ return t;
70029
70058
  }
70030
70059
  if (containsMatchingReference(reference, node)) {
70031
70060
  if (!isReachableFlowNode(flow)) {
@@ -70888,7 +70917,15 @@ function createTypeChecker(host) {
70888
70917
  location = location.parent;
70889
70918
  }
70890
70919
  if (isExpressionNode(location) && (!isAssignmentTarget(location) || isWriteAccess(location))) {
70891
- const type = removeOptionalTypeMarker(getTypeOfExpression(location));
70920
+ const type = removeOptionalTypeMarker(
70921
+ isWriteAccess(location) && location.kind === 211 /* PropertyAccessExpression */ ? checkPropertyAccessExpression(
70922
+ location,
70923
+ /*checkMode*/
70924
+ void 0,
70925
+ /*writeOnly*/
70926
+ true
70927
+ ) : getTypeOfExpression(location)
70928
+ );
70892
70929
  if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
70893
70930
  return type;
70894
70931
  }
@@ -71149,7 +71186,7 @@ function createTypeChecker(host) {
71149
71186
  const isAlias = localOrExportSymbol.flags & 2097152 /* Alias */;
71150
71187
  if (localOrExportSymbol.flags & 3 /* Variable */) {
71151
71188
  if (assignmentKind === 1 /* Definite */) {
71152
- return type;
71189
+ return isInCompoundLikeAssignment(node) ? getBaseTypeOfLiteralType(type) : type;
71153
71190
  }
71154
71191
  } else if (isAlias) {
71155
71192
  declaration = getDeclarationOfAliasSymbol(symbol);
@@ -72244,8 +72281,19 @@ function createTypeChecker(host) {
72244
72281
  contextualType,
72245
72282
  concatenate(
72246
72283
  map(
72247
- filter(node.properties, (p) => !!p.symbol && p.kind === 303 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName)),
72248
- (prop) => [() => getContextFreeTypeOfExpression(prop.initializer), prop.symbol.escapedName]
72284
+ filter(node.properties, (p) => {
72285
+ if (!p.symbol) {
72286
+ return false;
72287
+ }
72288
+ if (p.kind === 303 /* PropertyAssignment */) {
72289
+ return isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName);
72290
+ }
72291
+ if (p.kind === 304 /* ShorthandPropertyAssignment */) {
72292
+ return isDiscriminantProperty(contextualType, p.symbol.escapedName);
72293
+ }
72294
+ return false;
72295
+ }),
72296
+ (prop) => [() => getContextFreeTypeOfExpression(prop.kind === 303 /* PropertyAssignment */ ? prop.initializer : prop.name), prop.symbol.escapedName]
72249
72297
  ),
72250
72298
  map(
72251
72299
  filter(getPropertiesOfType(contextualType), (s) => {
@@ -164905,11 +164953,12 @@ function provideInlayHints(context) {
164905
164953
  if (!signature || !candidates.length) {
164906
164954
  return;
164907
164955
  }
164908
- let signatureParamPos = 0;
164909
164956
  const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : void 0;
164957
+ let signatureParamPos = 0;
164910
164958
  for (const originalArg of args) {
164911
164959
  const arg = skipParentheses(originalArg);
164912
164960
  if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
164961
+ signatureParamPos++;
164913
164962
  continue;
164914
164963
  }
164915
164964
  let spreadArgs = 0;
@@ -173490,6 +173539,7 @@ __export(ts_exports2, {
173490
173539
  isImportTypeNode: () => isImportTypeNode,
173491
173540
  isImportableFile: () => isImportableFile,
173492
173541
  isInComment: () => isInComment,
173542
+ isInCompoundLikeAssignment: () => isInCompoundLikeAssignment,
173493
173543
  isInExpressionContext: () => isInExpressionContext,
173494
173544
  isInJSDoc: () => isInJSDoc,
173495
173545
  isInJSFile: () => isInJSFile,
@@ -173783,6 +173833,7 @@ __export(ts_exports2, {
173783
173833
  isSetAccessor: () => isSetAccessor,
173784
173834
  isSetAccessorDeclaration: () => isSetAccessorDeclaration,
173785
173835
  isShebangTrivia: () => isShebangTrivia,
173836
+ isShiftOperatorOrHigher: () => isShiftOperatorOrHigher,
173786
173837
  isShorthandAmbientModuleSymbol: () => isShorthandAmbientModuleSymbol,
173787
173838
  isShorthandPropertyAssignment: () => isShorthandPropertyAssignment,
173788
173839
  isSignedNumericLiteral: () => isSignedNumericLiteral,
@@ -188019,6 +188070,7 @@ start(initializeNodeSystem(), require("os").platform());
188019
188070
  isImportTypeNode,
188020
188071
  isImportableFile,
188021
188072
  isInComment,
188073
+ isInCompoundLikeAssignment,
188022
188074
  isInExpressionContext,
188023
188075
  isInJSDoc,
188024
188076
  isInJSFile,
@@ -188312,6 +188364,7 @@ start(initializeNodeSystem(), require("os").platform());
188312
188364
  isSetAccessor,
188313
188365
  isSetAccessorDeclaration,
188314
188366
  isShebangTrivia,
188367
+ isShiftOperatorOrHigher,
188315
188368
  isShorthandAmbientModuleSymbol,
188316
188369
  isShorthandPropertyAssignment,
188317
188370
  isSignedNumericLiteral,
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.20230815`;
38
+ version = `${versionMajorMinor}.0-dev.20230816`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -14026,16 +14026,14 @@ ${lanes.join("\n")}
14026
14026
  const start = skipTrivia(sourceFile.text, nodes.pos);
14027
14027
  return createFileDiagnosticFromMessageChain(sourceFile, start, nodes.end - start, messageChain, relatedInformation);
14028
14028
  }
14029
- function assertDiagnosticLocation(file, start, length2) {
14029
+ function assertDiagnosticLocation(sourceText, start, length2) {
14030
14030
  Debug.assertGreaterThanOrEqual(start, 0);
14031
14031
  Debug.assertGreaterThanOrEqual(length2, 0);
14032
- if (file) {
14033
- Debug.assertLessThanOrEqual(start, file.text.length);
14034
- Debug.assertLessThanOrEqual(start + length2, file.text.length);
14035
- }
14032
+ Debug.assertLessThanOrEqual(start, sourceText.length);
14033
+ Debug.assertLessThanOrEqual(start + length2, sourceText.length);
14036
14034
  }
14037
14035
  function createFileDiagnosticFromMessageChain(file, start, length2, messageChain, relatedInformation) {
14038
- assertDiagnosticLocation(file, start, length2);
14036
+ assertDiagnosticLocation(file.text, start, length2);
14039
14037
  return {
14040
14038
  file,
14041
14039
  start,
@@ -14904,8 +14902,8 @@ ${lanes.join("\n")}
14904
14902
  return forStatement.initializer === node && forStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forStatement.condition === node || forStatement.incrementor === node;
14905
14903
  case 249 /* ForInStatement */:
14906
14904
  case 250 /* ForOfStatement */:
14907
- const forInStatement = parent2;
14908
- return forInStatement.initializer === node && forInStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forInStatement.expression === node;
14905
+ const forInOrOfStatement = parent2;
14906
+ return forInOrOfStatement.initializer === node && forInOrOfStatement.initializer.kind !== 261 /* VariableDeclarationList */ || forInOrOfStatement.expression === node;
14909
14907
  case 216 /* TypeAssertionExpression */:
14910
14908
  case 234 /* AsExpression */:
14911
14909
  return node === parent2.expression;
@@ -15595,20 +15593,23 @@ ${lanes.join("\n")}
15595
15593
  function hasTypeArguments(node) {
15596
15594
  return !!node.typeArguments;
15597
15595
  }
15598
- function getAssignmentTargetKind(node) {
15596
+ function getAssignmentTarget(node) {
15599
15597
  let parent2 = node.parent;
15600
15598
  while (true) {
15601
15599
  switch (parent2.kind) {
15602
15600
  case 226 /* BinaryExpression */:
15603
- const binaryOperator = parent2.operatorToken.kind;
15604
- return isAssignmentOperator(binaryOperator) && parent2.left === node ? binaryOperator === 64 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */;
15601
+ const binaryExpression = parent2;
15602
+ const binaryOperator = binaryExpression.operatorToken.kind;
15603
+ return isAssignmentOperator(binaryOperator) && binaryExpression.left === node ? binaryExpression : void 0;
15605
15604
  case 224 /* PrefixUnaryExpression */:
15606
15605
  case 225 /* PostfixUnaryExpression */:
15607
- const unaryOperator = parent2.operator;
15608
- return unaryOperator === 46 /* PlusPlusToken */ || unaryOperator === 47 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */;
15606
+ const unaryExpression = parent2;
15607
+ const unaryOperator = unaryExpression.operator;
15608
+ return unaryOperator === 46 /* PlusPlusToken */ || unaryOperator === 47 /* MinusMinusToken */ ? unaryExpression : void 0;
15609
15609
  case 249 /* ForInStatement */:
15610
15610
  case 250 /* ForOfStatement */:
15611
- return parent2.initializer === node ? 1 /* Definite */ : 0 /* None */;
15611
+ const forInOrOfStatement = parent2;
15612
+ return forInOrOfStatement.initializer === node ? forInOrOfStatement : void 0;
15612
15613
  case 217 /* ParenthesizedExpression */:
15613
15614
  case 209 /* ArrayLiteralExpression */:
15614
15615
  case 230 /* SpreadElement */:
@@ -15620,24 +15621,53 @@ ${lanes.join("\n")}
15620
15621
  break;
15621
15622
  case 304 /* ShorthandPropertyAssignment */:
15622
15623
  if (parent2.name !== node) {
15623
- return 0 /* None */;
15624
+ return void 0;
15624
15625
  }
15625
15626
  node = parent2.parent;
15626
15627
  break;
15627
15628
  case 303 /* PropertyAssignment */:
15628
15629
  if (parent2.name === node) {
15629
- return 0 /* None */;
15630
+ return void 0;
15630
15631
  }
15631
15632
  node = parent2.parent;
15632
15633
  break;
15633
15634
  default:
15634
- return 0 /* None */;
15635
+ return void 0;
15635
15636
  }
15636
15637
  parent2 = node.parent;
15637
15638
  }
15638
15639
  }
15640
+ function getAssignmentTargetKind(node) {
15641
+ const target = getAssignmentTarget(node);
15642
+ if (!target) {
15643
+ return 0 /* None */;
15644
+ }
15645
+ switch (target.kind) {
15646
+ case 226 /* BinaryExpression */:
15647
+ const binaryOperator = target.operatorToken.kind;
15648
+ return binaryOperator === 64 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */;
15649
+ case 224 /* PrefixUnaryExpression */:
15650
+ case 225 /* PostfixUnaryExpression */:
15651
+ return 2 /* Compound */;
15652
+ case 249 /* ForInStatement */:
15653
+ case 250 /* ForOfStatement */:
15654
+ return 1 /* Definite */;
15655
+ }
15656
+ }
15639
15657
  function isAssignmentTarget(node) {
15640
- return getAssignmentTargetKind(node) !== 0 /* None */;
15658
+ return !!getAssignmentTarget(node);
15659
+ }
15660
+ function isCompoundLikeAssignment(assignment) {
15661
+ const right = skipParentheses(assignment.right);
15662
+ return right.kind === 226 /* BinaryExpression */ && isShiftOperatorOrHigher(right.operatorToken.kind);
15663
+ }
15664
+ function isInCompoundLikeAssignment(node) {
15665
+ const target = getAssignmentTarget(node);
15666
+ return !!target && isAssignmentExpression(
15667
+ target,
15668
+ /*excludeCompoundAssignment*/
15669
+ true
15670
+ ) && isCompoundLikeAssignment(target);
15641
15671
  }
15642
15672
  function isNodeWithPossibleHoistedDeclaration(node) {
15643
15673
  switch (node.kind) {
@@ -17864,13 +17894,11 @@ ${lanes.join("\n")}
17864
17894
  function getLocaleSpecificMessage(message) {
17865
17895
  return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
17866
17896
  }
17867
- function createDetachedDiagnostic(fileName, start, length2, message, ...args) {
17868
- assertDiagnosticLocation(
17869
- /*file*/
17870
- void 0,
17871
- start,
17872
- length2
17873
- );
17897
+ function createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args) {
17898
+ if (start + length2 > sourceText.length) {
17899
+ length2 = sourceText.length - start;
17900
+ }
17901
+ assertDiagnosticLocation(sourceText, start, length2);
17874
17902
  let text = getLocaleSpecificMessage(message);
17875
17903
  if (some(args)) {
17876
17904
  text = formatStringFromArgs(text, args);
@@ -17926,7 +17954,7 @@ ${lanes.join("\n")}
17926
17954
  return diagnosticsWithLocation;
17927
17955
  }
17928
17956
  function createFileDiagnostic(file, start, length2, message, ...args) {
17929
- assertDiagnosticLocation(file, start, length2);
17957
+ assertDiagnosticLocation(file.text, start, length2);
17930
17958
  let text = getLocaleSpecificMessage(message);
17931
17959
  if (some(args)) {
17932
17960
  text = formatStringFromArgs(text, args);
@@ -29108,7 +29136,7 @@ ${lanes.join("\n")}
29108
29136
  }
29109
29137
  return sourceFile;
29110
29138
  function reportPragmaDiagnostic(pos, end, diagnostic) {
29111
- parseDiagnostics.push(createDetachedDiagnostic(fileName, pos, end, diagnostic));
29139
+ parseDiagnostics.push(createDetachedDiagnostic(fileName, sourceText, pos, end, diagnostic));
29112
29140
  }
29113
29141
  }
29114
29142
  let hasDeprecatedTag = false;
@@ -29348,7 +29376,7 @@ ${lanes.join("\n")}
29348
29376
  const lastError = lastOrUndefined(parseDiagnostics);
29349
29377
  let result;
29350
29378
  if (!lastError || start !== lastError.start) {
29351
- result = createDetachedDiagnostic(fileName, start, length2, message, ...args);
29379
+ result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
29352
29380
  parseDiagnostics.push(result);
29353
29381
  }
29354
29382
  parseErrorBeforeNextFinishedNode = true;
@@ -29576,7 +29604,7 @@ ${lanes.join("\n")}
29576
29604
  if (lastError) {
29577
29605
  addRelatedInfo(
29578
29606
  lastError,
29579
- createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
29607
+ createDetachedDiagnostic(fileName, sourceText, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
29580
29608
  );
29581
29609
  }
29582
29610
  }
@@ -31175,7 +31203,7 @@ ${lanes.join("\n")}
31175
31203
  if (lastError && lastError.code === Diagnostics._0_expected.code) {
31176
31204
  addRelatedInfo(
31177
31205
  lastError,
31178
- createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
31206
+ createDetachedDiagnostic(fileName, sourceText, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
31179
31207
  );
31180
31208
  }
31181
31209
  }
@@ -34292,7 +34320,7 @@ ${lanes.join("\n")}
34292
34320
  if (lastError && lastError.code === Diagnostics._0_expected.code) {
34293
34321
  addRelatedInfo(
34294
34322
  lastError,
34295
- createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
34323
+ createDetachedDiagnostic(fileName, sourceText, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
34296
34324
  );
34297
34325
  }
34298
34326
  }
@@ -35271,7 +35299,7 @@ ${lanes.join("\n")}
35271
35299
  if (childTypeTag) {
35272
35300
  const lastError = parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
35273
35301
  if (lastError) {
35274
- addRelatedInfo(lastError, createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here));
35302
+ addRelatedInfo(lastError, createDetachedDiagnostic(fileName, sourceText, 0, 0, Diagnostics.The_tag_was_first_specified_here));
35275
35303
  }
35276
35304
  break;
35277
35305
  } else {
@@ -54774,7 +54802,7 @@ ${lanes.join("\n")}
54774
54802
  return checkFlags & 2 /* SyntheticProperty */ ? checkFlags & 65536 /* DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : (
54775
54803
  // NOTE: cast to TransientSymbol should be safe because only TransientSymbols can have CheckFlags.SyntheticProperty
54776
54804
  symbol.links.writeType || symbol.links.type
54777
- ) : getTypeOfSymbol(symbol);
54805
+ ) : removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */));
54778
54806
  }
54779
54807
  if (symbol.flags & 98304 /* Accessor */) {
54780
54808
  return checkFlags & 1 /* Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol);
@@ -65985,7 +66013,6 @@ ${lanes.join("\n")}
65985
66013
  let bivariant = false;
65986
66014
  let propagationType;
65987
66015
  let inferencePriority = 2048 /* MaxValue */;
65988
- let allowComplexConstraintInference = true;
65989
66016
  let visited;
65990
66017
  let sourceStack;
65991
66018
  let targetStack;
@@ -66140,8 +66167,7 @@ ${lanes.join("\n")}
66140
66167
  source = getReducedType(source);
66141
66168
  if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) {
66142
66169
  const apparentSource = getApparentType(source);
66143
- if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) {
66144
- allowComplexConstraintInference = false;
66170
+ if (apparentSource !== source && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) {
66145
66171
  return inferFromTypes(apparentSource, target);
66146
66172
  }
66147
66173
  source = apparentSource;
@@ -67785,10 +67811,11 @@ ${lanes.join("\n")}
67785
67811
  const assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow));
67786
67812
  return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
67787
67813
  }
67788
- if (declaredType.flags & 1048576 /* Union */) {
67789
- return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
67814
+ const t = isInCompoundLikeAssignment(node) ? getBaseTypeOfLiteralType(declaredType) : declaredType;
67815
+ if (t.flags & 1048576 /* Union */) {
67816
+ return getAssignmentReducedType(t, getInitialOrAssignedType(flow));
67790
67817
  }
67791
- return declaredType;
67818
+ return t;
67792
67819
  }
67793
67820
  if (containsMatchingReference(reference, node)) {
67794
67821
  if (!isReachableFlowNode(flow)) {
@@ -68651,7 +68678,15 @@ ${lanes.join("\n")}
68651
68678
  location = location.parent;
68652
68679
  }
68653
68680
  if (isExpressionNode(location) && (!isAssignmentTarget(location) || isWriteAccess(location))) {
68654
- const type = removeOptionalTypeMarker(getTypeOfExpression(location));
68681
+ const type = removeOptionalTypeMarker(
68682
+ isWriteAccess(location) && location.kind === 211 /* PropertyAccessExpression */ ? checkPropertyAccessExpression(
68683
+ location,
68684
+ /*checkMode*/
68685
+ void 0,
68686
+ /*writeOnly*/
68687
+ true
68688
+ ) : getTypeOfExpression(location)
68689
+ );
68655
68690
  if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
68656
68691
  return type;
68657
68692
  }
@@ -68912,7 +68947,7 @@ ${lanes.join("\n")}
68912
68947
  const isAlias = localOrExportSymbol.flags & 2097152 /* Alias */;
68913
68948
  if (localOrExportSymbol.flags & 3 /* Variable */) {
68914
68949
  if (assignmentKind === 1 /* Definite */) {
68915
- return type;
68950
+ return isInCompoundLikeAssignment(node) ? getBaseTypeOfLiteralType(type) : type;
68916
68951
  }
68917
68952
  } else if (isAlias) {
68918
68953
  declaration = getDeclarationOfAliasSymbol(symbol);
@@ -70007,8 +70042,19 @@ ${lanes.join("\n")}
70007
70042
  contextualType,
70008
70043
  concatenate(
70009
70044
  map(
70010
- filter(node.properties, (p) => !!p.symbol && p.kind === 303 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName)),
70011
- (prop) => [() => getContextFreeTypeOfExpression(prop.initializer), prop.symbol.escapedName]
70045
+ filter(node.properties, (p) => {
70046
+ if (!p.symbol) {
70047
+ return false;
70048
+ }
70049
+ if (p.kind === 303 /* PropertyAssignment */) {
70050
+ return isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName);
70051
+ }
70052
+ if (p.kind === 304 /* ShorthandPropertyAssignment */) {
70053
+ return isDiscriminantProperty(contextualType, p.symbol.escapedName);
70054
+ }
70055
+ return false;
70056
+ }),
70057
+ (prop) => [() => getContextFreeTypeOfExpression(prop.kind === 303 /* PropertyAssignment */ ? prop.initializer : prop.name), prop.symbol.escapedName]
70012
70058
  ),
70013
70059
  map(
70014
70060
  filter(getPropertiesOfType(contextualType), (s) => {
@@ -164253,11 +164299,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164253
164299
  if (!signature || !candidates.length) {
164254
164300
  return;
164255
164301
  }
164256
- let signatureParamPos = 0;
164257
164302
  const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : void 0;
164303
+ let signatureParamPos = 0;
164258
164304
  for (const originalArg of args) {
164259
164305
  const arg = skipParentheses(originalArg);
164260
164306
  if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
164307
+ signatureParamPos++;
164261
164308
  continue;
164262
164309
  }
164263
164310
  let spreadArgs = 0;
@@ -184638,6 +184685,7 @@ ${e.message}`;
184638
184685
  isImportTypeNode: () => isImportTypeNode,
184639
184686
  isImportableFile: () => isImportableFile,
184640
184687
  isInComment: () => isInComment,
184688
+ isInCompoundLikeAssignment: () => isInCompoundLikeAssignment,
184641
184689
  isInExpressionContext: () => isInExpressionContext,
184642
184690
  isInJSDoc: () => isInJSDoc,
184643
184691
  isInJSFile: () => isInJSFile,
@@ -184931,6 +184979,7 @@ ${e.message}`;
184931
184979
  isSetAccessor: () => isSetAccessor,
184932
184980
  isSetAccessorDeclaration: () => isSetAccessorDeclaration,
184933
184981
  isShebangTrivia: () => isShebangTrivia,
184982
+ isShiftOperatorOrHigher: () => isShiftOperatorOrHigher,
184934
184983
  isShorthandAmbientModuleSymbol: () => isShorthandAmbientModuleSymbol,
184935
184984
  isShorthandPropertyAssignment: () => isShorthandPropertyAssignment,
184936
184985
  isSignedNumericLiteral: () => isSignedNumericLiteral,
@@ -187045,6 +187094,7 @@ ${e.message}`;
187045
187094
  isImportTypeNode: () => isImportTypeNode,
187046
187095
  isImportableFile: () => isImportableFile,
187047
187096
  isInComment: () => isInComment,
187097
+ isInCompoundLikeAssignment: () => isInCompoundLikeAssignment,
187048
187098
  isInExpressionContext: () => isInExpressionContext,
187049
187099
  isInJSDoc: () => isInJSDoc,
187050
187100
  isInJSFile: () => isInJSFile,
@@ -187338,6 +187388,7 @@ ${e.message}`;
187338
187388
  isSetAccessor: () => isSetAccessor,
187339
187389
  isSetAccessorDeclaration: () => isSetAccessorDeclaration,
187340
187390
  isShebangTrivia: () => isShebangTrivia,
187391
+ isShiftOperatorOrHigher: () => isShiftOperatorOrHigher,
187341
187392
  isShorthandAmbientModuleSymbol: () => isShorthandAmbientModuleSymbol,
187342
187393
  isShorthandPropertyAssignment: () => isShorthandPropertyAssignment,
187343
187394
  isSignedNumericLiteral: () => isSignedNumericLiteral,
@@ -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.20230815`;
57
+ var version = `${versionMajorMinor}.0-dev.20230816`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -10169,13 +10169,11 @@ function createDiagnosticForNodeInSourceFile(sourceFile, node, message, ...args)
10169
10169
  const span = getErrorSpanForNode(sourceFile, node);
10170
10170
  return createFileDiagnostic(sourceFile, span.start, span.length, message, ...args);
10171
10171
  }
10172
- function assertDiagnosticLocation(file, start, length2) {
10172
+ function assertDiagnosticLocation(sourceText, start, length2) {
10173
10173
  Debug.assertGreaterThanOrEqual(start, 0);
10174
10174
  Debug.assertGreaterThanOrEqual(length2, 0);
10175
- if (file) {
10176
- Debug.assertLessThanOrEqual(start, file.text.length);
10177
- Debug.assertLessThanOrEqual(start + length2, file.text.length);
10178
- }
10175
+ Debug.assertLessThanOrEqual(start, sourceText.length);
10176
+ Debug.assertLessThanOrEqual(start + length2, sourceText.length);
10179
10177
  }
10180
10178
  function getSpanOfTokenAtPosition(sourceFile, pos) {
10181
10179
  const scanner = createScanner(
@@ -11164,13 +11162,11 @@ var localizedDiagnosticMessages;
11164
11162
  function getLocaleSpecificMessage(message) {
11165
11163
  return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
11166
11164
  }
11167
- function createDetachedDiagnostic(fileName, start, length2, message, ...args) {
11168
- assertDiagnosticLocation(
11169
- /*file*/
11170
- void 0,
11171
- start,
11172
- length2
11173
- );
11165
+ function createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args) {
11166
+ if (start + length2 > sourceText.length) {
11167
+ length2 = sourceText.length - start;
11168
+ }
11169
+ assertDiagnosticLocation(sourceText, start, length2);
11174
11170
  let text = getLocaleSpecificMessage(message);
11175
11171
  if (some(args)) {
11176
11172
  text = formatStringFromArgs(text, args);
@@ -11226,7 +11222,7 @@ function attachFileToDiagnostics(diagnostics, file) {
11226
11222
  return diagnosticsWithLocation;
11227
11223
  }
11228
11224
  function createFileDiagnostic(file, start, length2, message, ...args) {
11229
- assertDiagnosticLocation(file, start, length2);
11225
+ assertDiagnosticLocation(file.text, start, length2);
11230
11226
  let text = getLocaleSpecificMessage(message);
11231
11227
  if (some(args)) {
11232
11228
  text = formatStringFromArgs(text, args);
@@ -18525,7 +18521,7 @@ var Parser;
18525
18521
  }
18526
18522
  return sourceFile;
18527
18523
  function reportPragmaDiagnostic(pos, end, diagnostic) {
18528
- parseDiagnostics.push(createDetachedDiagnostic(fileName, pos, end, diagnostic));
18524
+ parseDiagnostics.push(createDetachedDiagnostic(fileName, sourceText, pos, end, diagnostic));
18529
18525
  }
18530
18526
  }
18531
18527
  let hasDeprecatedTag = false;
@@ -18765,7 +18761,7 @@ var Parser;
18765
18761
  const lastError = lastOrUndefined(parseDiagnostics);
18766
18762
  let result;
18767
18763
  if (!lastError || start !== lastError.start) {
18768
- result = createDetachedDiagnostic(fileName, start, length2, message, ...args);
18764
+ result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
18769
18765
  parseDiagnostics.push(result);
18770
18766
  }
18771
18767
  parseErrorBeforeNextFinishedNode = true;
@@ -18993,7 +18989,7 @@ var Parser;
18993
18989
  if (lastError) {
18994
18990
  addRelatedInfo(
18995
18991
  lastError,
18996
- createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
18992
+ createDetachedDiagnostic(fileName, sourceText, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
18997
18993
  );
18998
18994
  }
18999
18995
  }
@@ -20592,7 +20588,7 @@ var Parser;
20592
20588
  if (lastError && lastError.code === Diagnostics._0_expected.code) {
20593
20589
  addRelatedInfo(
20594
20590
  lastError,
20595
- createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
20591
+ createDetachedDiagnostic(fileName, sourceText, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
20596
20592
  );
20597
20593
  }
20598
20594
  }
@@ -23709,7 +23705,7 @@ var Parser;
23709
23705
  if (lastError && lastError.code === Diagnostics._0_expected.code) {
23710
23706
  addRelatedInfo(
23711
23707
  lastError,
23712
- createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
23708
+ createDetachedDiagnostic(fileName, sourceText, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")
23713
23709
  );
23714
23710
  }
23715
23711
  }
@@ -24688,7 +24684,7 @@ var Parser;
24688
24684
  if (childTypeTag) {
24689
24685
  const lastError = parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
24690
24686
  if (lastError) {
24691
- addRelatedInfo(lastError, createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here));
24687
+ addRelatedInfo(lastError, createDetachedDiagnostic(fileName, sourceText, 0, 0, Diagnostics.The_tag_was_first_specified_here));
24692
24688
  }
24693
24689
  break;
24694
24690
  } else {
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.20230815",
5
+ "version": "5.3.0-dev.20230816",
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": "c5281bf7003abc09164a093ce643ae8ba422c40f"
116
+ "gitHead": "cac899d44d19a2753e6cae9ebc8bd291fa571c76"
117
117
  }