typescript 4.6.0-dev.20220116 → 4.6.0-dev.20220117

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
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.6";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220116";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220117";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  function tryGetNativeMap() {
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220116";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220117";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -145238,7 +145238,11 @@ var ts;
145238
145238
  oldTags[i] = merged;
145239
145239
  return !!merged;
145240
145240
  }); });
145241
- var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true)));
145241
+ var tags = __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true);
145242
+ var jsDoc = ts.singleOrUndefined(parent.jsDoc);
145243
+ var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
145244
+ ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
145245
+ var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
145242
145246
  var host = updateJSDocHost(parent);
145243
145247
  this.insertJsdocCommentBefore(sourceFile, host, tag);
145244
145248
  };
@@ -145668,6 +145672,8 @@ var ts;
145668
145672
  }
145669
145673
  case 339 /* JSDocReturnTag */:
145670
145674
  return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
145675
+ case 341 /* JSDocTypeTag */:
145676
+ return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
145671
145677
  }
145672
145678
  }
145673
145679
  // find first non-whitespace position in the leading trivia of the node
@@ -154131,35 +154137,34 @@ var ts;
154131
154137
  codefix.registerCodeFix({
154132
154138
  errorCodes: errorCodes,
154133
154139
  getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
154134
- var propertyDeclaration = getPropertyDeclaration(context.sourceFile, context.span.start);
154135
- if (!propertyDeclaration)
154140
+ var info = getInfo(context.sourceFile, context.span.start);
154141
+ if (!info)
154136
154142
  return;
154137
- var result = [
154138
- getActionForAddMissingUndefinedType(context, propertyDeclaration),
154139
- getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration)
154140
- ];
154141
- ts.append(result, getActionForAddMissingInitializer(context, propertyDeclaration));
154143
+ var result = [];
154144
+ ts.append(result, getActionForAddMissingUndefinedType(context, info));
154145
+ ts.append(result, getActionForAddMissingDefiniteAssignmentAssertion(context, info));
154146
+ ts.append(result, getActionForAddMissingInitializer(context, info));
154142
154147
  return result;
154143
154148
  },
154144
154149
  fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
154145
154150
  getAllCodeActions: function (context) {
154146
154151
  return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
154147
- var propertyDeclaration = getPropertyDeclaration(diag.file, diag.start);
154148
- if (!propertyDeclaration)
154152
+ var info = getInfo(diag.file, diag.start);
154153
+ if (!info)
154149
154154
  return;
154150
154155
  switch (context.fixId) {
154151
154156
  case fixIdAddDefiniteAssignmentAssertions:
154152
- addDefiniteAssignmentAssertion(changes, diag.file, propertyDeclaration);
154157
+ addDefiniteAssignmentAssertion(changes, diag.file, info.prop);
154153
154158
  break;
154154
154159
  case fixIdAddUndefinedType:
154155
- addUndefinedType(changes, diag.file, propertyDeclaration);
154160
+ addUndefinedType(changes, diag.file, info);
154156
154161
  break;
154157
154162
  case fixIdAddInitializer:
154158
154163
  var checker = context.program.getTypeChecker();
154159
- var initializer = getInitializer(checker, propertyDeclaration);
154164
+ var initializer = getInitializer(checker, info.prop);
154160
154165
  if (!initializer)
154161
154166
  return;
154162
- addInitializer(changes, diag.file, propertyDeclaration, initializer);
154167
+ addInitializer(changes, diag.file, info.prop, initializer);
154163
154168
  break;
154164
154169
  default:
154165
154170
  ts.Debug.fail(JSON.stringify(context.fixId));
@@ -154167,35 +154172,50 @@ var ts;
154167
154172
  });
154168
154173
  },
154169
154174
  });
154170
- function getPropertyDeclaration(sourceFile, pos) {
154175
+ function getInfo(sourceFile, pos) {
154171
154176
  var token = ts.getTokenAtPosition(sourceFile, pos);
154172
- return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined;
154177
+ if (ts.isIdentifier(token) && ts.isPropertyDeclaration(token.parent)) {
154178
+ var type = ts.getEffectiveTypeAnnotationNode(token.parent);
154179
+ if (type) {
154180
+ return { type: type, prop: token.parent, isJs: ts.isInJSFile(token.parent) };
154181
+ }
154182
+ }
154183
+ return undefined;
154173
154184
  }
154174
- function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) {
154175
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, propertyDeclaration); });
154176
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
154185
+ function getActionForAddMissingDefiniteAssignmentAssertion(context, info) {
154186
+ if (info.isJs)
154187
+ return undefined;
154188
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, info.prop); });
154189
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
154177
154190
  }
