Skip to content

Commit

Permalink
🔧 Tests improved for TS lexer with recursive JSX
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrare committed Sep 21, 2024
1 parent 472695a commit 48d86ce
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lexers/testdata/typescript.actual
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@ declare module "../../compiler/types" {}

type TestType<T> = {
[Key keyof T]: Required<Pick<T, Key>>
}
}

const TestComponent = ({ a, b }) => (
<Component width={100} prop={{ a, ...b }} attr="text">
<span>This is a component</span>
<SomethingElse />
</Component>
)

export { TestComponent }
78 changes: 78 additions & 0 deletions lexers/testdata/typescript.expected
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,83 @@
{"type":"NameAttribute","value":"Key"},
{"type":"Punctuation","value":"\u003e\u003e"},
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"Text","value":"\n\n"},
{"type":"KeywordReserved","value":"const"},
{"type":"Text","value":" "},
{"type":"NameOther","value":"TestComponent"},
{"type":"Text","value":" "},
{"type":"Operator","value":"="},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"({"},
{"type":"Text","value":" "},
{"type":"NameOther","value":"a"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"NameOther","value":"b"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"})"},
{"type":"Text","value":" "},
{"type":"Operator","value":"=\u003e"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"("},
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"Component"},
{"type":"Text","value":" "},
{"type":"NameAttribute","value":"width"},
{"type":"Operator","value":"="},
{"type":"Punctuation","value":"{"},
{"type":"LiteralNumberInteger","value":"100"},
{"type":"Punctuation","value":"}"},
{"type":"Text","value":" "},
{"type":"NameAttribute","value":"prop"},
{"type":"Operator","value":"="},
{"type":"Punctuation","value":"{{"},
{"type":"Text","value":" "},
{"type":"NameOther","value":"a"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"..."},
{"type":"NameOther","value":"b"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"}}"},
{"type":"Text","value":" "},
{"type":"NameAttribute","value":"attr"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"\"text\""},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"span"},
{"type":"Punctuation","value":"\u003e"},
{"type":"NameOther","value":"This"},
{"type":"Text","value":" "},
{"type":"Keyword","value":"is"},
{"type":"Text","value":" "},
{"type":"NameOther","value":"a"},
{"type":"Text","value":" "},
{"type":"NameOther","value":"component"},
{"type":"Punctuation","value":"\u003c/"},
{"type":"NameTag","value":"span"},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"SomethingElse"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"/\u003e"},
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"\u003c/"},
{"type":"NameTag","value":"Component"},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":")"},
{"type":"Text","value":"\n\n"},
{"type":"KeywordReserved","value":"export"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"Text","value":" "},
{"type":"NameOther","value":"TestComponent"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"}"}
]

0 comments on commit 48d86ce

Please sign in to comment.