mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 02:35:48 -05:00
Plain JS grammar errors (#47067)
* Plain JS grammar errors From the list in https://github.com/microsoft/TypeScript/issues/45349#issuecomment-974561208, excluding the JSX errors, decorator errors and unresolved #private error. The latter re-uses "Cannot resolve name X" which naturally shows up a *lot* in plain JS. * Add grammarErrorAtPos errors Also remove checkGrammarArguments; it's blocked entirely by the same parser error.
This commit is contained in:
committed by
GitHub
parent
022542548e
commit
a72bf5410c
@@ -31013,7 +31013,7 @@ namespace ts {
|
||||
* @returns On success, the expression's signature's return type. On failure, anyType.
|
||||
*/
|
||||
function checkCallExpression(node: CallExpression | NewExpression, checkMode?: CheckMode): Type {
|
||||
if (!checkGrammarTypeArguments(node, node.typeArguments)) checkGrammarArguments(node.arguments);
|
||||
checkGrammarTypeArguments(node, node.typeArguments);
|
||||
|
||||
const signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode);
|
||||
if (signature === resolvingSignature) {
|
||||
@@ -31133,7 +31133,7 @@ namespace ts {
|
||||
|
||||
function checkImportCallExpression(node: ImportCall): Type {
|
||||
// Check grammar of dynamic import
|
||||
if (!checkGrammarArguments(node.arguments)) checkGrammarImportCallExpression(node);
|
||||
checkGrammarImportCallExpression(node);
|
||||
|
||||
if (node.arguments.length === 0) {
|
||||
return createPromiseReturnType(node, anyType);
|
||||
@@ -42917,21 +42917,6 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkGrammarForOmittedArgument(args: NodeArray<Expression> | undefined): boolean {
|
||||
if (args) {
|
||||
for (const arg of args) {
|
||||
if (arg.kind === SyntaxKind.OmittedExpression) {
|
||||
return grammarErrorAtPos(arg, arg.pos, 0, Diagnostics.Argument_expression_expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkGrammarArguments(args: NodeArray<Expression> | undefined): boolean {
|
||||
return checkGrammarForOmittedArgument(args);
|
||||
}
|
||||
|
||||
function checkGrammarHeritageClause(node: HeritageClause): boolean {
|
||||
const types = node.types;
|
||||
if (checkGrammarForDisallowedTrailingComma(types)) {
|
||||
|
||||
@@ -820,6 +820,7 @@ namespace ts {
|
||||
|
||||
/** @internal */
|
||||
export const plainJSErrors: Set<number> = new Set([
|
||||
// binder errors
|
||||
Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
|
||||
Diagnostics.A_module_cannot_have_multiple_default_exports.code,
|
||||
Diagnostics.Another_export_default_is_here.code,
|
||||
@@ -835,6 +836,69 @@ namespace ts {
|
||||
Diagnostics.A_label_is_not_allowed_here.code,
|
||||
Diagnostics.Octal_literals_are_not_allowed_in_strict_mode.code,
|
||||
Diagnostics.with_statements_are_not_allowed_in_strict_mode.code,
|
||||
// grammar errors
|
||||
Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement.code,
|
||||
Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement.code,
|
||||
Diagnostics.A_class_member_cannot_have_the_0_keyword.code,
|
||||
Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name.code,
|
||||
Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement.code,
|
||||
Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement.code,
|
||||
Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement.code,
|
||||
Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement.code,
|
||||
Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context.code,
|
||||
Diagnostics.A_destructuring_declaration_must_have_an_initializer.code,
|
||||
Diagnostics.A_get_accessor_cannot_have_parameters.code,
|
||||
Diagnostics.A_rest_element_cannot_contain_a_binding_pattern.code,
|
||||
Diagnostics.A_rest_element_cannot_have_a_property_name.code,
|
||||
Diagnostics.A_rest_element_cannot_have_an_initializer.code,
|
||||
Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern.code,
|
||||
Diagnostics.A_rest_parameter_cannot_have_an_initializer.code,
|
||||
Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code,
|
||||
Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code,
|
||||
Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
|
||||
Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
|
||||
Diagnostics.An_object_member_cannot_be_declared_optional.code,
|
||||
Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code,
|
||||
Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable.code,
|
||||
Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause.code,
|
||||
Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator.code,
|
||||
Diagnostics.Classes_may_not_have_a_field_named_constructor.code,
|
||||
Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern.code,
|
||||
Diagnostics.Duplicate_label_0.code,
|
||||
Diagnostics.Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments.code,
|
||||
Diagnostics.For_await_loops_cannot_be_used_inside_a_class_static_block.code,
|
||||
Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression.code,
|
||||
Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name.code,
|
||||
Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array.code,
|
||||
Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names.code,
|
||||
Diagnostics.Jump_target_cannot_cross_function_boundary.code,
|
||||
Diagnostics.Line_terminator_not_permitted_before_arrow.code,
|
||||
Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement.code,
|
||||
Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement.code,
|
||||
Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies.code,
|
||||
Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression.code,
|
||||
Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier.code,
|
||||
Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain.code,
|
||||
Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async.code,
|
||||
Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer.code,
|
||||
Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer.code,
|
||||
Diagnostics.Trailing_comma_not_allowed.code,
|
||||
Diagnostics.Variable_declaration_list_cannot_be_empty.code,
|
||||
Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses.code,
|
||||
Diagnostics._0_expected.code,
|
||||
Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2.code,
|
||||
Diagnostics._0_list_cannot_be_empty.code,
|
||||
Diagnostics._0_modifier_already_seen.code,
|
||||
Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration.code,
|
||||
Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element.code,
|
||||
Diagnostics._0_modifier_cannot_appear_on_a_parameter.code,
|
||||
Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind.code,
|
||||
Diagnostics._0_modifier_cannot_be_used_here.code,
|
||||
Diagnostics._0_modifier_must_precede_1_modifier.code,
|
||||
Diagnostics.const_declarations_can_only_be_declared_inside_a_block.code,
|
||||
Diagnostics.const_declarations_must_be_initialized.code,
|
||||
Diagnostics.let_declarations_can_only_be_declared_inside_a_block.code,
|
||||
Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
|
||||
]);
|
||||
|
||||
/**
|
||||
@@ -2036,9 +2100,10 @@ namespace ts {
|
||||
const includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === ScriptKind.TS || sourceFile.scriptKind === ScriptKind.TSX
|
||||
|| sourceFile.scriptKind === ScriptKind.External || isPlainJs || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred);
|
||||
let bindDiagnostics: readonly Diagnostic[] = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
|
||||
const checkDiagnostics = includeBindAndCheckDiagnostics && !isPlainJs ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
|
||||
let checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
|
||||
if (isPlainJs) {
|
||||
bindDiagnostics = filter(bindDiagnostics, d => plainJSErrors.has(d.code));
|
||||
checkDiagnostics = filter(checkDiagnostics, d => plainJSErrors.has(d.code));
|
||||
}
|
||||
// skip ts-expect-error errors in plain JS files, and skip JSDoc errors except in checked JS
|
||||
return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics && !isPlainJs, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
|
||||
|
||||
@@ -12,11 +12,12 @@ tests/cases/conformance/salsa/plainJSBinderErrors.js(22,15): error TS1210: Code
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(23,15): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(27,9): error TS1101: 'with' statements are not allowed in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(33,13): error TS1344: 'A label is not allowed here.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(34,13): error TS1107: Jump target cannot cross function boundary.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(39,7): error TS1215: Invalid use of 'eval'. Modules are automatically in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSBinderErrors.js(40,7): error TS1215: Invalid use of 'arguments'. Modules are automatically in strict mode.
|
||||
|
||||
|
||||
==== tests/cases/conformance/salsa/plainJSBinderErrors.js (16 errors) ====
|
||||
==== tests/cases/conformance/salsa/plainJSBinderErrors.js (17 errors) ====
|
||||
export default 12
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2528: A module cannot have multiple default exports.
|
||||
@@ -81,6 +82,8 @@ tests/cases/conformance/salsa/plainJSBinderErrors.js(40,7): error TS1215: Invali
|
||||
~~~~~
|
||||
!!! error TS1344: 'A label is not allowed here.
|
||||
break label
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1107: Jump target cannot cross function boundary.
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
451
tests/baselines/reference/plainJSGrammarErrors.errors.txt
Normal file
451
tests/baselines/reference/plainJSGrammarErrors.errors.txt
Normal file
@@ -0,0 +1,451 @@
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(3,9): error TS1451: Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(5,9): error TS1451: Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(10,15): error TS2803: Cannot assign to private method '#m'. Private methods are not writable.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(14,13): error TS18038: 'For await' loops cannot be used inside a class static block.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(19,5): error TS1089: 'static' modifier cannot appear on a constructor declaration.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(20,5): error TS1089: 'async' modifier cannot appear on a constructor declaration.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(21,5): error TS8009: The 'const' modifier can only be used in TypeScript files.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(21,11): error TS1248: A class member cannot have the 'const' keyword.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(22,5): error TS8009: The 'const' modifier can only be used in TypeScript files.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(22,11): error TS1248: A class member cannot have the 'const' keyword.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(25,11): error TS1030: 'async' modifier already seen.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(27,11): error TS1029: 'static' modifier must precede 'async' modifier.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(28,5): error TS1031: 'export' modifier cannot appear on class elements of this kind.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(28,5): error TS8009: The 'export' modifier can only be used in TypeScript files.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(29,5): error TS1031: 'export' modifier cannot appear on class elements of this kind.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(33,22): error TS1005: '{' expected.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(34,9): error TS1054: A 'get' accessor cannot have parameters.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(35,9): error TS1049: A 'set' accessor must have exactly one parameter.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(36,9): error TS1049: A 'set' accessor must have exactly one parameter.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(37,18): error TS1053: A 'set' accessor cannot have rest parameter.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(40,5): error TS18006: Classes may not have a field named 'constructor'.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(43,1): error TS18016: Private identifiers are not allowed outside class bodies.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(44,6): error TS18016: Private identifiers are not allowed outside class bodies.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(45,9): error TS18013: Property '#m' is not accessible outside class 'C' because it has a private identifier.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(48,8): error TS1030: 'export' modifier already seen.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(49,8): error TS1044: 'static' modifier cannot appear on a module or namespace element.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(50,22): error TS1090: 'static' modifier cannot appear on a parameter.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(50,22): error TS8012: Parameter modifiers can only be used in TypeScript files.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(51,7): error TS1029: 'export' modifier must precede 'async' modifier.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(52,26): error TS1090: 'export' modifier cannot appear on a parameter.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(52,26): error TS8012: Parameter modifiers can only be used in TypeScript files.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(53,25): error TS1090: 'async' modifier cannot appear on a parameter.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(53,25): error TS8012: Parameter modifiers can only be used in TypeScript files.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(54,7): error TS1030: 'async' modifier already seen.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(55,1): error TS1042: 'async' modifier cannot be used here.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(56,5): error TS1042: 'async' modifier cannot be used here.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(56,5): error TS8009: The 'async' modifier can only be used in TypeScript files.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(58,1): error TS1042: 'async' modifier cannot be used here.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(59,1): error TS1042: 'async' modifier cannot be used here.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(60,1): error TS1042: 'async' modifier cannot be used here.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(63,25): error TS1014: A rest parameter must be last in a parameter list.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(65,37): error TS1048: A rest parameter cannot have an initializer.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(67,41): error TS1013: A rest parameter or binding pattern may not have a trailing comma.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(69,8): error TS2501: A rest element cannot contain a binding pattern.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(71,12): error TS2462: A rest element must be last in a destructuring pattern.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(72,33): error TS2566: A rest element cannot have a property name.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(73,42): error TS1186: A rest element cannot have an initializer.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(76,4): error TS1123: Variable declaration list cannot be empty.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(77,9): error TS5076: '||' and '??' operations cannot be mixed without parentheses.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(78,14): error TS5076: '||' and '??' operations cannot be mixed without parentheses.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(80,3): error TS1200: Line terminator not permitted before arrow.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(82,4): error TS1358: Tagged template expressions are not permitted in an optional chain.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(84,6): error TS1171: A comma expression is not allowed in a computed property name.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(85,5): error TS18016: Private identifiers are not allowed outside class bodies.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(86,5): error TS1042: 'export' modifier cannot be used here.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(88,25): error TS1162: An object member cannot be declared optional.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(89,6): error TS1162: An object member cannot be declared optional.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(89,6): error TS8009: The '?' modifier can only be used in TypeScript files.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(90,15): error TS1255: A definite assignment assertion '!' is not permitted in this context.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(91,19): error TS1255: A definite assignment assertion '!' is not permitted in this context.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(94,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(96,24): error TS1009: Trailing comma not allowed.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(97,29): error TS1097: 'extends' list cannot be empty.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(100,7): error TS1182: A destructuring declaration must have an initializer.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(101,7): error TS1155: 'const' declarations must be initialized.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(102,5): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(102,5): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(104,5): error TS1157: 'let' declarations can only be declared inside a block.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(106,5): error TS1156: 'const' declarations can only be declared inside a block.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(111,6): error TS1106: The left-hand side of a 'for...of' statement may not be 'async'.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(114,12): error TS1190: The variable declaration of a 'for...of' statement cannot have an initializer.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(117,12): error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(120,13): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(123,13): error TS1091: Only a single variable declaration is allowed in a 'for...in' statement.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(134,5): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(141,11): error TS2492: Cannot redeclare identifier 'e' in catch clause.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(145,5): error TS1114: Duplicate label 'label'.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(154,13): error TS1107: Jump target cannot cross function boundary.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(162,13): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(166,5): error TS1107: Jump target cannot cross function boundary.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(169,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(170,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(172,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(173,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement.
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(176,28): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(177,22): error TS17012: 'targe' is not a valid meta-property for keyword 'new'. Did you mean 'target'?
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(178,30): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(179,30): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments
|
||||
tests/cases/conformance/salsa/plainJSGrammarErrors.js(180,36): error TS1325: Argument of dynamic import cannot be spread element.
|
||||
|
||||
|
||||
==== tests/cases/conformance/salsa/plainJSGrammarErrors.js (89 errors) ====
|
||||
class C {
|
||||
// #private mistakes
|
||||
q = #unbound
|
||||
~~~~~~~~
|
||||
!!! error TS1451: Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression
|
||||
m() {
|
||||
#p
|
||||
~~
|
||||
!!! error TS1451: Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression
|
||||
if (#po in this) {
|
||||
}
|
||||
}
|
||||
#m() {
|
||||
this.#m = () => {}
|
||||
~~
|
||||
!!! error TS2803: Cannot assign to private method '#m'. Private methods are not writable.
|
||||
}
|
||||
// await in static block
|
||||
static {
|
||||
for await (const x of [1,2,3]) {
|
||||
~~~~~
|
||||
!!! error TS18038: 'For await' loops cannot be used inside a class static block.
|
||||
console.log(x)
|
||||
}
|
||||
}
|
||||
// modifier mistakes
|
||||
static constructor() { }
|
||||
~~~~~~
|
||||
!!! error TS1089: 'static' modifier cannot appear on a constructor declaration.
|
||||
async constructor() { }
|
||||
~~~~~
|
||||
!!! error TS1089: 'async' modifier cannot appear on a constructor declaration.
|
||||
const x = 1
|
||||
~~~~~
|
||||
!!! error TS8009: The 'const' modifier can only be used in TypeScript files.
|
||||
~
|
||||
!!! error TS1248: A class member cannot have the 'const' keyword.
|
||||
const y() {
|
||||
~~~~~
|
||||
!!! error TS8009: The 'const' modifier can only be used in TypeScript files.
|
||||
~
|
||||
!!! error TS1248: A class member cannot have the 'const' keyword.
|
||||
return 12
|
||||
}
|
||||
async async extremelyAsync() {
|
||||
~~~~~
|
||||
!!! error TS1030: 'async' modifier already seen.
|
||||
}
|
||||
async static oorder(){ }
|
||||
~~~~~~
|
||||
!!! error TS1029: 'static' modifier must precede 'async' modifier.
|
||||
export cantExportProperty = 1
|
||||
~~~~~~
|
||||
!!! error TS1031: 'export' modifier cannot appear on class elements of this kind.
|
||||
~~~~~~
|
||||
!!! error TS8009: The 'export' modifier can only be used in TypeScript files.
|
||||
export cantExportMethod() {
|
||||
~~~~~~
|
||||
!!! error TS1031: 'export' modifier cannot appear on class elements of this kind.
|
||||
}
|
||||
|
||||
// accessor mistakes
|
||||
get incorporeal();
|
||||
~
|
||||
!!! error TS1005: '{' expected.
|
||||
get parametric(n) { return 1 }
|
||||
~~~~~~~~~~
|
||||
!!! error TS1054: A 'get' accessor cannot have parameters.
|
||||
set invariant() { }
|
||||
~~~~~~~~~
|
||||
!!! error TS1049: A 'set' accessor must have exactly one parameter.
|
||||
set binary(fst, snd) { }
|
||||
~~~~~~
|
||||
!!! error TS1049: A 'set' accessor must have exactly one parameter.
|
||||
set variable(...n) { }
|
||||
~~~
|
||||
!!! error TS1053: A 'set' accessor cannot have rest parameter.
|
||||
|
||||
// other
|
||||
"constructor" = 16
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS18006: Classes may not have a field named 'constructor'.
|
||||
}
|
||||
// #private mistakes
|
||||
#unrelated
|
||||
~~~~~~~~~~
|
||||
!!! error TS18016: Private identifiers are not allowed outside class bodies.
|
||||
junk.#m
|
||||
~~
|
||||
!!! error TS18016: Private identifiers are not allowed outside class bodies.
|
||||
new C().#m
|
||||
~~
|
||||
!!! error TS18013: Property '#m' is not accessible outside class 'C' because it has a private identifier.
|
||||
|
||||
// modifier mistakes
|
||||
export export var extremelyExported = 10
|
||||
~~~~~~
|
||||
!!! error TS1030: 'export' modifier already seen.
|
||||
export static var staticExport = 1
|
||||
~~~~~~
|
||||
!!! error TS1044: 'static' modifier cannot appear on a module or namespace element.
|
||||
function staticParam(static x = 1) { return x }
|
||||
~~~~~~
|
||||
!!! error TS1090: 'static' modifier cannot appear on a parameter.
|
||||
~~~~~~
|
||||
!!! error TS8012: Parameter modifiers can only be used in TypeScript files.
|
||||
async export function oorder(x = 1) { return x }
|
||||
~~~~~~
|
||||
!!! error TS1029: 'export' modifier must precede 'async' modifier.
|
||||
function cantExportParam(export x = 1) { return x }
|
||||
~~~~~~
|
||||
!!! error TS1090: 'export' modifier cannot appear on a parameter.
|
||||
~~~~~~
|
||||
!!! error TS8012: Parameter modifiers can only be used in TypeScript files.
|
||||
function cantAsyncParam(async x = 1) { return x }
|
||||
~~~~~
|
||||
!!! error TS1090: 'async' modifier cannot appear on a parameter.
|
||||
~~~~~
|
||||
!!! error TS8012: Parameter modifiers can only be used in TypeScript files.
|
||||
async async function extremelyAsync() {}
|
||||
~~~~~
|
||||
!!! error TS1030: 'async' modifier already seen.
|
||||
async class CantAsyncClass {
|
||||
~~~~~
|
||||
!!! error TS1042: 'async' modifier cannot be used here.
|
||||
async cantAsyncPropert = 1
|
||||
~~~~~
|
||||
!!! error TS1042: 'async' modifier cannot be used here.
|
||||
~~~~~
|
||||
!!! error TS8009: The 'async' modifier can only be used in TypeScript files.
|
||||
}
|
||||
async const cantAsyncConst = 2
|
||||
~~~~~
|
||||
!!! error TS1042: 'async' modifier cannot be used here.
|
||||
async import 'assert'
|
||||
~~~~~
|
||||
!!! error TS1042: 'async' modifier cannot be used here.
|
||||
async export { CantAsyncClass }
|
||||
~~~~~
|
||||
!!! error TS1042: 'async' modifier cannot be used here.
|
||||
|
||||
// rest parameters
|
||||
function restMustBeLast(...x, y) {
|
||||
~~~
|
||||
!!! error TS1014: A rest parameter must be last in a parameter list.
|
||||
}
|
||||
function restCantHaveInitialiser(...x = [1,2,3]) {
|
||||
~
|
||||
!!! error TS1048: A rest parameter cannot have an initializer.
|
||||
}
|
||||
function restCantHaveTrailingComma (...x,) {
|
||||
~
|
||||
!!! error TS1013: A rest parameter or binding pattern may not have a trailing comma.
|
||||
}
|
||||
;({ ...{} } = {})
|
||||
~~
|
||||
!!! error TS2501: A rest element cannot contain a binding pattern.
|
||||
const doom = { e: 1, m: 1, name: "knee-deep" }
|
||||
const { ...rest, e: episode, m: mission } = doom
|
||||
~~~~
|
||||
!!! error TS2462: A rest element must be last in a destructuring pattern.
|
||||
const { e: eep, m: em, ...rest: noRestAllowed } = doom
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2566: A rest element cannot have a property name.
|
||||
const { e: erp, m: erm, ...noInitialiser = true } = doom
|
||||
~
|
||||
!!! error TS1186: A rest element cannot have an initializer.
|
||||
|
||||
// left-over parsing
|
||||
var;
|
||||
|
||||
!!! error TS1123: Variable declaration list cannot be empty.
|
||||
var x = 1 || 2 ?? 3
|
||||
~~~~~~
|
||||
!!! error TS5076: '||' and '??' operations cannot be mixed without parentheses.
|
||||
var x = 2 ?? 3 || 4
|
||||
~~~~~~
|
||||
!!! error TS5076: '||' and '??' operations cannot be mixed without parentheses.
|
||||
const arr = x
|
||||
=> x + 1
|
||||
~~
|
||||
!!! error TS1200: Line terminator not permitted before arrow.
|
||||
var a = [1,2]
|
||||
a?.`length`;
|
||||
~~~~~~~~
|
||||
!!! error TS1358: Tagged template expressions are not permitted in an optional chain.
|
||||
const o = {
|
||||
[console.log('oh no'),2]: 'hi',
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1171: A comma expression is not allowed in a computed property name.
|
||||
#noPrivate: 3,
|
||||
~~~~~~~~~~
|
||||
!!! error TS18016: Private identifiers are not allowed outside class bodies.
|
||||
export cantExportProperties: 4,
|
||||
~~~~~~
|
||||
!!! error TS1042: 'export' modifier cannot be used here.
|
||||
// TODO: See what the existing JS error is like for these
|
||||
cantHaveQuestionMark?: 1,
|
||||
~
|
||||
!!! error TS1162: An object member cannot be declared optional.
|
||||
m?() { return 12 },
|
||||
~
|
||||
!!! error TS1162: An object member cannot be declared optional.
|
||||
~
|
||||
!!! error TS8009: The '?' modifier can only be used in TypeScript files.
|
||||
definitely!,
|
||||
~
|
||||
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
|
||||
definiteMethod!() { return 13 },
|
||||
~
|
||||
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
|
||||
}
|
||||
const noAssignment = {
|
||||
assignment = 1,
|
||||
~
|
||||
!!! error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.
|
||||
}
|
||||
var noTrailingComma = 1,;
|
||||
~
|
||||
!!! error TS1009: Trailing comma not allowed.
|
||||
class MissingExtends extends { }
|
||||
|
||||
!!! error TS1097: 'extends' list cannot be empty.
|
||||
|
||||
// let/const mistakes
|
||||
const { e: ee };
|
||||
~~~~~~~~~
|
||||
!!! error TS1182: A destructuring declaration must have an initializer.
|
||||
const noInit;
|
||||
~~~~~~
|
||||
!!! error TS1155: 'const' declarations must be initialized.
|
||||
let let = 15;
|
||||
~~~
|
||||
!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
|
||||
~~~
|
||||
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
|
||||
if (true)
|
||||
let onlyBlockLet = 17;
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1157: 'let' declarations can only be declared inside a block.
|
||||
if (true)
|
||||
const onlyBlockConst = 18;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1156: 'const' declarations can only be declared inside a block.
|
||||
|
||||
// loop mistakes
|
||||
let async
|
||||
export const l = [1,2,3]
|
||||
for (async of l) {
|
||||
~~~~~
|
||||
!!! error TS1106: The left-hand side of a 'for...of' statement may not be 'async'.
|
||||
console.log(x)
|
||||
}
|
||||
for (const cantHaveInit = 1 of [1,2,3]) {
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1190: The variable declaration of a 'for...of' statement cannot have an initializer.
|
||||
console.log(cantHaveInit)
|
||||
}
|
||||
for (const cantHaveInit = 1 in [1,2,3]) {
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer.
|
||||
console.log(cantHaveInit)
|
||||
}
|
||||
for (let y, x of [1,2,3]) {
|
||||
~
|
||||
!!! error TS1188: Only a single variable declaration is allowed in a 'for...of' statement.
|
||||
console.log(x)
|
||||
}
|
||||
for (let y, x in [1,2,3]) {
|
||||
~
|
||||
!!! error TS1091: Only a single variable declaration is allowed in a 'for...in' statement.
|
||||
console.log(x)
|
||||
}
|
||||
|
||||
// duplication mistakes
|
||||
var b
|
||||
switch (b) {
|
||||
case false:
|
||||
console.log('no')
|
||||
default:
|
||||
console.log('yes')
|
||||
default:
|
||||
~~~~~~~~
|
||||
!!! error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement.
|
||||
console.log('wat')
|
||||
}
|
||||
try {
|
||||
throw 2
|
||||
}
|
||||
catch (e) {
|
||||
const e = 1
|
||||
~
|
||||
!!! error TS2492: Cannot redeclare identifier 'e' in catch clause.
|
||||
console.log(e)
|
||||
}
|
||||
label: for (const x in [1,2,3]) {
|
||||
label: for (const y in [1,2,3]) {
|
||||
~~~~~
|
||||
!!! error TS1114: Duplicate label 'label'.
|
||||
break label;
|
||||
}
|
||||
}
|
||||
|
||||
// labels
|
||||
function crossFunctionBoundary() {
|
||||
outer: for(;;) {
|
||||
function test() {
|
||||
break outer
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1107: Jump target cannot cross function boundary.
|
||||
}
|
||||
test()
|
||||
}
|
||||
}
|
||||
function continueIterationOnly(x) {
|
||||
outer: switch (x) {
|
||||
case 1:
|
||||
continue outer
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
}
|
||||
}
|
||||
function jumpToLabelOnly(x) {
|
||||
break jumpToLabelOnly
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1107: Jump target cannot cross function boundary.
|
||||
}
|
||||
for (;;) {
|
||||
break toplevel
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1116: A 'break' statement can only jump to a label of an enclosing statement.
|
||||
continue toplevel
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement.
|
||||
}
|
||||
break
|
||||
~~~~~
|
||||
!!! error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement.
|
||||
continue
|
||||
~~~~~~~~
|
||||
!!! error TS1104: A 'continue' statement can only be used within an enclosing iteration statement.
|
||||
|
||||
// other weirdness
|
||||
export let noMeta = import.metal
|
||||
~~~~~
|
||||
!!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
function foo() { new.targe }
|
||||
~~~~~
|
||||
!!! error TS17012: 'targe' is not a valid meta-property for keyword 'new'. Did you mean 'target'?
|
||||
const nullaryDynamicImport = import()
|
||||
~~~~~~~~
|
||||
!!! message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments
|
||||
const trinaryDynamicImport = import('1', '2', '3')
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments
|
||||
const spreadDynamicImport = import(...[])
|
||||
~~~~~
|
||||
!!! error TS1325: Argument of dynamic import cannot be spread element.
|
||||
|
||||
355
tests/baselines/reference/plainJSGrammarErrors.js
Normal file
355
tests/baselines/reference/plainJSGrammarErrors.js
Normal file
@@ -0,0 +1,355 @@
|
||||
//// [plainJSGrammarErrors.js]
|
||||
class C {
|
||||
// #private mistakes
|
||||
q = #unbound
|
||||
m() {
|
||||
#p
|
||||
if (#po in this) {
|
||||
}
|
||||
}
|
||||
#m() {
|
||||
this.#m = () => {}
|
||||
}
|
||||
// await in static block
|
||||
static {
|
||||
for await (const x of [1,2,3]) {
|
||||
console.log(x)
|
||||
}
|
||||
}
|
||||
// modifier mistakes
|
||||
static constructor() { }
|
||||
async constructor() { }
|
||||
const x = 1
|
||||
const y() {
|
||||
return 12
|
||||
}
|
||||
async async extremelyAsync() {
|
||||
}
|
||||
async static oorder(){ }
|
||||
export cantExportProperty = 1
|
||||
export cantExportMethod() {
|
||||
}
|
||||
|
||||
// accessor mistakes
|
||||
get incorporeal();
|
||||
get parametric(n) { return 1 }
|
||||
set invariant() { }
|
||||
set binary(fst, snd) { }
|
||||
set variable(...n) { }
|
||||
|
||||
// other
|
||||
"constructor" = 16
|
||||
}
|
||||
// #private mistakes
|
||||
#unrelated
|
||||
junk.#m
|
||||
new C().#m
|
||||
|
||||
// modifier mistakes
|
||||
export export var extremelyExported = 10
|
||||
export static var staticExport = 1
|
||||
function staticParam(static x = 1) { return x }
|
||||
async export function oorder(x = 1) { return x }
|
||||
function cantExportParam(export x = 1) { return x }
|
||||
function cantAsyncParam(async x = 1) { return x }
|
||||
async async function extremelyAsync() {}
|
||||
async class CantAsyncClass {
|
||||
async cantAsyncPropert = 1
|
||||
}
|
||||
async const cantAsyncConst = 2
|
||||
async import 'assert'
|
||||
async export { CantAsyncClass }
|
||||
|
||||
// rest parameters
|
||||
function restMustBeLast(...x, y) {
|
||||
}
|
||||
function restCantHaveInitialiser(...x = [1,2,3]) {
|
||||
}
|
||||
function restCantHaveTrailingComma (...x,) {
|
||||
}
|
||||
;({ ...{} } = {})
|
||||
const doom = { e: 1, m: 1, name: "knee-deep" }
|
||||
const { ...rest, e: episode, m: mission } = doom
|
||||
const { e: eep, m: em, ...rest: noRestAllowed } = doom
|
||||
const { e: erp, m: erm, ...noInitialiser = true } = doom
|
||||
|
||||
// left-over parsing
|
||||
var;
|
||||
var x = 1 || 2 ?? 3
|
||||
var x = 2 ?? 3 || 4
|
||||
const arr = x
|
||||
=> x + 1
|
||||
var a = [1,2]
|
||||
a?.`length`;
|
||||
const o = {
|
||||
[console.log('oh no'),2]: 'hi',
|
||||
#noPrivate: 3,
|
||||
export cantExportProperties: 4,
|
||||
// TODO: See what the existing JS error is like for these
|
||||
cantHaveQuestionMark?: 1,
|
||||
m?() { return 12 },
|
||||
definitely!,
|
||||
definiteMethod!() { return 13 },
|
||||
}
|
||||
const noAssignment = {
|
||||
assignment = 1,
|
||||
}
|
||||
var noTrailingComma = 1,;
|
||||
class MissingExtends extends { }
|
||||
|
||||
// let/const mistakes
|
||||
const { e: ee };
|
||||
const noInit;
|
||||
let let = 15;
|
||||
if (true)
|
||||
let onlyBlockLet = 17;
|
||||
if (true)
|
||||
const onlyBlockConst = 18;
|
||||
|
||||
// loop mistakes
|
||||
let async
|
||||
export const l = [1,2,3]
|
||||
for (async of l) {
|
||||
console.log(x)
|
||||
}
|
||||
for (const cantHaveInit = 1 of [1,2,3]) {
|
||||
console.log(cantHaveInit)
|
||||
}
|
||||
for (const cantHaveInit = 1 in [1,2,3]) {
|
||||
console.log(cantHaveInit)
|
||||
}
|
||||
for (let y, x of [1,2,3]) {
|
||||
console.log(x)
|
||||
}
|
||||
for (let y, x in [1,2,3]) {
|
||||
console.log(x)
|
||||
}
|
||||
|
||||
// duplication mistakes
|
||||
var b
|
||||
switch (b) {
|
||||
case false:
|
||||
console.log('no')
|
||||
default:
|
||||
console.log('yes')
|
||||
default:
|
||||
console.log('wat')
|
||||
}
|
||||
try {
|
||||
throw 2
|
||||
}
|
||||
catch (e) {
|
||||
const e = 1
|
||||
console.log(e)
|
||||
}
|
||||
label: for (const x in [1,2,3]) {
|
||||
label: for (const y in [1,2,3]) {
|
||||
break label;
|
||||
}
|
||||
}
|
||||
|
||||
// labels
|
||||
function crossFunctionBoundary() {
|
||||
outer: for(;;) {
|
||||
function test() {
|
||||
break outer
|
||||
}
|
||||
test()
|
||||
}
|
||||
}
|
||||
function continueIterationOnly(x) {
|
||||
outer: switch (x) {
|
||||
case 1:
|
||||
continue outer
|
||||
}
|
||||
}
|
||||
function jumpToLabelOnly(x) {
|
||||
break jumpToLabelOnly
|
||||
}
|
||||
for (;;) {
|
||||
break toplevel
|
||||
continue toplevel
|
||||
}
|
||||
break
|
||||
continue
|
||||
|
||||
// other weirdness
|
||||
export let noMeta = import.metal
|
||||
function foo() { new.targe }
|
||||
const nullaryDynamicImport = import()
|
||||
const trinaryDynamicImport = import('1', '2', '3')
|
||||
const spreadDynamicImport = import(...[])
|
||||
|
||||
|
||||
//// [plainJSGrammarErrors.js]
|
||||
class C {
|
||||
// #private mistakes
|
||||
q = #unbound;
|
||||
m() {
|
||||
#p;
|
||||
if (#po in this) {
|
||||
}
|
||||
}
|
||||
#m() {
|
||||
this.#m = () => { };
|
||||
}
|
||||
// await in static block
|
||||
static {
|
||||
for await (const x of [1, 2, 3]) {
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
// modifier mistakes
|
||||
static constructor() { }
|
||||
async constructor() { }
|
||||
x = 1;
|
||||
y() {
|
||||
return 12;
|
||||
}
|
||||
async async extremelyAsync() {
|
||||
}
|
||||
async static oorder() { }
|
||||
export cantExportProperty = 1;
|
||||
export cantExportMethod() {
|
||||
}
|
||||
// accessor mistakes
|
||||
get incorporeal() { }
|
||||
get parametric(n) { return 1; }
|
||||
set invariant() { }
|
||||
set binary(fst, snd) { }
|
||||
set variable(...n) { }
|
||||
// other
|
||||
"constructor" = 16;
|
||||
}
|
||||
// #private mistakes
|
||||
#unrelated;
|
||||
junk.#m;
|
||||
new C().#m;
|
||||
// modifier mistakes
|
||||
export export var extremelyExported = 10;
|
||||
export static var staticExport = 1;
|
||||
function staticParam(static x = 1) { return x; }
|
||||
async export function oorder(x = 1) { return x; }
|
||||
function cantExportParam(export x = 1) { return x; }
|
||||
function cantAsyncParam(async x = 1) { return x; }
|
||||
async async function extremelyAsync() { }
|
||||
async class CantAsyncClass {
|
||||
async cantAsyncPropert = 1;
|
||||
}
|
||||
async const cantAsyncConst = 2;
|
||||
async import 'assert';
|
||||
export { CantAsyncClass };
|
||||
// rest parameters
|
||||
function restMustBeLast(...x, y) {
|
||||
}
|
||||
function restCantHaveInitialiser(...x = [1, 2, 3]) {
|
||||
}
|
||||
function restCantHaveTrailingComma(...x) {
|
||||
}
|
||||
;
|
||||
({ ...{} } = {});
|
||||
const doom = { e: 1, m: 1, name: "knee-deep" };
|
||||
const { ...rest, e: episode, m: mission } = doom;
|
||||
const { e: eep, m: em, ...rest: noRestAllowed } = doom;
|
||||
const { e: erp, m: erm, ...noInitialiser = true } = doom;
|
||||
// left-over parsing
|
||||
var ;
|
||||
var x = 1 || 2 ?? 3;
|
||||
var x = 2 ?? 3 || 4;
|
||||
const arr = x => x + 1;
|
||||
var a = [1, 2];
|
||||
a `length`;
|
||||
const o = {
|
||||
[console.log('oh no'), 2]: 'hi',
|
||||
#noPrivate: 3,
|
||||
cantExportProperties: 4,
|
||||
// TODO: See what the existing JS error is like for these
|
||||
cantHaveQuestionMark: 1,
|
||||
m() { return 12; },
|
||||
definitely,
|
||||
definiteMethod() { return 13; },
|
||||
};
|
||||
const noAssignment = {
|
||||
assignment = 1,
|
||||
};
|
||||
var noTrailingComma = 1;
|
||||
class MissingExtends extends {
|
||||
}
|
||||
// let/const mistakes
|
||||
const { e: ee };
|
||||
const noInit;
|
||||
let let = 15;
|
||||
if (true)
|
||||
let onlyBlockLet = 17;
|
||||
if (true)
|
||||
const onlyBlockConst = 18;
|
||||
// loop mistakes
|
||||
let async;
|
||||
export const l = [1, 2, 3];
|
||||
for (async of l) {
|
||||
console.log(x);
|
||||
}
|
||||
for (const cantHaveInit = 1 of [1, 2, 3]) {
|
||||
console.log(cantHaveInit);
|
||||
}
|
||||
for (const cantHaveInit = 1 in [1, 2, 3]) {
|
||||
console.log(cantHaveInit);
|
||||
}
|
||||
for (let y, x of [1, 2, 3]) {
|
||||
console.log(x);
|
||||
}
|
||||
for (let y, x in [1, 2, 3]) {
|
||||
console.log(x);
|
||||
}
|
||||
// duplication mistakes
|
||||
var b;
|
||||
switch (b) {
|
||||
case false:
|
||||
console.log('no');
|
||||
default:
|
||||
console.log('yes');
|
||||
default:
|
||||
console.log('wat');
|
||||
}
|
||||
try {
|
||||
throw 2;
|
||||
}
|
||||
catch (e) {
|
||||
const e = 1;
|
||||
console.log(e);
|
||||
}
|
||||
label: for (const x in [1, 2, 3]) {
|
||||
label: for (const y in [1, 2, 3]) {
|
||||
break label;
|
||||
}
|
||||
}
|
||||
// labels
|
||||
function crossFunctionBoundary() {
|
||||
outer: for (;;) {
|
||||
function test() {
|
||||
break outer;
|
||||
}
|
||||
test();
|
||||
}
|
||||
}
|
||||
function continueIterationOnly(x) {
|
||||
outer: switch (x) {
|
||||
case 1:
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
function jumpToLabelOnly(x) {
|
||||
break jumpToLabelOnly;
|
||||
}
|
||||
for (;;) {
|
||||
break toplevel;
|
||||
continue toplevel;
|
||||
}
|
||||
break;
|
||||
continue;
|
||||
// other weirdness
|
||||
export let noMeta = import.metal;
|
||||
function foo() { new.targe; }
|
||||
const nullaryDynamicImport = import();
|
||||
const trinaryDynamicImport = import('1', '2', '3');
|
||||
const spreadDynamicImport = import(...[]);
|
||||
419
tests/baselines/reference/plainJSGrammarErrors.symbols
Normal file
419
tests/baselines/reference/plainJSGrammarErrors.symbols
Normal file
@@ -0,0 +1,419 @@
|
||||
=== tests/cases/conformance/salsa/plainJSGrammarErrors.js ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(plainJSGrammarErrors.js, 0, 0))
|
||||
|
||||
// #private mistakes
|
||||
q = #unbound
|
||||
>q : Symbol(C.q, Decl(plainJSGrammarErrors.js, 0, 9))
|
||||
|
||||
m() {
|
||||
>m : Symbol(C.m, Decl(plainJSGrammarErrors.js, 2, 16))
|
||||
|
||||
#p
|
||||
if (#po in this) {
|
||||
>this : Symbol(C, Decl(plainJSGrammarErrors.js, 0, 0))
|
||||
}
|
||||
}
|
||||
#m() {
|
||||
>#m : Symbol(C.#m, Decl(plainJSGrammarErrors.js, 7, 5))
|
||||
|
||||
this.#m = () => {}
|
||||
>this.#m : Symbol(C.#m, Decl(plainJSGrammarErrors.js, 7, 5))
|
||||
>this : Symbol(C, Decl(plainJSGrammarErrors.js, 0, 0))
|
||||
}
|
||||
// await in static block
|
||||
static {
|
||||
for await (const x of [1,2,3]) {
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 13, 24))
|
||||
|
||||
console.log(x)
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 13, 24))
|
||||
}
|
||||
}
|
||||
// modifier mistakes
|
||||
static constructor() { }
|
||||
async constructor() { }
|
||||
const x = 1
|
||||
>x : Symbol(C.x, Decl(plainJSGrammarErrors.js, 19, 27))
|
||||
|
||||
const y() {
|
||||
>y : Symbol(C.y, Decl(plainJSGrammarErrors.js, 20, 15))
|
||||
|
||||
return 12
|
||||
}
|
||||
async async extremelyAsync() {
|
||||
>extremelyAsync : Symbol(C.extremelyAsync, Decl(plainJSGrammarErrors.js, 23, 5))
|
||||
}
|
||||
async static oorder(){ }
|
||||
>oorder : Symbol(C.oorder, Decl(plainJSGrammarErrors.js, 25, 5))
|
||||
|
||||
export cantExportProperty = 1
|
||||
>cantExportProperty : Symbol(C.cantExportProperty, Decl(plainJSGrammarErrors.js, 26, 28))
|
||||
|
||||
export cantExportMethod() {
|
||||
>cantExportMethod : Symbol(C.cantExportMethod, Decl(plainJSGrammarErrors.js, 27, 33))
|
||||
}
|
||||
|
||||
// accessor mistakes
|
||||
get incorporeal();
|
||||
>incorporeal : Symbol(C.incorporeal, Decl(plainJSGrammarErrors.js, 29, 5))
|
||||
|
||||
get parametric(n) { return 1 }
|
||||
>parametric : Symbol(C.parametric, Decl(plainJSGrammarErrors.js, 32, 22))
|
||||
>n : Symbol(n, Decl(plainJSGrammarErrors.js, 33, 19))
|
||||
|
||||
set invariant() { }
|
||||
>invariant : Symbol(C.invariant, Decl(plainJSGrammarErrors.js, 33, 34))
|
||||
|
||||
set binary(fst, snd) { }
|
||||
>binary : Symbol(C.binary, Decl(plainJSGrammarErrors.js, 34, 23))
|
||||
>fst : Symbol(fst, Decl(plainJSGrammarErrors.js, 35, 15))
|
||||
>snd : Symbol(snd, Decl(plainJSGrammarErrors.js, 35, 19))
|
||||
|
||||
set variable(...n) { }
|
||||
>variable : Symbol(C.variable, Decl(plainJSGrammarErrors.js, 35, 28))
|
||||
>n : Symbol(n, Decl(plainJSGrammarErrors.js, 36, 17))
|
||||
|
||||
// other
|
||||
"constructor" = 16
|
||||
>"constructor" : Symbol(C["constructor"], Decl(plainJSGrammarErrors.js, 36, 26))
|
||||
}
|
||||
// #private mistakes
|
||||
#unrelated
|
||||
junk.#m
|
||||
new C().#m
|
||||
>C : Symbol(C, Decl(plainJSGrammarErrors.js, 0, 0))
|
||||
|
||||
// modifier mistakes
|
||||
export export var extremelyExported = 10
|
||||
>extremelyExported : Symbol(extremelyExported, Decl(plainJSGrammarErrors.js, 47, 17))
|
||||
|
||||
export static var staticExport = 1
|
||||
>staticExport : Symbol(staticExport, Decl(plainJSGrammarErrors.js, 48, 17))
|
||||
|
||||
function staticParam(static x = 1) { return x }
|
||||
>staticParam : Symbol(staticParam, Decl(plainJSGrammarErrors.js, 48, 34))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 49, 21))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 49, 21))
|
||||
|
||||
async export function oorder(x = 1) { return x }
|
||||
>oorder : Symbol(oorder, Decl(plainJSGrammarErrors.js, 49, 47))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 50, 29))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 50, 29))
|
||||
|
||||
function cantExportParam(export x = 1) { return x }
|
||||
>cantExportParam : Symbol(cantExportParam, Decl(plainJSGrammarErrors.js, 50, 48))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 51, 25))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 51, 25))
|
||||
|
||||
function cantAsyncParam(async x = 1) { return x }
|
||||
>cantAsyncParam : Symbol(cantAsyncParam, Decl(plainJSGrammarErrors.js, 51, 51))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 52, 24))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 52, 24))
|
||||
|
||||
async async function extremelyAsync() {}
|
||||
>extremelyAsync : Symbol(extremelyAsync, Decl(plainJSGrammarErrors.js, 52, 49))
|
||||
|
||||
async class CantAsyncClass {
|
||||
>CantAsyncClass : Symbol(CantAsyncClass, Decl(plainJSGrammarErrors.js, 53, 40))
|
||||
|
||||
async cantAsyncPropert = 1
|
||||
>cantAsyncPropert : Symbol(CantAsyncClass.cantAsyncPropert, Decl(plainJSGrammarErrors.js, 54, 28))
|
||||
}
|
||||
async const cantAsyncConst = 2
|
||||
>cantAsyncConst : Symbol(cantAsyncConst, Decl(plainJSGrammarErrors.js, 57, 11))
|
||||
|
||||
async import 'assert'
|
||||
async export { CantAsyncClass }
|
||||
>CantAsyncClass : Symbol(CantAsyncClass, Decl(plainJSGrammarErrors.js, 59, 14))
|
||||
|
||||
// rest parameters
|
||||
function restMustBeLast(...x, y) {
|
||||
>restMustBeLast : Symbol(restMustBeLast, Decl(plainJSGrammarErrors.js, 59, 31))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 62, 24))
|
||||
>y : Symbol(y, Decl(plainJSGrammarErrors.js, 62, 29))
|
||||
}
|
||||
function restCantHaveInitialiser(...x = [1,2,3]) {
|
||||
>restCantHaveInitialiser : Symbol(restCantHaveInitialiser, Decl(plainJSGrammarErrors.js, 63, 1))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 64, 33))
|
||||
}
|
||||
function restCantHaveTrailingComma (...x,) {
|
||||
>restCantHaveTrailingComma : Symbol(restCantHaveTrailingComma, Decl(plainJSGrammarErrors.js, 65, 1))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 66, 36))
|
||||
}
|
||||
;({ ...{} } = {})
|
||||
const doom = { e: 1, m: 1, name: "knee-deep" }
|
||||
>doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 69, 5))
|
||||
>e : Symbol(e, Decl(plainJSGrammarErrors.js, 69, 14))
|
||||
>m : Symbol(m, Decl(plainJSGrammarErrors.js, 69, 20))
|
||||
>name : Symbol(name, Decl(plainJSGrammarErrors.js, 69, 26))
|
||||
|
||||
const { ...rest, e: episode, m: mission } = doom
|
||||
>rest : Symbol(rest, Decl(plainJSGrammarErrors.js, 70, 7))
|
||||
>e : Symbol(e, Decl(plainJSGrammarErrors.js, 69, 14))
|
||||
>episode : Symbol(episode, Decl(plainJSGrammarErrors.js, 70, 16))
|
||||
>m : Symbol(m, Decl(plainJSGrammarErrors.js, 69, 20))
|
||||
>mission : Symbol(mission, Decl(plainJSGrammarErrors.js, 70, 28))
|
||||
>doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 69, 5))
|
||||
|
||||
const { e: eep, m: em, ...rest: noRestAllowed } = doom
|
||||
>e : Symbol(e, Decl(plainJSGrammarErrors.js, 69, 14))
|
||||
>eep : Symbol(eep, Decl(plainJSGrammarErrors.js, 71, 7))
|
||||
>m : Symbol(m, Decl(plainJSGrammarErrors.js, 69, 20))
|
||||
>em : Symbol(em, Decl(plainJSGrammarErrors.js, 71, 15))
|
||||
>noRestAllowed : Symbol(noRestAllowed, Decl(plainJSGrammarErrors.js, 71, 22))
|
||||
>doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 69, 5))
|
||||
|
||||
const { e: erp, m: erm, ...noInitialiser = true } = doom
|
||||
>e : Symbol(e, Decl(plainJSGrammarErrors.js, 69, 14))
|
||||
>erp : Symbol(erp, Decl(plainJSGrammarErrors.js, 72, 7))
|
||||
>m : Symbol(m, Decl(plainJSGrammarErrors.js, 69, 20))
|
||||
>erm : Symbol(erm, Decl(plainJSGrammarErrors.js, 72, 15))
|
||||
>noInitialiser : Symbol(noInitialiser, Decl(plainJSGrammarErrors.js, 72, 23))
|
||||
>doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 69, 5))
|
||||
|
||||
// left-over parsing
|
||||
var;
|
||||
var x = 1 || 2 ?? 3
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 76, 3), Decl(plainJSGrammarErrors.js, 77, 3))
|
||||
|
||||
var x = 2 ?? 3 || 4
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 76, 3), Decl(plainJSGrammarErrors.js, 77, 3))
|
||||
|
||||
const arr = x
|
||||
>arr : Symbol(arr, Decl(plainJSGrammarErrors.js, 78, 5))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 78, 11))
|
||||
|
||||
=> x + 1
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 78, 11))
|
||||
|
||||
var a = [1,2]
|
||||
>a : Symbol(a, Decl(plainJSGrammarErrors.js, 80, 3))
|
||||
|
||||
a?.`length`;
|
||||
>a : Symbol(a, Decl(plainJSGrammarErrors.js, 80, 3))
|
||||
|
||||
const o = {
|
||||
>o : Symbol(o, Decl(plainJSGrammarErrors.js, 82, 5))
|
||||
|
||||
[console.log('oh no'),2]: 'hi',
|
||||
>[console.log('oh no'),2] : Symbol([console.log('oh no'),2], Decl(plainJSGrammarErrors.js, 82, 11))
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
|
||||
#noPrivate: 3,
|
||||
>#noPrivate : Symbol(#noPrivate, Decl(plainJSGrammarErrors.js, 83, 35))
|
||||
|
||||
export cantExportProperties: 4,
|
||||
>cantExportProperties : Symbol(cantExportProperties, Decl(plainJSGrammarErrors.js, 84, 18))
|
||||
|
||||
// TODO: See what the existing JS error is like for these
|
||||
cantHaveQuestionMark?: 1,
|
||||
>cantHaveQuestionMark : Symbol(cantHaveQuestionMark, Decl(plainJSGrammarErrors.js, 85, 35))
|
||||
|
||||
m?() { return 12 },
|
||||
>m : Symbol(m, Decl(plainJSGrammarErrors.js, 87, 29))
|
||||
|
||||
definitely!,
|
||||
>definitely : Symbol(definitely, Decl(plainJSGrammarErrors.js, 88, 23))
|
||||
|
||||
definiteMethod!() { return 13 },
|
||||
>definiteMethod : Symbol(definiteMethod, Decl(plainJSGrammarErrors.js, 89, 16))
|
||||
}
|
||||
const noAssignment = {
|
||||
>noAssignment : Symbol(noAssignment, Decl(plainJSGrammarErrors.js, 92, 5))
|
||||
|
||||
assignment = 1,
|
||||
>assignment : Symbol(assignment, Decl(plainJSGrammarErrors.js, 92, 22))
|
||||
}
|
||||
var noTrailingComma = 1,;
|
||||
>noTrailingComma : Symbol(noTrailingComma, Decl(plainJSGrammarErrors.js, 95, 3))
|
||||
|
||||
class MissingExtends extends { }
|
||||
>MissingExtends : Symbol(MissingExtends, Decl(plainJSGrammarErrors.js, 95, 25))
|
||||
|
||||
// let/const mistakes
|
||||
const { e: ee };
|
||||
>e : Symbol(e)
|
||||
>ee : Symbol(ee, Decl(plainJSGrammarErrors.js, 99, 7))
|
||||
|
||||
const noInit;
|
||||
>noInit : Symbol(noInit, Decl(plainJSGrammarErrors.js, 100, 5))
|
||||
|
||||
let let = 15;
|
||||
>let : Symbol(let, Decl(plainJSGrammarErrors.js, 101, 3))
|
||||
|
||||
if (true)
|
||||
let onlyBlockLet = 17;
|
||||
>onlyBlockLet : Symbol(onlyBlockLet, Decl(plainJSGrammarErrors.js, 103, 7))
|
||||
|
||||
if (true)
|
||||
const onlyBlockConst = 18;
|
||||
>onlyBlockConst : Symbol(onlyBlockConst, Decl(plainJSGrammarErrors.js, 105, 9))
|
||||
|
||||
// loop mistakes
|
||||
let async
|
||||
>async : Symbol(async, Decl(plainJSGrammarErrors.js, 108, 3))
|
||||
|
||||
export const l = [1,2,3]
|
||||
>l : Symbol(l, Decl(plainJSGrammarErrors.js, 109, 12))
|
||||
|
||||
for (async of l) {
|
||||
>async : Symbol(async, Decl(plainJSGrammarErrors.js, 108, 3))
|
||||
>l : Symbol(l, Decl(plainJSGrammarErrors.js, 109, 12))
|
||||
|
||||
console.log(x)
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 76, 3), Decl(plainJSGrammarErrors.js, 77, 3))
|
||||
}
|
||||
for (const cantHaveInit = 1 of [1,2,3]) {
|
||||
>cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 113, 10))
|
||||
|
||||
console.log(cantHaveInit)
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 113, 10))
|
||||
}
|
||||
for (const cantHaveInit = 1 in [1,2,3]) {
|
||||
>cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 116, 10))
|
||||
|
||||
console.log(cantHaveInit)
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 116, 10))
|
||||
}
|
||||
for (let y, x of [1,2,3]) {
|
||||
>y : Symbol(y, Decl(plainJSGrammarErrors.js, 119, 8))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 119, 11))
|
||||
|
||||
console.log(x)
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 119, 11))
|
||||
}
|
||||
for (let y, x in [1,2,3]) {
|
||||
>y : Symbol(y, Decl(plainJSGrammarErrors.js, 122, 8))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 122, 11))
|
||||
|
||||
console.log(x)
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 122, 11))
|
||||
}
|
||||
|
||||
// duplication mistakes
|
||||
var b
|
||||
>b : Symbol(b, Decl(plainJSGrammarErrors.js, 127, 3))
|
||||
|
||||
switch (b) {
|
||||
>b : Symbol(b, Decl(plainJSGrammarErrors.js, 127, 3))
|
||||
|
||||
case false:
|
||||
console.log('no')
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
|
||||
default:
|
||||
console.log('yes')
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
|
||||
default:
|
||||
console.log('wat')
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
try {
|
||||
throw 2
|
||||
}
|
||||
catch (e) {
|
||||
>e : Symbol(e, Decl(plainJSGrammarErrors.js, 139, 7))
|
||||
|
||||
const e = 1
|
||||
>e : Symbol(e, Decl(plainJSGrammarErrors.js, 140, 9))
|
||||
|
||||
console.log(e)
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>e : Symbol(e, Decl(plainJSGrammarErrors.js, 140, 9))
|
||||
}
|
||||
label: for (const x in [1,2,3]) {
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 143, 17))
|
||||
|
||||
label: for (const y in [1,2,3]) {
|
||||
>y : Symbol(y, Decl(plainJSGrammarErrors.js, 144, 21))
|
||||
|
||||
break label;
|
||||
}
|
||||
}
|
||||
|
||||
// labels
|
||||
function crossFunctionBoundary() {
|
||||
>crossFunctionBoundary : Symbol(crossFunctionBoundary, Decl(plainJSGrammarErrors.js, 147, 1))
|
||||
|
||||
outer: for(;;) {
|
||||
function test() {
|
||||
>test : Symbol(test, Decl(plainJSGrammarErrors.js, 151, 20))
|
||||
|
||||
break outer
|
||||
}
|
||||
test()
|
||||
>test : Symbol(test, Decl(plainJSGrammarErrors.js, 151, 20))
|
||||
}
|
||||
}
|
||||
function continueIterationOnly(x) {
|
||||
>continueIterationOnly : Symbol(continueIterationOnly, Decl(plainJSGrammarErrors.js, 157, 1))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 158, 31))
|
||||
|
||||
outer: switch (x) {
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 158, 31))
|
||||
|
||||
case 1:
|
||||
continue outer
|
||||
}
|
||||
}
|
||||
function jumpToLabelOnly(x) {
|
||||
>jumpToLabelOnly : Symbol(jumpToLabelOnly, Decl(plainJSGrammarErrors.js, 163, 1))
|
||||
>x : Symbol(x, Decl(plainJSGrammarErrors.js, 164, 25))
|
||||
|
||||
break jumpToLabelOnly
|
||||
}
|
||||
for (;;) {
|
||||
break toplevel
|
||||
continue toplevel
|
||||
}
|
||||
break
|
||||
continue
|
||||
|
||||
// other weirdness
|
||||
export let noMeta = import.metal
|
||||
>noMeta : Symbol(noMeta, Decl(plainJSGrammarErrors.js, 175, 10))
|
||||
|
||||
function foo() { new.targe }
|
||||
>foo : Symbol(foo, Decl(plainJSGrammarErrors.js, 175, 32))
|
||||
>new.targe : Symbol(foo, Decl(plainJSGrammarErrors.js, 175, 32))
|
||||
>targe : Symbol(foo, Decl(plainJSGrammarErrors.js, 175, 32))
|
||||
|
||||
const nullaryDynamicImport = import()
|
||||
>nullaryDynamicImport : Symbol(nullaryDynamicImport, Decl(plainJSGrammarErrors.js, 177, 5))
|
||||
|
||||
const trinaryDynamicImport = import('1', '2', '3')
|
||||
>trinaryDynamicImport : Symbol(trinaryDynamicImport, Decl(plainJSGrammarErrors.js, 178, 5))
|
||||
|
||||
const spreadDynamicImport = import(...[])
|
||||
>spreadDynamicImport : Symbol(spreadDynamicImport, Decl(plainJSGrammarErrors.js, 179, 5))
|
||||
|
||||
572
tests/baselines/reference/plainJSGrammarErrors.types
Normal file
572
tests/baselines/reference/plainJSGrammarErrors.types
Normal file
@@ -0,0 +1,572 @@
|
||||
=== tests/cases/conformance/salsa/plainJSGrammarErrors.js ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
// #private mistakes
|
||||
q = #unbound
|
||||
>q : any
|
||||
|
||||
m() {
|
||||
>m : () => void
|
||||
|
||||
#p
|
||||
if (#po in this) {
|
||||
>#po in this : boolean
|
||||
>#po : any
|
||||
>this : this
|
||||
}
|
||||
}
|
||||
#m() {
|
||||
>#m : () => void
|
||||
|
||||
this.#m = () => {}
|
||||
>this.#m = () => {} : () => void
|
||||
>this.#m : () => void
|
||||
>this : this
|
||||
>() => {} : () => void
|
||||
}
|
||||
// await in static block
|
||||
static {
|
||||
for await (const x of [1,2,3]) {
|
||||
>x : number
|
||||
>[1,2,3] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
console.log(x)
|
||||
>console.log(x) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>x : number
|
||||
}
|
||||
}
|
||||
// modifier mistakes
|
||||
static constructor() { }
|
||||
async constructor() { }
|
||||
const x = 1
|
||||
>x : number
|
||||
>1 : 1
|
||||
|
||||
const y() {
|
||||
>y : () => number
|
||||
|
||||
return 12
|
||||
>12 : 12
|
||||
}
|
||||
async async extremelyAsync() {
|
||||
>extremelyAsync : () => Promise<void>
|
||||
}
|
||||
async static oorder(){ }
|
||||
>oorder : () => Promise<void>
|
||||
|
||||
export cantExportProperty = 1
|
||||
>cantExportProperty : number
|
||||
>1 : 1
|
||||
|
||||
export cantExportMethod() {
|
||||
>cantExportMethod : () => void
|
||||
}
|
||||
|
||||
// accessor mistakes
|
||||
get incorporeal();
|
||||
>incorporeal : any
|
||||
|
||||
get parametric(n) { return 1 }
|
||||
>parametric : number
|
||||
>n : any
|
||||
>1 : 1
|
||||
|
||||
set invariant() { }
|
||||
>invariant : any
|
||||
|
||||
set binary(fst, snd) { }
|
||||
>binary : any
|
||||
>fst : any
|
||||
>snd : any
|
||||
|
||||
set variable(...n) { }
|
||||
>variable : any
|
||||
>n : any[]
|
||||
|
||||
// other
|
||||
"constructor" = 16
|
||||
>"constructor" : number
|
||||
>16 : 16
|
||||
}
|
||||
// #private mistakes
|
||||
#unrelated
|
||||
junk.#m
|
||||
>junk.#m : any
|
||||
>junk : any
|
||||
|
||||
new C().#m
|
||||
>new C().#m : any
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
|
||||
// modifier mistakes
|
||||
export export var extremelyExported = 10
|
||||
>extremelyExported : number
|
||||
>10 : 10
|
||||
|
||||
export static var staticExport = 1
|
||||
>staticExport : number
|
||||
>1 : 1
|
||||
|
||||
function staticParam(static x = 1) { return x }
|
||||
>staticParam : (x?: number) => number
|
||||
>x : number
|
||||
>1 : 1
|
||||
>x : number
|
||||
|
||||
async export function oorder(x = 1) { return x }
|
||||
>oorder : (x?: number) => Promise<number>
|
||||
>x : number
|
||||
>1 : 1
|
||||
>x : number
|
||||
|
||||
function cantExportParam(export x = 1) { return x }
|
||||
>cantExportParam : (x?: number) => number
|
||||
>x : number
|
||||
>1 : 1
|
||||
>x : number
|
||||
|
||||
function cantAsyncParam(async x = 1) { return x }
|
||||
>cantAsyncParam : (x?: number) => number
|
||||
>x : number
|
||||
>1 : 1
|
||||
>x : number
|
||||
|
||||
async async function extremelyAsync() {}
|
||||
>extremelyAsync : () => Promise<void>
|
||||
|
||||
async class CantAsyncClass {
|
||||
>CantAsyncClass : CantAsyncClass
|
||||
|
||||
async cantAsyncPropert = 1
|
||||
>cantAsyncPropert : number
|
||||
>1 : 1
|
||||
}
|
||||
async const cantAsyncConst = 2
|
||||
>cantAsyncConst : 2
|
||||
>2 : 2
|
||||
|
||||
async import 'assert'
|
||||
async export { CantAsyncClass }
|
||||
>CantAsyncClass : typeof CantAsyncClass
|
||||
|
||||
// rest parameters
|
||||
function restMustBeLast(...x, y) {
|
||||
>restMustBeLast : (...x: any[], y: any) => void
|
||||
>x : any[]
|
||||
>y : any
|
||||
}
|
||||
function restCantHaveInitialiser(...x = [1,2,3]) {
|
||||
>restCantHaveInitialiser : (...x?: number[]) => void
|
||||
>x : number[]
|
||||
>[1,2,3] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
}
|
||||
function restCantHaveTrailingComma (...x,) {
|
||||
>restCantHaveTrailingComma : (...x: any[]) => void
|
||||
>x : any[]
|
||||
}
|
||||
;({ ...{} } = {})
|
||||
>({ ...{} } = {}) : {}
|
||||
>{ ...{} } = {} : {}
|
||||
>{ ...{} } : {}
|
||||
>{} : {}
|
||||
>{} : {}
|
||||
|
||||
const doom = { e: 1, m: 1, name: "knee-deep" }
|
||||
>doom : { e: number; m: number; name: string; }
|
||||
>{ e: 1, m: 1, name: "knee-deep" } : { e: number; m: number; name: string; }
|
||||
>e : number
|
||||
>1 : 1
|
||||
>m : number
|
||||
>1 : 1
|
||||
>name : string
|
||||
>"knee-deep" : "knee-deep"
|
||||
|
||||
const { ...rest, e: episode, m: mission } = doom
|
||||
>rest : { name: string; }
|
||||
>e : any
|
||||
>episode : number
|
||||
>m : any
|
||||
>mission : number
|
||||
>doom : { e: number; m: number; name: string; }
|
||||
|
||||
const { e: eep, m: em, ...rest: noRestAllowed } = doom
|
||||
>e : any
|
||||
>eep : number
|
||||
>m : any
|
||||
>em : number
|
||||
>rest : any
|
||||
>noRestAllowed : { name: string; }
|
||||
>doom : { e: number; m: number; name: string; }
|
||||
|
||||
const { e: erp, m: erm, ...noInitialiser = true } = doom
|
||||
>e : any
|
||||
>erp : number
|
||||
>m : any
|
||||
>erm : number
|
||||
>noInitialiser : true | { name: string; }
|
||||
>true : true
|
||||
>doom : { e: number; m: number; name: string; }
|
||||
|
||||
// left-over parsing
|
||||
var;
|
||||
var x = 1 || 2 ?? 3
|
||||
>x : number
|
||||
>1 || 2 ?? 3 : 1 | 2 | 3
|
||||
>1 || 2 : 1 | 2
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
var x = 2 ?? 3 || 4
|
||||
>x : number
|
||||
>2 ?? 3 || 4 : 2 | 3 | 4
|
||||
>2 : 2
|
||||
>3 || 4 : 3 | 4
|
||||
>3 : 3
|
||||
>4 : 4
|
||||
|
||||
const arr = x
|
||||
>arr : (x: any) => any
|
||||
>x => x + 1 : (x: any) => any
|
||||
>x : any
|
||||
|
||||
=> x + 1
|
||||
>x + 1 : any
|
||||
>x : any
|
||||
>1 : 1
|
||||
|
||||
var a = [1,2]
|
||||
>a : number[]
|
||||
>[1,2] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
|
||||
a?.`length`;
|
||||
>a?.`length` : any
|
||||
>a : number[]
|
||||
>`length` : "length"
|
||||
|
||||
const o = {
|
||||
>o : { 2: string; cantExportProperties: number; cantHaveQuestionMark: number; m?(): number; definitely: any; definiteMethod(): number; }
|
||||
>{ [console.log('oh no'),2]: 'hi', #noPrivate: 3, export cantExportProperties: 4, // TODO: See what the existing JS error is like for these cantHaveQuestionMark?: 1, m?() { return 12 }, definitely!, definiteMethod!() { return 13 },} : { 2: string; cantExportProperties: number; cantHaveQuestionMark: number; m?(): number; definitely: any; definiteMethod(): number; }
|
||||
|
||||
[console.log('oh no'),2]: 'hi',
|
||||
>[console.log('oh no'),2] : string
|
||||
>console.log('oh no'),2 : 2
|
||||
>console.log('oh no') : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>'oh no' : "oh no"
|
||||
>2 : 2
|
||||
>'hi' : "hi"
|
||||
|
||||
#noPrivate: 3,
|
||||
>#noPrivate : number
|
||||
>3 : 3
|
||||
|
||||
export cantExportProperties: 4,
|
||||
>cantExportProperties : number
|
||||
>4 : 4
|
||||
|
||||
// TODO: See what the existing JS error is like for these
|
||||
cantHaveQuestionMark?: 1,
|
||||
>cantHaveQuestionMark : number
|
||||
>1 : 1
|
||||
|
||||
m?() { return 12 },
|
||||
>m : () => number
|
||||
>12 : 12
|
||||
|
||||
definitely!,
|
||||
>definitely : any
|
||||
|
||||
definiteMethod!() { return 13 },
|
||||
>definiteMethod : () => number
|
||||
>13 : 13
|
||||
}
|
||||
const noAssignment = {
|
||||
>noAssignment : { assignment: number; }
|
||||
>{ assignment = 1,} : { assignment: number; }
|
||||
|
||||
assignment = 1,
|
||||
>assignment : any
|
||||
>1 : 1
|
||||
}
|
||||
var noTrailingComma = 1,;
|
||||
>noTrailingComma : number
|
||||
>1 : 1
|
||||
|
||||
class MissingExtends extends { }
|
||||
>MissingExtends : MissingExtends
|
||||
|
||||
// let/const mistakes
|
||||
const { e: ee };
|
||||
>e : any
|
||||
>ee : any
|
||||
|
||||
const noInit;
|
||||
>noInit : any
|
||||
|
||||
let let = 15;
|
||||
>let : number
|
||||
>15 : 15
|
||||
|
||||
if (true)
|
||||
>true : true
|
||||
|
||||
let onlyBlockLet = 17;
|
||||
>onlyBlockLet : number
|
||||
>17 : 17
|
||||
|
||||
if (true)
|
||||
>true : true
|
||||
|
||||
const onlyBlockConst = 18;
|
||||
>onlyBlockConst : 18
|
||||
>18 : 18
|
||||
|
||||
// loop mistakes
|
||||
let async
|
||||
>async : any
|
||||
|
||||
export const l = [1,2,3]
|
||||
>l : number[]
|
||||
>[1,2,3] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
for (async of l) {
|
||||
>async : any
|
||||
>l : number[]
|
||||
|
||||
console.log(x)
|
||||
>console.log(x) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>x : number
|
||||
}
|
||||
for (const cantHaveInit = 1 of [1,2,3]) {
|
||||
>cantHaveInit : number
|
||||
>1 : 1
|
||||
>[1,2,3] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
console.log(cantHaveInit)
|
||||
>console.log(cantHaveInit) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>cantHaveInit : number
|
||||
}
|
||||
for (const cantHaveInit = 1 in [1,2,3]) {
|
||||
>cantHaveInit : string
|
||||
>1 : 1
|
||||
>[1,2,3] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
console.log(cantHaveInit)
|
||||
>console.log(cantHaveInit) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>cantHaveInit : string
|
||||
}
|
||||
for (let y, x of [1,2,3]) {
|
||||
>y : number
|
||||
>x : number
|
||||
>[1,2,3] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
console.log(x)
|
||||
>console.log(x) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>x : number
|
||||
}
|
||||
for (let y, x in [1,2,3]) {
|
||||
>y : string
|
||||
>x : string
|
||||
>[1,2,3] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
console.log(x)
|
||||
>console.log(x) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>x : string
|
||||
}
|
||||
|
||||
// duplication mistakes
|
||||
var b
|
||||
>b : any
|
||||
|
||||
switch (b) {
|
||||
>b : undefined
|
||||
|
||||
case false:
|
||||
>false : false
|
||||
|
||||
console.log('no')
|
||||
>console.log('no') : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>'no' : "no"
|
||||
|
||||
default:
|
||||
console.log('yes')
|
||||
>console.log('yes') : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>'yes' : "yes"
|
||||
|
||||
default:
|
||||
console.log('wat')
|
||||
>console.log('wat') : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>'wat' : "wat"
|
||||
}
|
||||
try {
|
||||
throw 2
|
||||
>2 : 2
|
||||
}
|
||||
catch (e) {
|
||||
>e : any
|
||||
|
||||
const e = 1
|
||||
>e : 1
|
||||
>1 : 1
|
||||
|
||||
console.log(e)
|
||||
>console.log(e) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>e : 1
|
||||
}
|
||||
label: for (const x in [1,2,3]) {
|
||||
>label : any
|
||||
>x : string
|
||||
>[1,2,3] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
label: for (const y in [1,2,3]) {
|
||||
>label : any
|
||||
>y : string
|
||||
>[1,2,3] : number[]
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
break label;
|
||||
>label : any
|
||||
}
|
||||
}
|
||||
|
||||
// labels
|
||||
function crossFunctionBoundary() {
|
||||
>crossFunctionBoundary : () => void
|
||||
|
||||
outer: for(;;) {
|
||||
>outer : any
|
||||
|
||||
function test() {
|
||||
>test : () => void
|
||||
|
||||
break outer
|
||||
>outer : any
|
||||
}
|
||||
test()
|
||||
>test() : void
|
||||
>test : () => void
|
||||
}
|
||||
}
|
||||
function continueIterationOnly(x) {
|
||||
>continueIterationOnly : (x: any) => void
|
||||
>x : any
|
||||
|
||||
outer: switch (x) {
|
||||
>outer : any
|
||||
>x : any
|
||||
|
||||
case 1:
|
||||
>1 : 1
|
||||
|
||||
continue outer
|
||||
>outer : any
|
||||
}
|
||||
}
|
||||
function jumpToLabelOnly(x) {
|
||||
>jumpToLabelOnly : (x: any) => void
|
||||
>x : any
|
||||
|
||||
break jumpToLabelOnly
|
||||
>jumpToLabelOnly : any
|
||||
}
|
||||
for (;;) {
|
||||
break toplevel
|
||||
>toplevel : any
|
||||
|
||||
continue toplevel
|
||||
>toplevel : any
|
||||
}
|
||||
break
|
||||
continue
|
||||
|
||||
// other weirdness
|
||||
export let noMeta = import.metal
|
||||
>noMeta : any
|
||||
>import.metal : any
|
||||
>metal : any
|
||||
|
||||
function foo() { new.targe }
|
||||
>foo : () => void
|
||||
>new.targe : () => void
|
||||
>targe : any
|
||||
|
||||
const nullaryDynamicImport = import()
|
||||
>nullaryDynamicImport : Promise<any>
|
||||
>import() : Promise<any>
|
||||
|
||||
const trinaryDynamicImport = import('1', '2', '3')
|
||||
>trinaryDynamicImport : Promise<any>
|
||||
>import('1', '2', '3') : Promise<any>
|
||||
>'1' : "1"
|
||||
>'2' : "2"
|
||||
>'3' : "3"
|
||||
|
||||
const spreadDynamicImport = import(...[])
|
||||
>spreadDynamicImport : Promise<any>
|
||||
>import(...[]) : Promise<any>
|
||||
>...[] : undefined
|
||||
>[] : undefined[]
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
tests/cases/conformance/salsa/plainJSReservedStrict.js(2,7): error TS1100: Invalid use of 'eval' in strict mode.
|
||||
tests/cases/conformance/salsa/plainJSReservedStrict.js(2,7): error TS2451: Cannot redeclare block-scoped variable 'eval'.
|
||||
tests/cases/conformance/salsa/plainJSReservedStrict.js(3,7): error TS1100: Invalid use of 'arguments' in strict mode.
|
||||
|
||||
|
||||
==== tests/cases/conformance/salsa/plainJSReservedStrict.js (2 errors) ====
|
||||
==== tests/cases/conformance/salsa/plainJSReservedStrict.js (3 errors) ====
|
||||
"use strict"
|
||||
const eval = 1
|
||||
~~~~
|
||||
!!! error TS1100: Invalid use of 'eval' in strict mode.
|
||||
~~~~
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'eval'.
|
||||
!!! related TS6203 /.ts/lib.es5.d.ts:32:18: 'eval' was also declared here.
|
||||
const arguments = 2
|
||||
~~~~~~~~~
|
||||
!!! error TS1100: Invalid use of 'arguments' in strict mode.
|
||||
|
||||
185
tests/cases/conformance/salsa/plainJSGrammarErrors.ts
Normal file
185
tests/cases/conformance/salsa/plainJSGrammarErrors.ts
Normal file
@@ -0,0 +1,185 @@
|
||||
// @outdir: out/
|
||||
// @target: esnext
|
||||
// @module: esnext
|
||||
// @allowJs: true
|
||||
// @filename: plainJSGrammarErrors.js
|
||||
class C {
|
||||
// #private mistakes
|
||||
q = #unbound
|
||||
m() {
|
||||
#p
|
||||
if (#po in this) {
|
||||
}
|
||||
}
|
||||
#m() {
|
||||
this.#m = () => {}
|
||||
}
|
||||
// await in static block
|
||||
static {
|
||||
for await (const x of [1,2,3]) {
|
||||
console.log(x)
|
||||
}
|
||||
}
|
||||
// modifier mistakes
|
||||
static constructor() { }
|
||||
async constructor() { }
|
||||
const x = 1
|
||||
const y() {
|
||||
return 12
|
||||
}
|
||||
async async extremelyAsync() {
|
||||
}
|
||||
async static oorder(){ }
|
||||
export cantExportProperty = 1
|
||||
export cantExportMethod() {
|
||||
}
|
||||
|
||||
// accessor mistakes
|
||||
get incorporeal();
|
||||
get parametric(n) { return 1 }
|
||||
set invariant() { }
|
||||
set binary(fst, snd) { }
|
||||
set variable(...n) { }
|
||||
|
||||
// other
|
||||
"constructor" = 16
|
||||
}
|
||||
// #private mistakes
|
||||
#unrelated
|
||||
junk.#m
|
||||
new C().#m
|
||||
|
||||
// modifier mistakes
|
||||
export export var extremelyExported = 10
|
||||
export static var staticExport = 1
|
||||
function staticParam(static x = 1) { return x }
|
||||
async export function oorder(x = 1) { return x }
|
||||
function cantExportParam(export x = 1) { return x }
|
||||
function cantAsyncParam(async x = 1) { return x }
|
||||
async async function extremelyAsync() {}
|
||||
async class CantAsyncClass {
|
||||
async cantAsyncPropert = 1
|
||||
}
|
||||
async const cantAsyncConst = 2
|
||||
async import 'assert'
|
||||
async export { CantAsyncClass }
|
||||
|
||||
// rest parameters
|
||||
function restMustBeLast(...x, y) {
|
||||
}
|
||||
function restCantHaveInitialiser(...x = [1,2,3]) {
|
||||
}
|
||||
function restCantHaveTrailingComma (...x,) {
|
||||
}
|
||||
;({ ...{} } = {})
|
||||
const doom = { e: 1, m: 1, name: "knee-deep" }
|
||||
const { ...rest, e: episode, m: mission } = doom
|
||||
const { e: eep, m: em, ...rest: noRestAllowed } = doom
|
||||
const { e: erp, m: erm, ...noInitialiser = true } = doom
|
||||
|
||||
// left-over parsing
|
||||
var;
|
||||
var x = 1 || 2 ?? 3
|
||||
var x = 2 ?? 3 || 4
|
||||
const arr = x
|
||||
=> x + 1
|
||||
var a = [1,2]
|
||||
a?.`length`;
|
||||
const o = {
|
||||
[console.log('oh no'),2]: 'hi',
|
||||
#noPrivate: 3,
|
||||
export cantExportProperties: 4,
|
||||
// TODO: See what the existing JS error is like for these
|
||||
cantHaveQuestionMark?: 1,
|
||||
m?() { return 12 },
|
||||
definitely!,
|
||||
definiteMethod!() { return 13 },
|
||||
}
|
||||
const noAssignment = {
|
||||
assignment = 1,
|
||||
}
|
||||
var noTrailingComma = 1,;
|
||||
class MissingExtends extends { }
|
||||
|
||||
// let/const mistakes
|
||||
const { e: ee };
|
||||
const noInit;
|
||||
let let = 15;
|
||||
if (true)
|
||||
let onlyBlockLet = 17;
|
||||
if (true)
|
||||
const onlyBlockConst = 18;
|
||||
|
||||
// loop mistakes
|
||||
let async
|
||||
export const l = [1,2,3]
|
||||
for (async of l) {
|
||||
console.log(x)
|
||||
}
|
||||
for (const cantHaveInit = 1 of [1,2,3]) {
|
||||
console.log(cantHaveInit)
|
||||
}
|
||||
for (const cantHaveInit = 1 in [1,2,3]) {
|
||||
console.log(cantHaveInit)
|
||||
}
|
||||
for (let y, x of [1,2,3]) {
|
||||
console.log(x)
|
||||
}
|
||||
for (let y, x in [1,2,3]) {
|
||||
console.log(x)
|
||||
}
|
||||
|
||||
// duplication mistakes
|
||||
var b
|
||||
switch (b) {
|
||||
case false:
|
||||
console.log('no')
|
||||
default:
|
||||
console.log('yes')
|
||||
default:
|
||||
console.log('wat')
|
||||
}
|
||||
try {
|
||||
throw 2
|
||||
}
|
||||
catch (e) {
|
||||
const e = 1
|
||||
console.log(e)
|
||||
}
|
||||
label: for (const x in [1,2,3]) {
|
||||
label: for (const y in [1,2,3]) {
|
||||
break label;
|
||||
}
|
||||
}
|
||||
|
||||
// labels
|
||||
function crossFunctionBoundary() {
|
||||
outer: for(;;) {
|
||||
function test() {
|
||||
break outer
|
||||
}
|
||||
test()
|
||||
}
|
||||
}
|
||||
function continueIterationOnly(x) {
|
||||
outer: switch (x) {
|
||||
case 1:
|
||||
continue outer
|
||||
}
|
||||
}
|
||||
function jumpToLabelOnly(x) {
|
||||
break jumpToLabelOnly
|
||||
}
|
||||
for (;;) {
|
||||
break toplevel
|
||||
continue toplevel
|
||||
}
|
||||
break
|
||||
continue
|
||||
|
||||
// other weirdness
|
||||
export let noMeta = import.metal
|
||||
function foo() { new.targe }
|
||||
const nullaryDynamicImport = import()
|
||||
const trinaryDynamicImport = import('1', '2', '3')
|
||||
const spreadDynamicImport = import(...[])
|
||||
Reference in New Issue
Block a user