Skip to content

Commit

Permalink
chore: update code
Browse files Browse the repository at this point in the history
  • Loading branch information
fireairforce committed Nov 7, 2024
1 parent 82297c2 commit 8d3fe9b
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type A = typeof import("a.json",{
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
source: crates/biome_js_parser/tests/spec_test.rs
expression: snapshot
---
## Input

```ts
type A = typeof import("a.json",{
```
## AST
```
JsModule {
bom_token: missing (optional),
interpreter_token: missing (optional),
directives: JsDirectiveList [],
items: JsModuleItemList [
TsTypeAliasDeclaration {
type_token: TYPE_KW@0..5 "type" [] [Whitespace(" ")],
binding_identifier: TsIdentifierBinding {
name_token: IDENT@5..7 "A" [] [Whitespace(" ")],
},
type_parameters: missing (optional),
eq_token: EQ@7..9 "=" [] [Whitespace(" ")],
ty: TsImportType {
typeof_token: TYPEOF_KW@9..16 "typeof" [] [Whitespace(" ")],
import_token: IMPORT_KW@16..22 "import" [] [],
arguments: TsImportTypeArguments {
l_paren_token: L_PAREN@22..23 "(" [] [],
argument: TsStringLiteralType {
literal_token: JS_STRING_LITERAL@23..31 "\"a.json\"" [] [],
},
comma_token: COMMA@31..32 "," [] [],
ts_import_type_assertion_block: TsImportTypeAssertionBlock {
l_curly_token: L_CURLY@32..33 "{" [] [],
type_assertion: missing (required),
r_curly_token: missing (required),
},
r_paren_token: missing (required),
},
qualifier_clause: missing (optional),
type_arguments: missing (optional),
},
semicolon_token: missing (optional),
},
],
eof_token: EOF@33..33 "" [] [],
}
```
## CST
```
0: JS_MODULE@0..33
0: (empty)
1: (empty)
2: JS_DIRECTIVE_LIST@0..0
3: JS_MODULE_ITEM_LIST@0..33
0: TS_TYPE_ALIAS_DECLARATION@0..33
0: TYPE_KW@0..5 "type" [] [Whitespace(" ")]
1: TS_IDENTIFIER_BINDING@5..7
0: IDENT@5..7 "A" [] [Whitespace(" ")]
2: (empty)
3: EQ@7..9 "=" [] [Whitespace(" ")]
4: TS_IMPORT_TYPE@9..33
0: TYPEOF_KW@9..16 "typeof" [] [Whitespace(" ")]
1: IMPORT_KW@16..22 "import" [] []
2: TS_IMPORT_TYPE_ARGUMENTS@22..33
0: L_PAREN@22..23 "(" [] []
1: TS_STRING_LITERAL_TYPE@23..31
0: JS_STRING_LITERAL@23..31 "\"a.json\"" [] []
2: COMMA@31..32 "," [] []
3: TS_IMPORT_TYPE_ASSERTION_BLOCK@32..33
0: L_CURLY@32..33 "{" [] []
1: (empty)
2: (empty)
4: (empty)
3: (empty)
4: (empty)
5: (empty)
4: EOF@33..33 "" [] []
```
## Diagnostics
```
import_type_error2.ts:1:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
× expected `}` but instead the file ends
> 1type A = typeof import("a.json",{
i the file ends here
> 1 │ type A = typeof import("a.json",{
```
11 changes: 4 additions & 7 deletions xtask/codegen/js.ungram
Original file line number Diff line number Diff line change
Expand Up @@ -2144,13 +2144,10 @@ TsImportTypeAssertionBlock =
// a: typeof import("mod", { with: { "resolution-mode": "import" } })
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TsImportTypeArguments =
'('
argument: AnyTsType
(
','
TsImportTypeAssertionBlock
)?
')'
'('
argument: AnyTsType
(',' TsImportTypeAssertionBlock )?
')'

// a: import("./test").T<typeof X>
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit 8d3fe9b

Please sign in to comment.