Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
fix: 🐛 cr issues
Browse files Browse the repository at this point in the history
  • Loading branch information
IWANABETHATGUY committed Sep 10, 2022
1 parent d2d9e60 commit 91de3db
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/rome_js_parser/src/syntax/typescript/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,10 @@ pub(crate) fn parse_ts_name(p: &mut Parser) -> ParsedSyntax {
// type B = typeof a;
// type T21 = typeof Array<string>;
// type A<U> = InstanceType<typeof Array<U>>;

// test tsx ts_typeof_type2
// type X = typeof Array
// <div>a</div>;
fn parse_ts_typeof_type(p: &mut Parser) -> ParsedSyntax {
if !p.at(T![typeof]) {
return Absent;
Expand Down
90 changes: 90 additions & 0 deletions crates/rome_js_parser/test_data/inline/ok/ts_typeof_type2.rast
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
JsModule {
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 "X" [] [Whitespace(" ")],
},
type_parameters: missing (optional),
eq_token: EQ@7..9 "=" [] [Whitespace(" ")],
ty: TsTypeofType {
typeof_token: TYPEOF_KW@9..16 "typeof" [] [Whitespace(" ")],
expression_name: JsReferenceIdentifier {
value_token: IDENT@16..21 "Array" [] [],
},
type_arguments: missing (optional),
},
semicolon_token: missing (optional),
},
JsExpressionStatement {
expression: JsxTagExpression {
tag: JsxElement {
opening_element: JsxOpeningElement {
l_angle_token: L_ANGLE@21..23 "<" [Newline("\n")] [],
name: JsxName {
value_token: JSX_IDENT@23..26 "div" [] [],
},
type_arguments: missing (optional),
attributes: JsxAttributeList [],
r_angle_token: R_ANGLE@26..27 ">" [] [],
},
children: JsxChildList [
JsxText {
value_token: JSX_TEXT_LITERAL@27..28 "a" [] [],
},
],
closing_element: JsxClosingElement {
l_angle_token: L_ANGLE@28..29 "<" [] [],
slash_token: SLASH@29..30 "/" [] [],
name: JsxName {
value_token: JSX_IDENT@30..33 "div" [] [],
},
r_angle_token: R_ANGLE@33..34 ">" [] [],
},
},
},
semicolon_token: SEMICOLON@34..35 ";" [] [],
},
],
eof_token: EOF@35..36 "" [Newline("\n")] [],
}

0: JS_MODULE@0..36
0: (empty)
1: JS_DIRECTIVE_LIST@0..0
2: JS_MODULE_ITEM_LIST@0..35
0: TS_TYPE_ALIAS_DECLARATION@0..21
0: TYPE_KW@0..5 "type" [] [Whitespace(" ")]
1: TS_IDENTIFIER_BINDING@5..7
0: IDENT@5..7 "X" [] [Whitespace(" ")]
2: (empty)
3: EQ@7..9 "=" [] [Whitespace(" ")]
4: TS_TYPEOF_TYPE@9..21
0: TYPEOF_KW@9..16 "typeof" [] [Whitespace(" ")]
1: JS_REFERENCE_IDENTIFIER@16..21
0: IDENT@16..21 "Array" [] []
2: (empty)
5: (empty)
1: JS_EXPRESSION_STATEMENT@21..35
0: JSX_TAG_EXPRESSION@21..34
0: JSX_ELEMENT@21..34
0: JSX_OPENING_ELEMENT@21..27
0: L_ANGLE@21..23 "<" [Newline("\n")] []
1: JSX_NAME@23..26
0: JSX_IDENT@23..26 "div" [] []
2: (empty)
3: JSX_ATTRIBUTE_LIST@26..26
4: R_ANGLE@26..27 ">" [] []
1: JSX_CHILD_LIST@27..28
0: JSX_TEXT@27..28
0: JSX_TEXT_LITERAL@27..28 "a" [] []
2: JSX_CLOSING_ELEMENT@28..34
0: L_ANGLE@28..29 "<" [] []
1: SLASH@29..30 "/" [] []
2: JSX_NAME@30..33
0: JSX_IDENT@30..33 "div" [] []
3: R_ANGLE@33..34 ">" [] []
1: SEMICOLON@34..35 ";" [] []
3: EOF@35..36 "" [Newline("\n")] []
2 changes: 2 additions & 0 deletions crates/rome_js_parser/test_data/inline/ok/ts_typeof_type2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type X = typeof Array
<div>a</div>;

0 comments on commit 91de3db

Please sign in to comment.