154178
154191
  function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
154179
154192
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
154180
154193
  changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
154181
154194
  }
154182
- function getActionForAddMissingUndefinedType(context, propertyDeclaration) {
154183
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, propertyDeclaration); });
154184
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
154195
+ function getActionForAddMissingUndefinedType(context, info) {
154196
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, info); });
154197
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
154185
154198
  }
154186
- function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
154199
+ function addUndefinedType(changeTracker, sourceFile, info) {
154187
154200
  var undefinedTypeNode = ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */);
154188
- var type = propertyDeclaration.type; // TODO: GH#18217
154189
- var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode];
154190
- changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types));
154201
+ var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode];
154202
+ var unionTypeNode = ts.factory.createUnionTypeNode(types);
154203
+ if (info.isJs) {
154204
+ changeTracker.addJSDocTags(sourceFile, info.prop, [ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(unionTypeNode))]);
154205
+ }
154206
+ else {
154207
+ changeTracker.replaceNode(sourceFile, info.type, unionTypeNode);
154208
+ }
154191
154209
  }
154192
- function getActionForAddMissingInitializer(context, propertyDeclaration) {
154210
+ function getActionForAddMissingInitializer(context, info) {
154211
+ if (info.isJs)
154212
+ return undefined;
154193
154213
  var checker = context.program.getTypeChecker();
154194
- var initializer = getInitializer(checker, propertyDeclaration);
154214
+ var initializer = getInitializer(checker, info.prop);
154195
154215
  if (!initializer)
154196
154216
  return undefined;
154197
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, propertyDeclaration, initializer); });
154198
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, propertyDeclaration.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
154217
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, info.prop, initializer); });
154218
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
154199
154219
  }
154200
154220
  function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
154201
154221
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220116";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220117";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -145849,7 +145849,11 @@ var ts;
145849
145849
  oldTags[i] = merged;
145850
145850
  return !!merged;
145851
145851
  }); });
145852
- var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true)));
145852
+ var tags = __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true);
145853
+ var jsDoc = ts.singleOrUndefined(parent.jsDoc);
145854
+ var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
145855
+ ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
145856
+ var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
145853
145857
  var host = updateJSDocHost(parent);
145854
145858
  this.insertJsdocCommentBefore(sourceFile, host, tag);
145855
145859
  };
@@ -146279,6 +146283,8 @@ var ts;
146279
146283
  }
146280
146284
  case 339 /* JSDocReturnTag */:
146281
146285
  return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
146286
+ case 341 /* JSDocTypeTag */:
146287
+ return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
146282
146288
  }
146283
146289
  }
146284
146290
  // find first non-whitespace position in the leading trivia of the node
@@ -154742,35 +154748,34 @@ var ts;
154742
154748
  codefix.registerCodeFix({
154743
154749
  errorCodes: errorCodes,
154744
154750
  getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
154745
- var propertyDeclaration = getPropertyDeclaration(context.sourceFile, context.span.start);
154746
- if (!propertyDeclaration)
154751
+ var info = getInfo(context.sourceFile, context.span.start);
154752
+ if (!info)
154747
154753
  return;
154748
- var result = [
154749
- getActionForAddMissingUndefinedType(context, propertyDeclaration),
154750
- getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration)
154751
- ];
154752
- ts.append(result, getActionForAddMissingInitializer(context, propertyDeclaration));
154754
+ var result = [];
154755
+ ts.append(result, getActionForAddMissingUndefinedType(context, info));
154756
+ ts.append(result, getActionForAddMissingDefiniteAssignmentAssertion(context, info));
154757
+ ts.append(result, getActionForAddMissingInitializer(context, info));
154753
154758
  return result;
154754
154759
  },
154755
154760
  fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
