From 8f577446cbbccebb1a0e01fd468d54aceb46b0bc Mon Sep 17 00:00:00 2001 From: Denis Bezrukov <6227442+denbezrukov@users.noreply.github.com> Date: Wed, 19 Apr 2023 08:58:23 +0300 Subject: [PATCH] feat(rome_js_parser): EcmaScript @decorators #4252 --- crates/rome_js_parser/src/syntax/class.rs | 7 - .../inline/err/import_attribute_err.js | 2 +- .../inline/err/import_attribute_err.rast | 376 +++++++++--------- 3 files changed, 184 insertions(+), 201 deletions(-) diff --git a/crates/rome_js_parser/src/syntax/class.rs b/crates/rome_js_parser/src/syntax/class.rs index ab3527aac96..1bc5626243d 100644 --- a/crates/rome_js_parser/src/syntax/class.rs +++ b/crates/rome_js_parser/src/syntax/class.rs @@ -2479,13 +2479,6 @@ fn parse_decorator(p: &mut JsParser) -> ParsedSyntax { Present(m.complete(p, JS_DECORATOR)) } -// test ts ts_class_decorator -// function test() {} -// @test -// class Test {} -// @test.a?.c @test @test -// class Test2{} - /// Skips over any TypeScript decorator syntax. pub(crate) fn skip_ts_decorators(p: &mut JsParser) { if !p.at(T![@]) { diff --git a/crates/rome_js_parser/test_data/inline/err/import_attribute_err.js b/crates/rome_js_parser/test_data/inline/err/import_attribute_err.js index 7fbec80fc90..d3f26f98235 100644 --- a/crates/rome_js_parser/test_data/inline/err/import_attribute_err.js +++ b/crates/rome_js_parser/test_data/inline/err/import_attribute_err.js @@ -2,7 +2,7 @@ import "foo" with { type, "json" }; import "bar" \u{61}ith { type: "json" }; import { foo } with { type: "json" }; import "lorem" -assert { type: "json" } +with { type: "json" } import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; import "x" with; import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 }; diff --git a/crates/rome_js_parser/test_data/inline/err/import_attribute_err.rast b/crates/rome_js_parser/test_data/inline/err/import_attribute_err.rast index 28317c62d63..9eb1fa06ba3 100644 --- a/crates/rome_js_parser/test_data/inline/err/import_attribute_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/import_attribute_err.rast @@ -110,160 +110,157 @@ JsModule { }, semicolon_token: missing (optional), }, - JsExpressionStatement { - expression: JsIdentifierExpression { - name: JsReferenceIdentifier { - value_token: IDENT@129..137 "assert" [Newline("\n")] [Whitespace(" ")], - }, - }, - semicolon_token: missing (optional), - }, - JsBlockStatement { - l_curly_token: L_CURLY@137..139 "{" [] [Whitespace(" ")], - statements: JsStatementList [ - JsLabeledStatement { - label_token: IDENT@139..143 "type" [] [], - colon_token: COLON@143..145 ":" [] [Whitespace(" ")], - body: JsExpressionStatement { - expression: JsStringLiteralExpression { - value_token: JS_STRING_LITERAL@145..152 "\"json\"" [] [Whitespace(" ")], + JsBogusStatement { + items: [ + WITH_KW@129..135 "with" [Newline("\n")] [Whitespace(" ")], + JsBlockStatement { + l_curly_token: L_CURLY@135..137 "{" [] [Whitespace(" ")], + statements: JsStatementList [ + JsLabeledStatement { + label_token: IDENT@137..141 "type" [] [], + colon_token: COLON@141..143 ":" [] [Whitespace(" ")], + body: JsExpressionStatement { + expression: JsStringLiteralExpression { + value_token: JS_STRING_LITERAL@143..150 "\"json\"" [] [Whitespace(" ")], + }, + semicolon_token: missing (optional), + }, }, - semicolon_token: missing (optional), - }, + ], + r_curly_token: R_CURLY@150..151 "}" [] [], }, ], - r_curly_token: R_CURLY@152..153 "}" [] [], }, JsImport { - import_token: IMPORT_KW@153..161 "import" [Newline("\n")] [Whitespace(" ")], + import_token: IMPORT_KW@151..159 "import" [Newline("\n")] [Whitespace(" ")], import_clause: JsImportDefaultClause { type_token: missing (optional), local_name: JsIdentifierBinding { - name_token: IDENT@161..166 "foo2" [] [Whitespace(" ")], + name_token: IDENT@159..164 "foo2" [] [Whitespace(" ")], }, - from_token: FROM_KW@166..171 "from" [] [Whitespace(" ")], + from_token: FROM_KW@164..169 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@171..182 "\"foo.json\"" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@169..180 "\"foo.json\"" [] [Whitespace(" ")], }, attribute: JsImportAttribute { - with_token: WITH_KW@182..187 "with" [] [Whitespace(" ")], - l_curly_token: L_CURLY@187..189 "{" [] [Whitespace(" ")], + with_token: WITH_KW@180..185 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@185..187 "{" [] [Whitespace(" ")], attributes: JsImportAttributeEntryList [ JsImportAttributeEntry { - key: JS_STRING_LITERAL@189..195 "\"type\"" [] [], - colon_token: COLON@195..197 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@197..203 "\"json\"" [] [], + key: JS_STRING_LITERAL@187..193 "\"type\"" [] [], + colon_token: COLON@193..195 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@195..201 "\"json\"" [] [], }, - COMMA@203..205 "," [] [Whitespace(" ")], + COMMA@201..203 "," [] [Whitespace(" ")], JsBogusImportAttributeEntry { items: [ - IDENT@205..209 "type" [] [], - COLON@209..211 ":" [] [Whitespace(" ")], - JS_STRING_LITERAL@211..217 "\"html\"" [] [], + IDENT@203..207 "type" [] [], + COLON@207..209 ":" [] [Whitespace(" ")], + JS_STRING_LITERAL@209..215 "\"html\"" [] [], ], }, - COMMA@217..219 "," [] [Whitespace(" ")], + COMMA@215..217 "," [] [Whitespace(" ")], JsBogusImportAttributeEntry { items: [ - JS_STRING_LITERAL@219..225 "\"type\"" [] [], - COLON@225..227 ":" [] [Whitespace(" ")], - JS_STRING_LITERAL@227..232 "\"js\"" [] [Whitespace(" ")], + JS_STRING_LITERAL@217..223 "\"type\"" [] [], + COLON@223..225 ":" [] [Whitespace(" ")], + JS_STRING_LITERAL@225..230 "\"js\"" [] [Whitespace(" ")], ], }, ], - r_curly_token: R_CURLY@232..233 "}" [] [], + r_curly_token: R_CURLY@230..231 "}" [] [], }, }, - semicolon_token: SEMICOLON@233..234 ";" [] [], + semicolon_token: SEMICOLON@231..232 ";" [] [], }, JsImport { - import_token: IMPORT_KW@234..242 "import" [Newline("\n")] [Whitespace(" ")], + import_token: IMPORT_KW@232..240 "import" [Newline("\n")] [Whitespace(" ")], import_clause: JsImportBareClause { source: JsModuleSource { - value_token: JS_STRING_LITERAL@242..246 "\"x\"" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@240..244 "\"x\"" [] [Whitespace(" ")], }, attribute: JsImportAttribute { - with_token: WITH_KW@246..250 "with" [] [], + with_token: WITH_KW@244..248 "with" [] [], l_curly_token: missing (required), attributes: JsImportAttributeEntryList [], r_curly_token: missing (required), }, }, - semicolon_token: SEMICOLON@250..251 ";" [] [], + semicolon_token: SEMICOLON@248..249 ";" [] [], }, JsImport { - import_token: IMPORT_KW@251..259 "import" [Newline("\n")] [Whitespace(" ")], + import_token: IMPORT_KW@249..257 "import" [Newline("\n")] [Whitespace(" ")], import_clause: JsImportDefaultClause { type_token: missing (optional), local_name: JsIdentifierBinding { - name_token: IDENT@259..265 "ipsum" [] [Whitespace(" ")], + name_token: IDENT@257..263 "ipsum" [] [Whitespace(" ")], }, - from_token: FROM_KW@265..270 "from" [] [Whitespace(" ")], + from_token: FROM_KW@263..268 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@270..283 "\"ipsum.json\"" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@268..281 "\"ipsum.json\"" [] [Whitespace(" ")], }, attribute: JsImportAttribute { - with_token: WITH_KW@283..288 "with" [] [Whitespace(" ")], - l_curly_token: L_CURLY@288..290 "{" [] [Whitespace(" ")], + with_token: WITH_KW@281..286 "with" [] [Whitespace(" ")], + l_curly_token: L_CURLY@286..288 "{" [] [Whitespace(" ")], attributes: JsImportAttributeEntryList [ JsImportAttributeEntry { - key: IDENT@290..294 "type" [] [], - colon_token: COLON@294..296 ":" [] [Whitespace(" ")], - value_token: JS_STRING_LITERAL@296..302 "\"json\"" [] [], + key: IDENT@288..292 "type" [] [], + colon_token: COLON@292..294 ":" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@294..300 "\"json\"" [] [], }, - COMMA@302..304 "," [] [Whitespace(" ")], + COMMA@300..302 "," [] [Whitespace(" ")], JsImportAttributeEntry { - key: IDENT@304..308 "lazy" [] [], - colon_token: COLON@308..310 ":" [] [Whitespace(" ")], + key: IDENT@302..306 "lazy" [] [], + colon_token: COLON@306..308 ":" [] [Whitespace(" ")], value_token: missing (required), }, missing separator, JsImportAttributeEntry { - key: IDENT@310..314 "true" [] [], + key: IDENT@308..312 "true" [] [], colon_token: missing (required), value_token: missing (required), }, - COMMA@314..316 "," [] [Whitespace(" ")], + COMMA@312..314 "," [] [Whitespace(" ")], JsImportAttributeEntry { - key: IDENT@316..327 "startAtLine" [] [], - colon_token: COLON@327..329 ":" [] [Whitespace(" ")], + key: IDENT@314..325 "startAtLine" [] [], + colon_token: COLON@325..327 ":" [] [Whitespace(" ")], value_token: missing (required), }, missing separator, JsBogusImportAttributeEntry { items: [ - JS_NUMBER_LITERAL@329..331 "1" [] [Whitespace(" ")], + JS_NUMBER_LITERAL@327..329 "1" [] [Whitespace(" ")], ], }, ], - r_curly_token: R_CURLY@331..332 "}" [] [], + r_curly_token: R_CURLY@329..330 "}" [] [], }, }, - semicolon_token: SEMICOLON@332..333 ";" [] [], + semicolon_token: SEMICOLON@330..331 ";" [] [], }, JsImport { - import_token: IMPORT_KW@333..341 "import" [Newline("\n")] [Whitespace(" ")], + import_token: IMPORT_KW@331..339 "import" [Newline("\n")] [Whitespace(" ")], import_clause: JsImportNamedClause { type_token: missing (optional), default_specifier: missing (optional), named_import: JsNamedImportSpecifiers { - l_curly_token: L_CURLY@341..343 "{" [] [Whitespace(" ")], + l_curly_token: L_CURLY@339..341 "{" [] [Whitespace(" ")], specifiers: JsNamedImportSpecifierList [ JsShorthandNamedImportSpecifier { type_token: missing (optional), local_name: JsIdentifierBinding { - name_token: IDENT@343..345 "a" [] [Whitespace(" ")], + name_token: IDENT@341..343 "a" [] [Whitespace(" ")], }, }, ], - r_curly_token: R_CURLY@345..347 "}" [] [Whitespace(" ")], + r_curly_token: R_CURLY@343..345 "}" [] [Whitespace(" ")], }, - from_token: FROM_KW@347..352 "from" [] [Whitespace(" ")], + from_token: FROM_KW@345..350 "from" [] [Whitespace(" ")], source: JsModuleSource { - value_token: JS_STRING_LITERAL@352..361 "\"a.json\"" [] [Whitespace(" ")], + value_token: JS_STRING_LITERAL@350..359 "\"a.json\"" [] [Whitespace(" ")], }, attribute: JsImportAttribute { - with_token: WITH_KW@361..365 "with" [] [], + with_token: WITH_KW@359..363 "with" [] [], l_curly_token: missing (required), attributes: JsImportAttributeEntryList [], r_curly_token: missing (required), @@ -272,13 +269,13 @@ JsModule { semicolon_token: missing (optional), }, ], - eof_token: EOF@365..366 "" [Newline("\n")] [], + eof_token: EOF@363..364 "" [Newline("\n")] [], } -0: JS_MODULE@0..366 +0: JS_MODULE@0..364 0: (empty) 1: JS_DIRECTIVE_LIST@0..0 - 2: JS_MODULE_ITEM_LIST@0..365 + 2: JS_MODULE_ITEM_LIST@0..363 0: JS_IMPORT@0..35 0: IMPORT_KW@0..7 "import" [] [Whitespace(" ")] 1: JS_IMPORT_BARE_CLAUSE@7..34 @@ -356,122 +353,119 @@ JsModule { 0: JS_STRING_LITERAL@122..129 "\"lorem\"" [] [] 1: (empty) 2: (empty) - 7: JS_EXPRESSION_STATEMENT@129..137 - 0: JS_IDENTIFIER_EXPRESSION@129..137 - 0: JS_REFERENCE_IDENTIFIER@129..137 - 0: IDENT@129..137 "assert" [Newline("\n")] [Whitespace(" ")] - 1: (empty) - 8: JS_BLOCK_STATEMENT@137..153 - 0: L_CURLY@137..139 "{" [] [Whitespace(" ")] - 1: JS_STATEMENT_LIST@139..152 - 0: JS_LABELED_STATEMENT@139..152 - 0: IDENT@139..143 "type" [] [] - 1: COLON@143..145 ":" [] [Whitespace(" ")] - 2: JS_EXPRESSION_STATEMENT@145..152 - 0: JS_STRING_LITERAL_EXPRESSION@145..152 - 0: JS_STRING_LITERAL@145..152 "\"json\"" [] [Whitespace(" ")] - 1: (empty) - 2: R_CURLY@152..153 "}" [] [] - 9: JS_IMPORT@153..234 - 0: IMPORT_KW@153..161 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_DEFAULT_CLAUSE@161..233 + 7: JS_BOGUS_STATEMENT@129..151 + 0: WITH_KW@129..135 "with" [Newline("\n")] [Whitespace(" ")] + 1: JS_BLOCK_STATEMENT@135..151 + 0: L_CURLY@135..137 "{" [] [Whitespace(" ")] + 1: JS_STATEMENT_LIST@137..150 + 0: JS_LABELED_STATEMENT@137..150 + 0: IDENT@137..141 "type" [] [] + 1: COLON@141..143 ":" [] [Whitespace(" ")] + 2: JS_EXPRESSION_STATEMENT@143..150 + 0: JS_STRING_LITERAL_EXPRESSION@143..150 + 0: JS_STRING_LITERAL@143..150 "\"json\"" [] [Whitespace(" ")] + 1: (empty) + 2: R_CURLY@150..151 "}" [] [] + 8: JS_IMPORT@151..232 + 0: IMPORT_KW@151..159 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_DEFAULT_CLAUSE@159..231 0: (empty) - 1: JS_IDENTIFIER_BINDING@161..166 - 0: IDENT@161..166 "foo2" [] [Whitespace(" ")] - 2: FROM_KW@166..171 "from" [] [Whitespace(" ")] - 3: JS_MODULE_SOURCE@171..182 - 0: JS_STRING_LITERAL@171..182 "\"foo.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ATTRIBUTE@182..233 - 0: WITH_KW@182..187 "with" [] [Whitespace(" ")] - 1: L_CURLY@187..189 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@189..232 - 0: JS_IMPORT_ATTRIBUTE_ENTRY@189..203 - 0: JS_STRING_LITERAL@189..195 "\"type\"" [] [] - 1: COLON@195..197 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@197..203 "\"json\"" [] [] - 1: COMMA@203..205 "," [] [Whitespace(" ")] - 2: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@205..217 - 0: IDENT@205..209 "type" [] [] - 1: COLON@209..211 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@211..217 "\"html\"" [] [] - 3: COMMA@217..219 "," [] [Whitespace(" ")] - 4: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@219..232 - 0: JS_STRING_LITERAL@219..225 "\"type\"" [] [] - 1: COLON@225..227 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@227..232 "\"js\"" [] [Whitespace(" ")] - 3: R_CURLY@232..233 "}" [] [] - 2: SEMICOLON@233..234 ";" [] [] - 10: JS_IMPORT@234..251 - 0: IMPORT_KW@234..242 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_BARE_CLAUSE@242..250 - 0: JS_MODULE_SOURCE@242..246 - 0: JS_STRING_LITERAL@242..246 "\"x\"" [] [Whitespace(" ")] - 1: JS_IMPORT_ATTRIBUTE@246..250 - 0: WITH_KW@246..250 "with" [] [] + 1: JS_IDENTIFIER_BINDING@159..164 + 0: IDENT@159..164 "foo2" [] [Whitespace(" ")] + 2: FROM_KW@164..169 "from" [] [Whitespace(" ")] + 3: JS_MODULE_SOURCE@169..180 + 0: JS_STRING_LITERAL@169..180 "\"foo.json\"" [] [Whitespace(" ")] + 4: JS_IMPORT_ATTRIBUTE@180..231 + 0: WITH_KW@180..185 "with" [] [Whitespace(" ")] + 1: L_CURLY@185..187 "{" [] [Whitespace(" ")] + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@187..230 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@187..201 + 0: JS_STRING_LITERAL@187..193 "\"type\"" [] [] + 1: COLON@193..195 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@195..201 "\"json\"" [] [] + 1: COMMA@201..203 "," [] [Whitespace(" ")] + 2: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@203..215 + 0: IDENT@203..207 "type" [] [] + 1: COLON@207..209 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@209..215 "\"html\"" [] [] + 3: COMMA@215..217 "," [] [Whitespace(" ")] + 4: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@217..230 + 0: JS_STRING_LITERAL@217..223 "\"type\"" [] [] + 1: COLON@223..225 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@225..230 "\"js\"" [] [Whitespace(" ")] + 3: R_CURLY@230..231 "}" [] [] + 2: SEMICOLON@231..232 ";" [] [] + 9: JS_IMPORT@232..249 + 0: IMPORT_KW@232..240 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_BARE_CLAUSE@240..248 + 0: JS_MODULE_SOURCE@240..244 + 0: JS_STRING_LITERAL@240..244 "\"x\"" [] [Whitespace(" ")] + 1: JS_IMPORT_ATTRIBUTE@244..248 + 0: WITH_KW@244..248 "with" [] [] 1: (empty) - 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@250..250 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@248..248 3: (empty) - 2: SEMICOLON@250..251 ";" [] [] - 11: JS_IMPORT@251..333 - 0: IMPORT_KW@251..259 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_DEFAULT_CLAUSE@259..332 + 2: SEMICOLON@248..249 ";" [] [] + 10: JS_IMPORT@249..331 + 0: IMPORT_KW@249..257 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_DEFAULT_CLAUSE@257..330 0: (empty) - 1: JS_IDENTIFIER_BINDING@259..265 - 0: IDENT@259..265 "ipsum" [] [Whitespace(" ")] - 2: FROM_KW@265..270 "from" [] [Whitespace(" ")] - 3: JS_MODULE_SOURCE@270..283 - 0: JS_STRING_LITERAL@270..283 "\"ipsum.json\"" [] [Whitespace(" ")] - 4: JS_IMPORT_ATTRIBUTE@283..332 - 0: WITH_KW@283..288 "with" [] [Whitespace(" ")] - 1: L_CURLY@288..290 "{" [] [Whitespace(" ")] - 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@290..331 - 0: JS_IMPORT_ATTRIBUTE_ENTRY@290..302 - 0: IDENT@290..294 "type" [] [] - 1: COLON@294..296 ":" [] [Whitespace(" ")] - 2: JS_STRING_LITERAL@296..302 "\"json\"" [] [] - 1: COMMA@302..304 "," [] [Whitespace(" ")] - 2: JS_IMPORT_ATTRIBUTE_ENTRY@304..310 - 0: IDENT@304..308 "lazy" [] [] - 1: COLON@308..310 ":" [] [Whitespace(" ")] + 1: JS_IDENTIFIER_BINDING@257..263 + 0: IDENT@257..263 "ipsum" [] [Whitespace(" ")] + 2: FROM_KW@263..268 "from" [] [Whitespace(" ")] + 3: JS_MODULE_SOURCE@268..281 + 0: JS_STRING_LITERAL@268..281 "\"ipsum.json\"" [] [Whitespace(" ")] + 4: JS_IMPORT_ATTRIBUTE@281..330 + 0: WITH_KW@281..286 "with" [] [Whitespace(" ")] + 1: L_CURLY@286..288 "{" [] [Whitespace(" ")] + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@288..329 + 0: JS_IMPORT_ATTRIBUTE_ENTRY@288..300 + 0: IDENT@288..292 "type" [] [] + 1: COLON@292..294 ":" [] [Whitespace(" ")] + 2: JS_STRING_LITERAL@294..300 "\"json\"" [] [] + 1: COMMA@300..302 "," [] [Whitespace(" ")] + 2: JS_IMPORT_ATTRIBUTE_ENTRY@302..308 + 0: IDENT@302..306 "lazy" [] [] + 1: COLON@306..308 ":" [] [Whitespace(" ")] 2: (empty) 3: (empty) - 4: JS_IMPORT_ATTRIBUTE_ENTRY@310..314 - 0: IDENT@310..314 "true" [] [] + 4: JS_IMPORT_ATTRIBUTE_ENTRY@308..312 + 0: IDENT@308..312 "true" [] [] 1: (empty) 2: (empty) - 5: COMMA@314..316 "," [] [Whitespace(" ")] - 6: JS_IMPORT_ATTRIBUTE_ENTRY@316..329 - 0: IDENT@316..327 "startAtLine" [] [] - 1: COLON@327..329 ":" [] [Whitespace(" ")] + 5: COMMA@312..314 "," [] [Whitespace(" ")] + 6: JS_IMPORT_ATTRIBUTE_ENTRY@314..327 + 0: IDENT@314..325 "startAtLine" [] [] + 1: COLON@325..327 ":" [] [Whitespace(" ")] 2: (empty) 7: (empty) - 8: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@329..331 - 0: JS_NUMBER_LITERAL@329..331 "1" [] [Whitespace(" ")] - 3: R_CURLY@331..332 "}" [] [] - 2: SEMICOLON@332..333 ";" [] [] - 12: JS_IMPORT@333..365 - 0: IMPORT_KW@333..341 "import" [Newline("\n")] [Whitespace(" ")] - 1: JS_IMPORT_NAMED_CLAUSE@341..365 + 8: JS_BOGUS_IMPORT_ATTRIBUTE_ENTRY@327..329 + 0: JS_NUMBER_LITERAL@327..329 "1" [] [Whitespace(" ")] + 3: R_CURLY@329..330 "}" [] [] + 2: SEMICOLON@330..331 ";" [] [] + 11: JS_IMPORT@331..363 + 0: IMPORT_KW@331..339 "import" [Newline("\n")] [Whitespace(" ")] + 1: JS_IMPORT_NAMED_CLAUSE@339..363 0: (empty) 1: (empty) - 2: JS_NAMED_IMPORT_SPECIFIERS@341..347 - 0: L_CURLY@341..343 "{" [] [Whitespace(" ")] - 1: JS_NAMED_IMPORT_SPECIFIER_LIST@343..345 - 0: JS_SHORTHAND_NAMED_IMPORT_SPECIFIER@343..345 + 2: JS_NAMED_IMPORT_SPECIFIERS@339..345 + 0: L_CURLY@339..341 "{" [] [Whitespace(" ")] + 1: JS_NAMED_IMPORT_SPECIFIER_LIST@341..343 + 0: JS_SHORTHAND_NAMED_IMPORT_SPECIFIER@341..343 0: (empty) - 1: JS_IDENTIFIER_BINDING@343..345 - 0: IDENT@343..345 "a" [] [Whitespace(" ")] - 2: R_CURLY@345..347 "}" [] [Whitespace(" ")] - 3: FROM_KW@347..352 "from" [] [Whitespace(" ")] - 4: JS_MODULE_SOURCE@352..361 - 0: JS_STRING_LITERAL@352..361 "\"a.json\"" [] [Whitespace(" ")] - 5: JS_IMPORT_ATTRIBUTE@361..365 - 0: WITH_KW@361..365 "with" [] [] + 1: JS_IDENTIFIER_BINDING@341..343 + 0: IDENT@341..343 "a" [] [Whitespace(" ")] + 2: R_CURLY@343..345 "}" [] [Whitespace(" ")] + 3: FROM_KW@345..350 "from" [] [Whitespace(" ")] + 4: JS_MODULE_SOURCE@350..359 + 0: JS_STRING_LITERAL@350..359 "\"a.json\"" [] [Whitespace(" ")] + 5: JS_IMPORT_ATTRIBUTE@359..363 + 0: WITH_KW@359..363 "with" [] [] 1: (empty) - 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@365..365 + 2: JS_IMPORT_ATTRIBUTE_ENTRY_LIST@363..363 3: (empty) 2: (empty) - 3: EOF@365..366 "" [Newline("\n")] [] + 3: EOF@363..364 "" [Newline("\n")] [] -- import_attribute_err.js:1:25 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -560,37 +554,33 @@ import_attribute_err.js:3:16 parse ━━━━━━━━━━━━━━━ > 3 │ import { foo } with { type: "json" }; │ ^^^^ 4 │ import "lorem" - 5 │ assert { type: "json" } + 5 │ with { type: "json" } i Remove with -- -import_attribute_err.js:5:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +import_attribute_err.js:5:6 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × Expected a semicolon or an implicit semicolon after a statement, but found none + × expected `(` but instead found `{` 3 │ import { foo } with { type: "json" }; 4 │ import "lorem" - > 5 │ assert { type: "json" } - │ ^ + > 5 │ with { type: "json" } + │ ^ 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; 7 │ import "x" with; - i An explicit or implicit semicolon is expected here... - - 3 │ import { foo } with { type: "json" }; - 4 │ import "lorem" - > 5 │ assert { type: "json" } - │ ^ - 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; - 7 │ import "x" with; + i Remove { - i ...Which is required to end this statement +-- +import_attribute_err.js:5:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × `with` statements are not allowed in strict mode 3 │ import { foo } with { type: "json" }; 4 │ import "lorem" - > 5 │ assert { type: "json" } - │ ^^^^^^^^ + > 5 │ with { type: "json" } + │ ^^^^^^^^^^^^^^^^^^^^^ 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; 7 │ import "x" with; @@ -600,7 +590,7 @@ import_attribute_err.js:6:36 parse ━━━━━━━━━━━━━━━ × Duplicate assertion keys are not allowed 4 │ import "lorem" - 5 │ assert { type: "json" } + 5 │ with { type: "json" } > 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; │ ^^^^^^ 7 │ import "x" with; @@ -609,7 +599,7 @@ import_attribute_err.js:6:36 parse ━━━━━━━━━━━━━━━ i First use of the key `type` 4 │ import "lorem" - 5 │ assert { type: "json" } + 5 │ with { type: "json" } > 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; │ ^^^^^^ 7 │ import "x" with; @@ -618,7 +608,7 @@ import_attribute_err.js:6:36 parse ━━━━━━━━━━━━━━━ i second use here 4 │ import "lorem" - 5 │ assert { type: "json" } + 5 │ with { type: "json" } > 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; │ ^^^^ 7 │ import "x" with; @@ -629,7 +619,7 @@ import_attribute_err.js:7:16 parse ━━━━━━━━━━━━━━━ × expected `{` but instead found `;` - 5 │ assert { type: "json" } + 5 │ with { type: "json" } 6 │ import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; > 7 │ import "x" with; │ ^ @@ -702,7 +692,7 @@ import "foo" with { type, "json" }; import "bar" \u{61}ith { type: "json" }; import { foo } with { type: "json" }; import "lorem" -assert { type: "json" } +with { type: "json" } import foo2 from "foo.json" with { "type": "json", type: "html", "type": "js" }; import "x" with; import ipsum from "ipsum.json" with { type: "json", lazy: true, startAtLine: 1 };