-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #415 from eyakubovich/ey/support-tsx-jsx-element
Support JSX elements in TSX
- Loading branch information
Showing
7 changed files
with
311 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
languages/tree-sitter-stack-graphs-typescript/test/jsx/jsx_core.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// The core of JSX tests here verify the behavior of the following node types: | ||
// jsx_element | ||
// jsx_identifier | ||
// jsx_attribute | ||
// jsx_expression | ||
// jsx_opening_element | ||
// jsx_closing_element | ||
// There is no real way to avoid testing all of these at once, | ||
// and so we don't even try to. | ||
|
||
let x = 1; | ||
|
||
// Flow In | ||
|
||
const el = <foo bar={x}>{x}</foo>; | ||
// ^ defined: 11 | ||
// ^ defined: 11 | ||
|
||
const el2 = <x></x> | ||
// ^ defined: 11 | ||
// ^ defined: 11 | ||
|
||
let y = 0; | ||
let z = 2; | ||
|
||
const el = <foo bar={y = 1}> | ||
// ^ defined: 23 | ||
{z = 3} | ||
// ^ defined: 24 | ||
</foo>; | ||
|
||
/**/ y; | ||
// ^ defined: 23 | ||
|
||
/**/ z; | ||
// ^ defined: 24 | ||
|
||
/**/ x; | ||
// ^ defined: 11 |
12 changes: 12 additions & 0 deletions
12
languages/tree-sitter-stack-graphs-typescript/test/jsx/jsx_fragment.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
let x = 1; | ||
|
||
// Flow Around | ||
|
||
const el = <></>; | ||
|
||
/**/ x; | ||
// ^ defined: 1 | ||
|
||
// Children | ||
(<foo><bar>{x}</bar></foo>); | ||
// ^ defined: 1 |
30 changes: 30 additions & 0 deletions
30
languages/tree-sitter-stack-graphs-typescript/test/jsx/jsx_namespace_name.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
let x = 1; | ||
|
||
// Flow Around | ||
namespace noo.bar { | ||
export let baz = 1; | ||
} | ||
|
||
const el = <noo.bar.baz></noo.bar.baz>; | ||
// ^ defined: 4 | ||
// ^ defined: 4 | ||
// ^ defined: 5 | ||
// ^ defined: 4 | ||
// ^ defined: 4 | ||
// ^ defined: 5 | ||
|
||
/**/ x; | ||
// ^ defined: 1 | ||
|
||
// Flow In | ||
|
||
let foo = { | ||
bar: { | ||
baz: 1 | ||
} | ||
}; | ||
|
||
const el2 = <foo.bar.baz />; | ||
// ^ defined: 21 | ||
// ^ defined: 22 | ||
// ^ defined: 23 |
37 changes: 37 additions & 0 deletions
37
languages/tree-sitter-stack-graphs-typescript/test/jsx/jsx_self_closing_element.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// The core of JSX tests here verify the behavior of the following node types: | ||
// jsx_element | ||
// jsx_identifier | ||
// jsx_attribute | ||
// jsx_expression | ||
// jsx_opening_element | ||
// jsx_closing_element | ||
// There is no real way to avoid testing all of these at once, | ||
// and so we don't even try to. | ||
|
||
let x = 1; | ||
|
||
// Flow In | ||
|
||
const el = <foo bar={x} />; | ||
// ^ defined: 11 | ||
|
||
const el2 = <x /> | ||
// ^ defined: 11 | ||
|
||
// Flow Out | ||
|
||
let y = 2; | ||
|
||
const el = <foo bar={y = 1} />; | ||
// ^ defined: 23 | ||
|
||
// Flow Across | ||
|
||
const el = <foo bar={y = 1} | ||
baz={y} />; | ||
// ^ defined: 23 | ||
|
||
// Flow Around | ||
|
||
/**/ x; | ||
// ^ defined: 11 |
8 changes: 8 additions & 0 deletions
8
languages/tree-sitter-stack-graphs-typescript/test/jsx/jsx_text.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
let x = 1; | ||
|
||
// Flow Around | ||
|
||
const el = <foo>bar</foo>; | ||
|
||
/**/ x; | ||
// ^ defined: 1 |