154756
154761
  getAllCodeActions: function (context) {
154757
154762
  return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
154758
- var propertyDeclaration = getPropertyDeclaration(diag.file, diag.start);
154759
- if (!propertyDeclaration)
154763
+ var info = getInfo(diag.file, diag.start);
154764
+ if (!info)
154760
154765
  return;
154761
154766
  switch (context.fixId) {
154762
154767
  case fixIdAddDefiniteAssignmentAssertions:
154763
- addDefiniteAssignmentAssertion(changes, diag.file, propertyDeclaration);
154768
+ addDefiniteAssignmentAssertion(changes, diag.file, info.prop);
154764
154769
  break;
154765
154770
  case fixIdAddUndefinedType:
154766
- addUndefinedType(changes, diag.file, propertyDeclaration);
154771
+ addUndefinedType(changes, diag.file, info);
154767
154772
  break;
154768
154773
  case fixIdAddInitializer:
154769
154774
  var checker = context.program.getTypeChecker();
154770
- var initializer = getInitializer(checker, propertyDeclaration);
154775
+ var initializer = getInitializer(checker, info.prop);
154771
154776
  if (!initializer)
154772
154777
  return;
154773
- addInitializer(changes, diag.file, propertyDeclaration, initializer);
154778
+ addInitializer(changes, diag.file, info.prop, initializer);
154774
154779
  break;
154775
154780
  default:
154776
154781
  ts.Debug.fail(JSON.stringify(context.fixId));
@@ -154778,35 +154783,50 @@ var ts;
154778
154783
  });
154779
154784
  },
154780
154785
  });
154781
- function getPropertyDeclaration(sourceFile, pos) {
154786
+ function getInfo(sourceFile, pos) {
154782
154787
  var token = ts.getTokenAtPosition(sourceFile, pos);
154783
- return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined;
154788
+ if (ts.isIdentifier(token) && ts.isPropertyDeclaration(token.parent)) {
154789
+ var type = ts.getEffectiveTypeAnnotationNode(token.parent);
154790
+ if (type) {
154791
+ return { type: type, prop: token.parent, isJs: ts.isInJSFile(token.parent) };
154792
+ }
154793
+ }
154794
+ return undefined;
154784
154795
  }
154785
- function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) {
154786
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, propertyDeclaration); });
154787
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
154796
+ function getActionForAddMissingDefiniteAssignmentAssertion(context, info) {
154797
+ if (info.isJs)
154798
+ return undefined;
154799
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, info.prop); });
154800
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
154788
154801
  }
154789
154802
  function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
154790
154803
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
154791
154804
  changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
154792
154805
  }
154793
- function getActionForAddMissingUndefinedType(context, propertyDeclaration) {
154794
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, propertyDeclaration); });
154795
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
154806
+ function getActionForAddMissingUndefinedType(context, info) {
154807
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, info); });
154808
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
154796
154809
  }
154797
- function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
154810
+ function addUndefinedType(changeTracker, sourceFile, info) {
154798
154811
  var undefinedTypeNode = ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */);
154799
- var type = propertyDeclaration.type; // TODO: GH#18217
154800
- var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode];
154801
- changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types));
154812
+ var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode];
154813
+ var unionTypeNode = ts.factory.createUnionTypeNode(types);
154814
+ if (info.isJs) {
154815
+ changeTracker.addJSDocTags(sourceFile, info.prop, [ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(unionTypeNode))]);
154816
+ }
154817
+ else {
154818
+ changeTracker.replaceNode(sourceFile, info.type, unionTypeNode);
154819
+ }
154802
154820
  }
154803
- function getActionForAddMissingInitializer(context, propertyDeclaration) {
154821
+ function getActionForAddMissingInitializer(context, info) {
154822
+ if (info.isJs)
154823
+ return undefined;
154804
154824
  var checker = context.program.getTypeChecker();
154805
- var initializer = getInitializer(checker, propertyDeclaration);
154825
+ var initializer = getInitializer(checker, info.prop);
154806
154826
  if (!initializer)
154807
154827
  return undefined;
154808
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, propertyDeclaration, initializer); });
154809
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, propertyDeclaration.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
154828
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, info.prop, initializer); });
154829
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
154810
154830
  }
154811
154831
  function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
