typescript 5.1.0-dev.20230320 → 5.1.0-dev.20230322

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.
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.1";
57
- var version = `${versionMajorMinor}.0-dev.20230320`;
57
+ var version = `${versionMajorMinor}.0-dev.20230322`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -6014,6 +6014,7 @@ var Diagnostics = {
6014
6014
  A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
6015
6015
  A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
6016
6016
  The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
6017
+ Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1: diag(2849, 1 /* Error */, "Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1_2849", "Target signature provides too few arguments. Expected {0} or more, but got {1}."),
6017
6018
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
6018
6019
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
6019
6020
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -6459,13 +6460,14 @@ var Diagnostics = {
6459
6460
  Output_Formatting: diag(6256, 3 /* Message */, "Output_Formatting_6256", "Output Formatting"),
6460
6461
  Completeness: diag(6257, 3 /* Message */, "Completeness_6257", "Completeness"),
6461
6462
  _0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file: diag(6258, 1 /* Error */, "_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file_6258", "'{0}' should be set inside the 'compilerOptions' object of the config json file"),
6462
- Found_1_error_in_1: diag(6259, 3 /* Message */, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
6463
+ Found_1_error_in_0: diag(6259, 3 /* Message */, "Found_1_error_in_0_6259", "Found 1 error in {0}"),
6463
6464
  Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, 3 /* Message */, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"),
6464
6465
  Found_0_errors_in_1_files: diag(6261, 3 /* Message */, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
6465
6466
  File_name_0_has_a_1_extension_looking_up_2_instead: diag(6262, 3 /* Message */, "File_name_0_has_a_1_extension_looking_up_2_instead_6262", "File name '{0}' has a '{1}' extension - looking up '{2}' instead."),
6466
6467
  Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set: diag(6263, 1 /* Error */, "Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set_6263", "Module '{0}' was resolved to '{1}', but '--allowArbitraryExtensions' is not set."),
6467
6468
  Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present: diag(6264, 3 /* Message */, "Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present_6264", "Enable importing files with any extension, provided a declaration file is present."),
6468
6469
  Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder: diag(6265, 3 /* Message */, "Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_no_6265", "Resolving type reference directive for program that specifies custom typeRoots, skipping lookup in 'node_modules' folder."),
6470
+ Option_0_can_only_be_specified_on_command_line: diag(6266, 1 /* Error */, "Option_0_can_only_be_specified_on_command_line_6266", "Option '{0}' can only be specified on command line."),
6469
6471
  Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, 3 /* Message */, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
6470
6472
  Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, 3 /* Message */, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
6471
6473
  Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, 3 /* Message */, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
@@ -10058,9 +10060,9 @@ function tryGetTextOfPropertyName(name) {
10058
10060
  function getTextOfPropertyName(name) {
10059
10061
  return Debug.checkDefined(tryGetTextOfPropertyName(name));
10060
10062
  }
10061
- function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3) {
10063
+ function createDiagnosticForNodeInSourceFile(sourceFile, node, message, ...args) {
10062
10064
  const span = getErrorSpanForNode(sourceFile, node);
10063
- return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3);
10065
+ return createFileDiagnostic(sourceFile, span.start, span.length, message, ...args);
10064
10066
  }
10065
10067
  function assertDiagnosticLocation(file, start, length2) {
10066
10068
  Debug.assertGreaterThanOrEqual(start, 0);
@@ -10493,6 +10495,12 @@ function skipParentheses(node, excludeJSDocTypeAssertions) {
10493
10495
  function isKeyword(token) {
10494
10496
  return 82 /* FirstKeyword */ <= token && token <= 163 /* LastKeyword */;
10495
10497
  }
10498
+ function isPunctuation(token) {
10499
+ return 18 /* FirstPunctuation */ <= token && token <= 78 /* LastPunctuation */;
10500
+ }
10501
+ function isKeywordOrPunctuation(token) {
10502
+ return isKeyword(token) || isPunctuation(token);
10503
+ }
10496
10504
  function isStringOrNumericLiteralLike(node) {
10497
10505
  return isStringLiteralLike(node) || isNumericLiteral(node);
10498
10506
  }
@@ -18124,14 +18132,12 @@ var Parser;
18124
18132
  scriptKind2 = ensureScriptKind(fileName2, scriptKind2);
18125
18133
  if (scriptKind2 === 6 /* JSON */) {
18126
18134
  const result2 = parseJsonText2(fileName2, sourceText2, languageVersion2, syntaxCursor2, setParentNodes);
18127
- convertToObjectWorker(
18135
+ convertToJson(
18128
18136
  result2,
18129
18137
  (_a2 = result2.statements[0]) == null ? void 0 : _a2.expression,
18130
18138
  result2.parseDiagnostics,
18131
18139
  /*returnValue*/
18132
18140
  false,
18133
- /*knownRootOptions*/
18134
- void 0,
18135
18141
  /*jsonConversionNotifier*/
18136
18142
  void 0
18137
18143
  );
@@ -18563,24 +18569,24 @@ var Parser;
18563
18569
  function inAwaitContext() {
18564
18570
  return inContext(32768 /* AwaitContext */);
18565
18571
  }
18566
- function parseErrorAtCurrentToken(message, arg0) {
18567
- return parseErrorAt(scanner.getTokenStart(), scanner.getTokenEnd(), message, arg0);
18572
+ function parseErrorAtCurrentToken(message, ...args) {
18573
+ return parseErrorAt(scanner.getTokenStart(), scanner.getTokenEnd(), message, ...args);
18568
18574
  }
18569
- function parseErrorAtPosition(start, length2, message, arg0) {
18575
+ function parseErrorAtPosition(start, length2, message, ...args) {
18570
18576
  const lastError = lastOrUndefined(parseDiagnostics);
18571
18577
  let result;
18572
18578
  if (!lastError || start !== lastError.start) {
18573
- result = createDetachedDiagnostic(fileName, start, length2, message, arg0);
18579
+ result = createDetachedDiagnostic(fileName, start, length2, message, ...args);
18574
18580
  parseDiagnostics.push(result);
18575
18581
  }
18576
18582
  parseErrorBeforeNextFinishedNode = true;
18577
18583
  return result;
18578
18584
  }
18579
- function parseErrorAt(start, end, message, arg0) {
18580
- return parseErrorAtPosition(start, end - start, message, arg0);
18585
+ function parseErrorAt(start, end, message, ...args) {
18586
+ return parseErrorAtPosition(start, end - start, message, ...args);
18581
18587
  }
18582
- function parseErrorAtRange(range, message, arg0) {
18583
- parseErrorAt(range.pos, range.end, message, arg0);
18588
+ function parseErrorAtRange(range, message, ...args) {
18589
+ parseErrorAt(range.pos, range.end, message, ...args);
18584
18590
  }
18585
18591
  function scanError(message, length2) {
18586
18592
  parseErrorAtPosition(scanner.getTokenEnd(), length2, message);
@@ -18786,6 +18792,7 @@ var Parser;
18786
18792
  nextTokenJSDoc();
18787
18793
  return true;
18788
18794
  }
18795
+ Debug.assert(isKeywordOrPunctuation(kind));
18789
18796
  parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(kind));
18790
18797
  return false;
18791
18798
  }
@@ -18834,7 +18841,11 @@ var Parser;
18834
18841
  );
18835
18842
  }
18836
18843
  function parseExpectedTokenJSDoc(t) {
18837
- return parseOptionalTokenJSDoc(t) || createMissingNode(
18844
+ const optional = parseOptionalTokenJSDoc(t);
18845
+ if (optional)
18846
+ return optional;
18847
+ Debug.assert(isKeywordOrPunctuation(t));
18848
+ return createMissingNode(
18838
18849
  t,
18839
18850
  /*reportAtCurrentPosition*/
18840
18851
  false,
@@ -18888,11 +18899,11 @@ var Parser;
18888
18899
  }
18889
18900
  return node;
18890
18901
  }
18891
- function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) {
18902
+ function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, ...args) {
18892
18903
  if (reportAtCurrentPosition) {
18893
- parseErrorAtPosition(scanner.getTokenFullStart(), 0, diagnosticMessage, arg0);
18904
+ parseErrorAtPosition(scanner.getTokenFullStart(), 0, diagnosticMessage, ...args);
18894
18905
  } else if (diagnosticMessage) {
18895
- parseErrorAtCurrentToken(diagnosticMessage, arg0);
18906
+ parseErrorAtCurrentToken(diagnosticMessage, ...args);
18896
18907
  }
18897
18908
  const pos = getNodePos();
18898
18909
  const result = kind === 79 /* Identifier */ ? factoryCreateIdentifier(
@@ -21251,6 +21262,7 @@ var Parser;
21251
21262
  if (simpleUnaryExpression.kind === 214 /* TypeAssertionExpression */) {
21252
21263
  parseErrorAt(pos, end, Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses);
21253
21264
  } else {
21265
+ Debug.assert(isKeywordOrPunctuation(unaryOperator));
21254
21266
  parseErrorAt(pos, end, Diagnostics.An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses, tokenToString(unaryOperator));
21255
21267
  }
21256
21268
  }
@@ -24198,14 +24210,14 @@ var Parser;
24198
24210
  }
24199
24211
  function parseReturnTag(start2, tagName, indent2, indentText) {
24200
24212
  if (some(tags, isJSDocReturnTag)) {
24201
- parseErrorAt(tagName.pos, scanner.getTokenStart(), Diagnostics._0_tag_already_specified, tagName.escapedText);
24213
+ parseErrorAt(tagName.pos, scanner.getTokenStart(), Diagnostics._0_tag_already_specified, unescapeLeadingUnderscores(tagName.escapedText));
24202
24214
  }
24203
24215
  const typeExpression = tryParseTypeExpression();
24204
24216
  return finishNode(factory2.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start2, getNodePos(), indent2, indentText)), start2);
24205
24217
  }
24206
24218
  function parseTypeTag(start2, tagName, indent2, indentText) {
24207
24219
  if (some(tags, isJSDocTypeTag)) {
24208
- parseErrorAt(tagName.pos, scanner.getTokenStart(), Diagnostics._0_tag_already_specified, tagName.escapedText);
24220
+ parseErrorAt(tagName.pos, scanner.getTokenStart(), Diagnostics._0_tag_already_specified, unescapeLeadingUnderscores(tagName.escapedText));
24209
24221
  }
24210
24222
  const typeExpression = parseJSDocTypeExpression(
24211
24223
  /*mayOmitBraces*/
@@ -25175,11 +25187,6 @@ function tagNamesAreEquivalent(lhs, rhs) {
25175
25187
  }
25176
25188
 
25177
25189
  // src/compiler/commandLineParser.ts
25178
- var compileOnSaveCommandLineOption = {
25179
- name: "compileOnSave",
25180
- type: "boolean",
25181
- defaultValueDescription: false
25182
- };
25183
25190
  var jsxOptionMap = new Map(Object.entries({
25184
25191
  "preserve": 1 /* Preserve */,
25185
25192
  "react-native": 3 /* ReactNative */,
@@ -26652,22 +26659,9 @@ var defaultInitCompilerOptions = {
26652
26659
  forceConsistentCasingInFileNames: true,
26653
26660
  skipLibCheck: true
26654
26661
  };
26655
- function createDiagnosticForInvalidCustomType(opt, createDiagnostic) {
26656
- const namesOfType = arrayFrom(opt.type.keys());
26657
- const stringNames = (opt.deprecatedKeys ? namesOfType.filter((k) => !opt.deprecatedKeys.has(k)) : namesOfType).map((key) => `'${key}'`).join(", ");
26658
- return createDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, stringNames);
26659
- }
26660
26662
  function getOptionName(option) {
26661
26663
  return option.name;
26662
26664
  }
26663
- function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) {
26664
- var _a2;
26665
- if ((_a2 = diagnostics.alternateMode) == null ? void 0 : _a2.getOptionsNameMap().optionsNameMap.has(unknownOption.toLowerCase())) {
26666
- return createDiagnostics(diagnostics.alternateMode.diagnostic, unknownOption);
26667
- }
26668
- const possibleOption = getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
26669
- return possibleOption ? createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
26670
- }
26671
26665
  var compilerOptionsDidYouMeanDiagnostics = {
26672
26666
  alternateMode: compilerOptionsAlternateMode,
26673
26667
  getOptionsNameMap,
@@ -26702,9 +26696,7 @@ function parseConfigFileTextToJson(fileName, jsonText) {
26702
26696
  config: convertConfigFileToObject(
26703
26697
  jsonSourceFile,
26704
26698
  jsonSourceFile.parseDiagnostics,
26705
- /*reportOptionsErrors*/
26706
- false,
26707
- /*optionsIterator*/
26699
+ /*jsonConversionNotifier*/
26708
26700
  void 0
26709
26701
  ),
26710
26702
  error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : void 0
@@ -26757,83 +26749,30 @@ var extendsOptionDeclaration = {
26757
26749
  name: "extends",
26758
26750
  type: "string"
26759
26751
  },
26760
- category: Diagnostics.File_Management
26752
+ category: Diagnostics.File_Management,
26753
+ disallowNullOrUndefined: true
26761
26754
  };
26762
- var _tsconfigRootOptions;
26763
- function getTsconfigRootOptionsMap() {
26764
- if (_tsconfigRootOptions === void 0) {
26765
- _tsconfigRootOptions = {
26766
- name: void 0,
26767
- // should never be needed since this is root
26768
- type: "object",
26769
- elementOptions: commandLineOptionsToMap([
26770
- {
26771
- name: "compilerOptions",
26772
- type: "object",
26773
- elementOptions: getCommandLineCompilerOptionsMap(),
26774
- extraKeyDiagnostics: compilerOptionsDidYouMeanDiagnostics
26775
- },
26776
- {
26777
- name: "watchOptions",
26778
- type: "object",
26779
- elementOptions: getCommandLineWatchOptionsMap(),
26780
- extraKeyDiagnostics: watchOptionsDidYouMeanDiagnostics
26781
- },
26782
- {
26783
- name: "typeAcquisition",
26784
- type: "object",
26785
- elementOptions: getCommandLineTypeAcquisitionMap(),
26786
- extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics
26787
- },
26788
- extendsOptionDeclaration,
26789
- {
26790
- name: "references",
26791
- type: "list",
26792
- element: {
26793
- name: "references",
26794
- type: "object"
26795
- },
26796
- category: Diagnostics.Projects
26797
- },
26798
- {
26799
- name: "files",
26800
- type: "list",
26801
- element: {
26802
- name: "files",
26803
- type: "string"
26804
- },
26805
- category: Diagnostics.File_Management
26806
- },
26807
- {
26808
- name: "include",
26809
- type: "list",
26810
- element: {
26811
- name: "include",
26812
- type: "string"
26813
- },
26814
- category: Diagnostics.File_Management,
26815
- defaultValueDescription: Diagnostics.if_files_is_specified_otherwise_Asterisk_Asterisk_Slash_Asterisk
26816
- },
26817
- {
26818
- name: "exclude",
26819
- type: "list",
26820
- element: {
26821
- name: "exclude",
26822
- type: "string"
26823
- },
26824
- category: Diagnostics.File_Management,
26825
- defaultValueDescription: Diagnostics.node_modules_bower_components_jspm_packages_plus_the_value_of_outDir_if_one_is_specified
26826
- },
26827
- compileOnSaveCommandLineOption
26828
- ])
26829
- };
26830
- }
26831
- return _tsconfigRootOptions;
26832
- }
26833
- function convertConfigFileToObject(sourceFile, errors, reportOptionsErrors, optionsIterator) {
26755
+ var compilerOptionsDeclaration = {
26756
+ name: "compilerOptions",
26757
+ type: "object",
26758
+ elementOptions: getCommandLineCompilerOptionsMap(),
26759
+ extraKeyDiagnostics: compilerOptionsDidYouMeanDiagnostics
26760
+ };
26761
+ var watchOptionsDeclaration = {
26762
+ name: "watchOptions",
26763
+ type: "object",
26764
+ elementOptions: getCommandLineWatchOptionsMap(),
26765
+ extraKeyDiagnostics: watchOptionsDidYouMeanDiagnostics
26766
+ };
26767
+ var typeAcquisitionDeclaration = {
26768
+ name: "typeAcquisition",
26769
+ type: "object",
26770
+ elementOptions: getCommandLineTypeAcquisitionMap(),
26771
+ extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics
26772
+ };
26773
+ function convertConfigFileToObject(sourceFile, errors, jsonConversionNotifier) {
26834
26774
  var _a2;
26835
26775
  const rootExpression = (_a2 = sourceFile.statements[0]) == null ? void 0 : _a2.expression;
26836
- const knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : void 0;
26837
26776
  if (rootExpression && rootExpression.kind !== 208 /* ObjectLiteralExpression */) {
26838
26777
  errors.push(createDiagnosticForNodeInSourceFile(
26839
26778
  sourceFile,
@@ -26844,38 +26783,34 @@ function convertConfigFileToObject(sourceFile, errors, reportOptionsErrors, opti
26844
26783
  if (isArrayLiteralExpression(rootExpression)) {
26845
26784
  const firstObject = find(rootExpression.elements, isObjectLiteralExpression);
26846
26785
  if (firstObject) {
26847
- return convertToObjectWorker(
26786
+ return convertToJson(
26848
26787
  sourceFile,
26849
26788
  firstObject,
26850
26789
  errors,
26851
26790
  /*returnValue*/
26852
26791
  true,
26853
- knownRootOptions,
26854
- optionsIterator
26792
+ jsonConversionNotifier
26855
26793
  );
26856
26794
  }
26857
26795
  }
26858
26796
  return {};
26859
26797
  }
26860
- return convertToObjectWorker(
26798
+ return convertToJson(
26861
26799
  sourceFile,
26862
26800
  rootExpression,
26863
26801
  errors,
26864
26802
  /*returnValue*/
26865
26803
  true,
26866
- knownRootOptions,
26867
- optionsIterator
26804
+ jsonConversionNotifier
26868
26805
  );
26869
26806
  }
26870
- function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue, knownRootOptions, jsonConversionNotifier) {
26807
+ function convertToJson(sourceFile, rootExpression, errors, returnValue, jsonConversionNotifier) {
26871
26808
  if (!rootExpression) {
26872
26809
  return returnValue ? {} : void 0;
26873
26810
  }
26874
- return convertPropertyValueToJson(rootExpression, knownRootOptions);
26875
- function isRootOptionMap(knownOptions) {
26876
- return knownRootOptions && knownRootOptions.elementOptions === knownOptions;
26877
- }
26878
- function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
26811
+ return convertPropertyValueToJson(rootExpression, jsonConversionNotifier == null ? void 0 : jsonConversionNotifier.rootOptions);
26812
+ function convertObjectLiteralExpressionToJson(node, objectOption) {
26813
+ var _a2;
26879
26814
  const result = returnValue ? {} : void 0;
26880
26815
  for (const element of node.properties) {
26881
26816
  if (element.kind !== 300 /* PropertyAssignment */) {
@@ -26890,38 +26825,13 @@ function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue,
26890
26825
  }
26891
26826
  const textOfKey = isComputedNonLiteralName(element.name) ? void 0 : getTextOfPropertyName(element.name);
26892
26827
  const keyText = textOfKey && unescapeLeadingUnderscores(textOfKey);
26893
- const option = keyText && knownOptions ? knownOptions.get(keyText) : void 0;
26894
- if (keyText && extraKeyDiagnostics && !option) {
26895
- if (knownOptions) {
26896
- errors.push(createUnknownOptionError(
26897
- keyText,
26898
- extraKeyDiagnostics,
26899
- (message, arg0, arg1) => createDiagnosticForNodeInSourceFile(sourceFile, element.name, message, arg0, arg1)
26900
- ));
26901
- } else {
26902
- errors.push(createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnostics.unknownOptionDiagnostic, keyText));
26903
- }
26904
- }
26828
+ const option = keyText ? (_a2 = objectOption == null ? void 0 : objectOption.elementOptions) == null ? void 0 : _a2.get(keyText) : void 0;
26905
26829
  const value = convertPropertyValueToJson(element.initializer, option);
26906
26830
  if (typeof keyText !== "undefined") {
26907
26831
  if (returnValue) {
26908
26832
  result[keyText] = value;
26909
26833
  }
26910
- if (jsonConversionNotifier && // Current callbacks are only on known parent option or if we are setting values in the root
26911
- (parentOption || isRootOptionMap(knownOptions))) {
26912
- const isValidOptionValue = isCompilerOptionsValue(option, value);
26913
- if (parentOption) {
26914
- if (isValidOptionValue) {
26915
- jsonConversionNotifier.onSetValidOptionKeyValueInParent(parentOption, option, value);
26916
- }
26917
- } else if (isRootOptionMap(knownOptions)) {
26918
- if (isValidOptionValue) {
26919
- jsonConversionNotifier.onSetValidOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
26920
- } else if (!option) {
26921
- jsonConversionNotifier.onSetUnknownOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
26922
- }
26923
- }
26924
- }
26834
+ jsonConversionNotifier == null ? void 0 : jsonConversionNotifier.onPropertySet(keyText, value, element, objectOption, option);
26925
26835
  }
26926
26836
  }
26927
26837
  return result;
@@ -26934,112 +26844,40 @@ function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue,
26934
26844
  return filter(elements.map((element) => convertPropertyValueToJson(element, elementOption)), (v) => v !== void 0);
26935
26845
  }
26936
26846
  function convertPropertyValueToJson(valueExpression, option) {
26937
- let invalidReported;
26938
26847
  switch (valueExpression.kind) {
26939
26848
  case 111 /* TrueKeyword */:
26940
- reportInvalidOptionValue(option && option.type !== "boolean" && (option.type !== "listOrElement" || option.element.type !== "boolean"));
26941
- return validateValue(
26942
- /*value*/
26943
- true
26944
- );
26849
+ return true;
26945
26850
  case 96 /* FalseKeyword */:
26946
- reportInvalidOptionValue(option && option.type !== "boolean" && (option.type !== "listOrElement" || option.element.type !== "boolean"));
26947
- return validateValue(
26948
- /*value*/
26949
- false
26950
- );
26851
+ return false;
26951
26852
  case 105 /* NullKeyword */:
26952
- reportInvalidOptionValue(option && option.name === "extends");
26953
- return validateValue(
26954
- /*value*/
26955
- null
26956
- );
26853
+ return null;
26957
26854
  case 10 /* StringLiteral */:
26958
26855
  if (!isDoubleQuotedString(valueExpression)) {
26959
26856
  errors.push(createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, Diagnostics.String_literal_with_double_quotes_expected));
26960
26857
  }
26961
- reportInvalidOptionValue(option && isString(option.type) && option.type !== "string" && (option.type !== "listOrElement" || isString(option.element.type) && option.element.type !== "string"));
26962
- const text = valueExpression.text;
26963
- if (option) {
26964
- Debug.assert(option.type !== "listOrElement" || option.element.type === "string", "Only string or array of string is handled for now");
26965
- }
26966
- if (option && !isString(option.type)) {
26967
- const customOption = option;
26968
- if (!customOption.type.has(text.toLowerCase())) {
26969
- errors.push(
26970
- createDiagnosticForInvalidCustomType(
26971
- customOption,
26972
- (message, arg0, arg1) => createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1)
26973
- )
26974
- );
26975
- invalidReported = true;
26976
- }
26977
- }
26978
- return validateValue(text);
26858
+ return valueExpression.text;
26979
26859
  case 8 /* NumericLiteral */:
26980
- reportInvalidOptionValue(option && option.type !== "number" && (option.type !== "listOrElement" || option.element.type !== "number"));
26981
- return validateValue(Number(valueExpression.text));
26860
+ return Number(valueExpression.text);
26982
26861
  case 222 /* PrefixUnaryExpression */:
26983
26862
  if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) {
26984
26863
  break;
26985
26864
  }
26986
- reportInvalidOptionValue(option && option.type !== "number" && (option.type !== "listOrElement" || option.element.type !== "number"));
26987
- return validateValue(-Number(valueExpression.operand.text));
26865
+ return -Number(valueExpression.operand.text);
26988
26866
  case 208 /* ObjectLiteralExpression */:
26989
- reportInvalidOptionValue(option && option.type !== "object" && (option.type !== "listOrElement" || option.element.type !== "object"));
26990
26867
  const objectLiteralExpression = valueExpression;
26991
- if (option) {
26992
- const { elementOptions, extraKeyDiagnostics, name: optionName } = option;
26993
- return validateValue(convertObjectLiteralExpressionToJson(
26994
- objectLiteralExpression,
26995
- elementOptions,
26996
- extraKeyDiagnostics,
26997
- optionName
26998
- ));
26999
- } else {
27000
- return validateValue(convertObjectLiteralExpressionToJson(
27001
- objectLiteralExpression,
27002
- /* knownOptions*/
27003
- void 0,
27004
- /*extraKeyDiagnosticMessage */
27005
- void 0,
27006
- /*parentOption*/
27007
- void 0
27008
- ));
27009
- }
26868
+ return convertObjectLiteralExpressionToJson(objectLiteralExpression, option);
27010
26869
  case 207 /* ArrayLiteralExpression */:
27011
- reportInvalidOptionValue(option && option.type !== "list" && option.type !== "listOrElement");
27012
- return validateValue(convertArrayLiteralExpressionToJson(
26870
+ return convertArrayLiteralExpressionToJson(
27013
26871
  valueExpression.elements,
27014
26872
  option && option.element
27015
- ));
26873
+ );
27016
26874
  }
27017
26875
  if (option) {
27018
- reportInvalidOptionValue(
27019
- /*isError*/
27020
- true
27021
- );
26876
+ errors.push(createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, Diagnostics.Compiler_option_0_requires_a_value_of_type_1, option.name, getCompilerOptionValueTypeString(option)));
27022
26877
  } else {
27023
26878
  errors.push(createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, Diagnostics.Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal));
27024
26879
  }
27025
26880
  return void 0;
27026
- function validateValue(value) {
27027
- var _a2;
27028
- if (!invalidReported) {
27029
- const diagnostic = (_a2 = option == null ? void 0 : option.extraValidation) == null ? void 0 : _a2.call(option, value);
27030
- if (diagnostic) {
27031
- errors.push(createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ...diagnostic));
27032
- return void 0;
27033
- }
27034
- }
27035
- return value;
27036
- }
27037
- function reportInvalidOptionValue(isError) {
27038
- if (isError) {
27039
- errors.push(createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, Diagnostics.Compiler_option_0_requires_a_value_of_type_1, option.name, getCompilerOptionValueTypeString(option)));
27040
- invalidReported = true;
27041
- }
27042
- }
27043
26881
  }
27044
26882
  function isDoubleQuotedString(node) {
27045
26883
  return isStringLiteral(node) && isStringDoubleQuoted(node, sourceFile);
@@ -27048,24 +26886,6 @@ function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue,
27048
26886
  function getCompilerOptionValueTypeString(option) {
27049
26887
  return option.type === "listOrElement" ? `${getCompilerOptionValueTypeString(option.element)} or Array` : option.type === "list" ? "Array" : isString(option.type) ? option.type : "string";
27050
26888
  }
27051
- function isCompilerOptionsValue(option, value) {
27052
- if (option) {
27053
- if (isNullOrUndefined(value))
27054
- return true;
27055
- if (option.type === "list") {
27056
- return isArray(value);
27057
- }
27058
- if (option.type === "listOrElement") {
27059
- return isArray(value) || isCompilerOptionsValue(option.element, value);
27060
- }
27061
- const expectedType = isString(option.type) ? option.type : "string";
27062
- return typeof value === expectedType;
27063
- }
27064
- return false;
27065
- }
27066
- function isNullOrUndefined(x) {
27067
- return x === void 0 || x === null;
27068
- }
27069
26889
  var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
27070
26890
  function invalidDotDotAfterRecursiveWildcard(s) {
27071
26891
  const wildcardIndex = startsWith(s, "**/") ? 0 : s.indexOf("/**/");
@@ -31533,7 +31353,7 @@ function renderPackageNameValidationFailureWorker(typing, result, name, isScopeN
31533
31353
  case 0 /* Ok */:
31534
31354
  return Debug.fail();
31535
31355
  default:
31536
- throw Debug.assertNever(result);
31356
+ Debug.assertNever(result);
31537
31357
  }
31538
31358
  }
31539
31359
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.1.0-dev.20230320",
5
+ "version": "5.1.0-dev.20230322",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -113,5 +113,5 @@
113
113
  "node": "14.21.1",
114
114
  "npm": "8.19.3"
115
115
  },
116
- "gitHead": "86f811440484f6a91e3d2a5ddaeb05eed8bf95cc"
116
+ "gitHead": "1df5717b120cddd325deab8b0f2b2c3eecaf2b01"
117
117
  }