154812
154832
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220116";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220117";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -145849,7 +145849,11 @@ var ts;
145849
145849
  oldTags[i] = merged;
145850
145850
  return !!merged;
145851
145851
  }); });
145852
- var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true)));
145852
+ var tags = __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true);
145853
+ var jsDoc = ts.singleOrUndefined(parent.jsDoc);
145854
+ var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
145855
+ ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
145856
+ var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
145853
145857
  var host = updateJSDocHost(parent);
145854
145858
  this.insertJsdocCommentBefore(sourceFile, host, tag);
145855
145859
  };
@@ -146279,6 +146283,8 @@ var ts;
146279
146283
  }
146280
146284
  case 339 /* JSDocReturnTag */:
146281
146285
  return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
146286
+ case 341 /* JSDocTypeTag */:
146287
+ return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
146282
146288
  }
146283
146289
  }
146284
146290
  // find first non-whitespace position in the leading trivia of the node
@@ -154742,35 +154748,34 @@ var ts;
154742
154748
  codefix.registerCodeFix({
154743
154749
  errorCodes: errorCodes,
154744
154750
  getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
154745
- var propertyDeclaration = getPropertyDeclaration(context.sourceFile, context.span.start);
154746
- if (!propertyDeclaration)
154751
+ var info = getInfo(context.sourceFile, context.span.start);
154752
+ if (!info)
154747
154753
  return;
154748
- var result = [
154749
- getActionForAddMissingUndefinedType(context, propertyDeclaration),
154750
- getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration)
154751
- ];
154752
- ts.append(result, getActionForAddMissingInitializer(context, propertyDeclaration));
154754
+ var result = [];
154755
+ ts.append(result, getActionForAddMissingUndefinedType(context, info));
154756
+ ts.append(result, getActionForAddMissingDefiniteAssignmentAssertion(context, info));
154757
+ ts.append(result, getActionForAddMissingInitializer(context, info));
154753
154758
  return result;
154754
154759
  },
154755
154760
  fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
154756
154761
  getAllCodeActions: function (context) {
154757
154762
  return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
154758
- var propertyDeclaration = getPropertyDeclaration(diag.file, diag.start);
154759
- if (!propertyDeclaration)
154763
+ var info = getInfo(diag.file, diag.start);
154764
+ if (!info)
154760
154765
  return;
154761
154766
  switch (context.fixId) {
154762
154767
  case fixIdAddDefiniteAssignmentAssertions:
154763
- addDefiniteAssignmentAssertion(changes, diag.file, propertyDeclaration);
154768
+ addDefiniteAssignmentAssertion(changes, diag.file, info.prop);
154764
154769
  break;
154765
154770
  case fixIdAddUndefinedType:
154766
- addUndefinedType(changes, diag.file, propertyDeclaration);
154771
+ addUndefinedType(changes, diag.file, info);
154767
154772
  break;
154768
154773
  case fixIdAddInitializer:
154769
154774
  var checker = context.program.getTypeChecker();
154770
- var initializer = getInitializer(checker, propertyDeclaration);
154775
+ var initializer = getInitializer(checker, info.prop);
154771
154776
  if (!initializer)
154772
154777
  return;
154773
- addInitializer(changes, diag.file, propertyDeclaration, initializer);
154778
+ addInitializer(changes, diag.file, info.prop, initializer);
154774
154779
  break;
154775
154780
  default:
154776
154781
  ts.Debug.fail(JSON.stringify(context.fixId));
@@ -154778,35 +154783,50 @@ var ts;
154778
154783
  });
154779
154784
  },
154780
154785
  });
154781
- function getPropertyDeclaration(sourceFile, pos) {
154786
+ function getInfo(sourceFile, pos) {
154782
154787
  var token = ts.getTokenAtPosition(sourceFile, pos);
154783
- return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined;
154788
+ if (ts.isIdentifier(token) && ts.isPropertyDeclaration(token.parent)) {
154789
+ var type = ts.getEffectiveTypeAnnotationNode(token.parent);
154790
+ if (type) {
154791
+ return { type: type, prop: token.parent, isJs: ts.isInJSFile(token.parent) };
154792
+ }
154793
+ }
154794
+ return undefined;
154784
154795
  }
154785
- function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) {
154786
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, propertyDeclaration); });
154787
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
154796
+ function getActionForAddMissingDefiniteAssignmentAssertion(context, info) {
154797
+ if (info.isJs)
154798
+ return undefined;
154799
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, info.prop); });
154800
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
154788
154801
  }
154789
154802
  function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
154790
154803
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
154791
154804
  changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
154792
154805
  }
154793
- function getActionForAddMissingUndefinedType(context, propertyDeclaration) {
154794
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, propertyDeclaration); });
154795
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
154806
+ function getActionForAddMissingUndefinedType(context, info) {
154807
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, info); });
154808
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
154796
154809
  }
154797
- function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
154810
+ function addUndefinedType(changeTracker, sourceFile, info) {
154798
154811
  var undefinedTypeNode = ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */);
154799
- var type = propertyDeclaration.type; // TODO: GH#18217
154800
- var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode];
154801
- changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types));
154812
+ var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode];
154813
+ var unionTypeNode = ts.factory.createUnionTypeNode(types);
154814
+ if (info.isJs) {
154815
+ changeTracker.addJSDocTags(sourceFile, info.prop, [ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(unionTypeNode))]);
154816
+ }
154817
+ else {
154818
+ changeTracker.replaceNode(sourceFile, info.type, unionTypeNode);
154819
+ }
154802
154820
  }
154803
- function getActionForAddMissingInitializer(context, propertyDeclaration) {
154821
+ function getActionForAddMissingInitializer(context, info) {
154822
+ if (info.isJs)
154823
+ return undefined;
154804
154824
  var checker = context.program.getTypeChecker();
154805
- var initializer = getInitializer(checker, propertyDeclaration);
154825
+ var initializer = getInitializer(checker, info.prop);
154806
154826
  if (!initializer)
154807
154827
  return undefined;
154808
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, propertyDeclaration, initializer); });
154809
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, propertyDeclaration.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
154828
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, info.prop, initializer); });
154829
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
154810
154830
  }
154811
154831
  function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
154812
154832
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220116";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220117";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -145849,7 +145849,11 @@ var ts;
145849
145849
  oldTags[i] = merged;
145850
145850
  return !!merged;
145851
145851
  }); });
145852
- var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true)));
145852
+ var tags = __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true);
145853
+ var jsDoc = ts.singleOrUndefined(parent.jsDoc);
145854
+ var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
145855
+ ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
145856
+ var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
145853
145857
  var host = updateJSDocHost(parent);
145854
145858
  this.insertJsdocCommentBefore(sourceFile, host, tag);
145855
145859
  };
@@ -146279,6 +146283,8 @@ var ts;
146279
146283
  }
146280
146284
  case 339 /* JSDocReturnTag */:
146281
146285
  return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
146286
+ case 341 /* JSDocTypeTag */:
146287
+ return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
146282
146288
  }
146283
146289
  }
146284
146290
  // find first non-whitespace position in the leading trivia of the node
@@ -154742,35 +154748,34 @@ var ts;
154742
154748
  codefix.registerCodeFix({
154743
154749
  errorCodes: errorCodes,
154744
154750
  getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
154745
- var propertyDeclaration = getPropertyDeclaration(context.sourceFile, context.span.start);
154746
- if (!propertyDeclaration)
154751
+ var info = getInfo(context.sourceFile, context.span.start);
154752
+ if (!info)
154747
154753
  return;
154748
- var result = [
154749
- getActionForAddMissingUndefinedType(context, propertyDeclaration),
154750
- getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration)
154751
- ];
154752
- ts.append(result, getActionForAddMissingInitializer(context, propertyDeclaration));
154754
+ var result = [];
154755
+ ts.append(result, getActionForAddMissingUndefinedType(context, info));
154756
+ ts.append(result, getActionForAddMissingDefiniteAssignmentAssertion(context, info));
154757
+ ts.append(result, getActionForAddMissingInitializer(context, info));
154753
154758
  return result;
154754
154759
  },
154755
154760
  fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
154756
154761
  getAllCodeActions: function (context) {
154757
154762
  return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
154758
- var propertyDeclaration = getPropertyDeclaration(diag.file, diag.start);
154759
- if (!propertyDeclaration)
154763
+ var info = getInfo(diag.file, diag.start);
154764
+ if (!info)
154760
154765
  return;
154761
154766
  switch (context.fixId) {
154762
154767
  case fixIdAddDefiniteAssignmentAssertions:
154763
- addDefiniteAssignmentAssertion(changes, diag.file, propertyDeclaration);
154768
+ addDefiniteAssignmentAssertion(changes, diag.file, info.prop);
154764
154769
  break;
154765
154770
  case fixIdAddUndefinedType:
154766
- addUndefinedType(changes, diag.file, propertyDeclaration);
154771
+ addUndefinedType(changes, diag.file, info);
154767
154772
  break;
154768
154773
  case fixIdAddInitializer:
154769
154774
  var checker = context.program.getTypeChecker();
154770
- var initializer = getInitializer(checker, propertyDeclaration);
154775
+ var initializer = getInitializer(checker, info.prop);
154771
154776
  if (!initializer)
154772
154777
  return;
154773
- addInitializer(changes, diag.file, propertyDeclaration, initializer);
154778
+ addInitializer(changes, diag.file, info.prop, initializer);
154774
154779
  break;
154775
154780
  default:
154776
154781
  ts.Debug.fail(JSON.stringify(context.fixId));
@@ -154778,35 +154783,50 @@ var ts;
154778
154783
  });
154779
154784
  },
154780
154785
  });
154781
- function getPropertyDeclaration(sourceFile, pos) {
154786
+ function getInfo(sourceFile, pos) {
154782
154787
  var token = ts.getTokenAtPosition(sourceFile, pos);
154783
- return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined;
154788
+ if (ts.isIdentifier(token) && ts.isPropertyDeclaration(token.parent)) {
154789
+ var type = ts.getEffectiveTypeAnnotationNode(token.parent);
154790
+ if (type) {
154791
+ return { type: type, prop: token.parent, isJs: ts.isInJSFile(token.parent) };
154792
+ }
154793
+ }
154794
+ return undefined;
154784
154795
  }
154785
- function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) {
154786
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, propertyDeclaration); });
154787
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
154796
+ function getActionForAddMissingDefiniteAssignmentAssertion(context, info) {
154797
+ if (info.isJs)
154798
+ return undefined;
154799
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, info.prop); });
154800
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
154788
154801
  }
154789
154802
  function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
154790
154803
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
154791
154804
  changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
154792
154805
  }
154793
- function getActionForAddMissingUndefinedType(context, propertyDeclaration) {
154794
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, propertyDeclaration); });
154795
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
154806
+ function getActionForAddMissingUndefinedType(context, info) {
154807
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, info); });
154808
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
154796
154809
  }
154797
- function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
154810
+ function addUndefinedType(changeTracker, sourceFile, info) {
154798
154811
  var undefinedTypeNode = ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */);
154799
- var type = propertyDeclaration.type; // TODO: GH#18217
154800
- var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode];
154801
- changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types));
154812
+ var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode];
154813
+ var unionTypeNode = ts.factory.createUnionTypeNode(types);
154814
+ if (info.isJs) {
154815
+ changeTracker.addJSDocTags(sourceFile, info.prop, [ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(unionTypeNode))]);
154816
+ }
154817
+ else {
154818
+ changeTracker.replaceNode(sourceFile, info.type, unionTypeNode);
154819
+ }
154802
154820
  }
154803
- function getActionForAddMissingInitializer(context, propertyDeclaration) {
154821
+ function getActionForAddMissingInitializer(context, info) {
154822
+ if (info.isJs)
154823
+ return undefined;
154804
154824
  var checker = context.program.getTypeChecker();
154805
- var initializer = getInitializer(checker, propertyDeclaration);
154825
+ var initializer = getInitializer(checker, info.prop);
154806
154826
  if (!initializer)
154807
154827
  return undefined;
154808
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, propertyDeclaration, initializer); });
154809
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, propertyDeclaration.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
154828
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, info.prop, initializer); });
154829
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
154810
154830
  }
154811
154831
  function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
154812
154832
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220116";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220117";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
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": "4.6.0-dev.20220116",
5
+ "version": "4.6.0-dev.20220117",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [