Skip to content

Commit a88c2ae

Browse files
committed
Add test cases for when jsxFactory cannot be resolved
1 parent c6b1bbe commit a88c2ae

16 files changed

+474
-0
lines changed

tests/baselines/reference/jsxFactoryIdentifierAsParameter.js

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/jsxFactoryIdentifierAsParameter.js.map

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
===================================================================
2+
JsFile: test.js
3+
mapUrl: test.js.map
4+
sourceRoot:
5+
sources: test.tsx
6+
===================================================================
7+
-------------------------------------------------------------------
8+
emittedFile:tests/cases/compiler/test.js
9+
sourceFile:test.tsx
10+
-------------------------------------------------------------------
11+
>>>"use strict";
12+
>>>class AppComponent {
13+
1 >
14+
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
15+
1 >
16+
>declare module JSX {
17+
> interface IntrinsicElements {
18+
> [s: string]: any;
19+
> }
20+
>}
21+
>
22+
>
23+
1 >Emitted(2, 1) Source(8, 1) + SourceIndex(0)
24+
---
25+
>>> render(createElement) {
26+
1->^^^^
27+
2 > ^^^^^^
28+
3 > ^
29+
4 > ^^^^^^^^^^^^^
30+
5 > ^^^^^^^^^^^^^^^^^^^->
31+
1->export class AppComponent {
32+
>
33+
2 > render
34+
3 > (
35+
4 > createElement
36+
1->Emitted(3, 5) Source(9, 5) + SourceIndex(0)
37+
2 >Emitted(3, 11) Source(9, 11) + SourceIndex(0)
38+
3 >Emitted(3, 12) Source(9, 12) + SourceIndex(0)
39+
4 >Emitted(3, 25) Source(9, 25) + SourceIndex(0)
40+
---
41+
>>> return createElement("div", null);
42+
1->^^^^^^^^
43+
2 > ^^^^^^
44+
3 > ^
45+
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
5 > ^
47+
1->) {
48+
>
49+
2 > return
50+
3 >
51+
4 > <div />
52+
5 > ;
53+
1->Emitted(4, 9) Source(10, 9) + SourceIndex(0)
54+
2 >Emitted(4, 15) Source(10, 15) + SourceIndex(0)
55+
3 >Emitted(4, 16) Source(10, 16) + SourceIndex(0)
56+
4 >Emitted(4, 42) Source(10, 23) + SourceIndex(0)
57+
5 >Emitted(4, 43) Source(10, 24) + SourceIndex(0)
58+
---
59+
>>> }
60+
1 >^^^^
61+
2 > ^
62+
1 >
63+
>
64+
2 > }
65+
1 >Emitted(5, 5) Source(11, 5) + SourceIndex(0)
66+
2 >Emitted(5, 6) Source(11, 6) + SourceIndex(0)
67+
---
68+
>>>}
69+
1 >^
70+
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
71+
1 >
72+
>}
73+
1 >Emitted(6, 2) Source(12, 2) + SourceIndex(0)
74+
---
75+
>>>exports.AppComponent = AppComponent;
76+
1->
77+
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
78+
1->
79+
2 >export class AppComponent {
80+
> render(createElement) {
81+
> return <div />;
82+
> }
83+
>}
84+
1->Emitted(7, 1) Source(8, 1) + SourceIndex(0)
85+
2 >Emitted(7, 37) Source(12, 2) + SourceIndex(0)
86+
---
87+
>>>//# sourceMappingURL=test.js.map
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=== tests/cases/compiler/test.tsx ===
2+
3+
declare module JSX {
4+
>JSX : Symbol(JSX, Decl(test.tsx, 0, 0))
5+
6+
interface IntrinsicElements {
7+
>IntrinsicElements : Symbol(IntrinsicElements, Decl(test.tsx, 1, 20))
8+
9+
[s: string]: any;
10+
>s : Symbol(s, Decl(test.tsx, 3, 9))
11+
}
12+
}
13+
14+
export class AppComponent {
15+
>AppComponent : Symbol(AppComponent, Decl(test.tsx, 5, 1))
16+
17+
render(createElement) {
18+
>render : Symbol(AppComponent.render, Decl(test.tsx, 7, 27))
19+
>createElement : Symbol(createElement, Decl(test.tsx, 8, 11))
20+
21+
return <div />;
22+
>div : Symbol(unknown)
23+
}
24+
}
25+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=== tests/cases/compiler/test.tsx ===
2+
3+
declare module JSX {
4+
>JSX : any
5+
6+
interface IntrinsicElements {
7+
>IntrinsicElements : IntrinsicElements
8+
9+
[s: string]: any;
10+
>s : string
11+
}
12+
}
13+
14+
export class AppComponent {
15+
>AppComponent : AppComponent
16+
17+
render(createElement) {
18+
>render : (createElement: any) => any
19+
>createElement : any
20+
21+
return <div />;
22+
><div /> : any
23+
>div : any
24+
}
25+
}
26+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
tests/cases/compiler/test.tsx(10,17): error TS2304: Cannot find name 'createElement'.
2+
3+
4+
==== tests/cases/compiler/test.tsx (1 errors) ====
5+
6+
declare module JSX {
7+
interface IntrinsicElements {
8+
[s: string]: any;
9+
}
10+
}
11+
12+
export class AppComponent {
13+
render() {
14+
return <div />;
15+
~~~
16+
!!! error TS2304: Cannot find name 'createElement'.
17+
}
18+
}
19+

tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.js

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/jsxFactoryIdentifierWithAbsentParameter.js.map

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
===================================================================
2+
JsFile: test.js
3+
mapUrl: test.js.map
4+
sourceRoot:
5+
sources: test.tsx
6+
===================================================================
7+
-------------------------------------------------------------------
8+
emittedFile:tests/cases/compiler/test.js
9+
sourceFile:test.tsx
10+
-------------------------------------------------------------------
11+
>>>"use strict";
12+
>>>class AppComponent {
13+
1 >
14+
2 >^^^^^^^^^^^^^^^->
15+
1 >
16+
>declare module JSX {
17+
> interface IntrinsicElements {
18+
> [s: string]: any;
19+
> }
20+
>}
21+
>
22+
>
23+
1 >Emitted(2, 1) Source(8, 1) + SourceIndex(0)
24+
---
25+
>>> render() {
26+
1->^^^^
27+
2 > ^^^^^^
28+
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
29+
1->export class AppComponent {
30+
>
31+
2 > render
32+
1->Emitted(3, 5) Source(9, 5) + SourceIndex(0)
33+
2 >Emitted(3, 11) Source(9, 11) + SourceIndex(0)
34+
---
35+
>>> return createElement("div", null);
36+
1->^^^^^^^^
37+
2 > ^^^^^^
38+
3 > ^
39+
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^
40+
5 > ^
41+
1->() {
42+
>
43+
2 > return
44+
3 >
45+
4 > <div />
46+
5 > ;
47+
1->Emitted(4, 9) Source(10, 9) + SourceIndex(0)
48+
2 >Emitted(4, 15) Source(10, 15) + SourceIndex(0)
49+
3 >Emitted(4, 16) Source(10, 16) + SourceIndex(0)
50+
4 >Emitted(4, 42) Source(10, 23) + SourceIndex(0)
51+
5 >Emitted(4, 43) Source(10, 24) + SourceIndex(0)
52+
---
53+
>>> }
54+
1 >^^^^
55+
2 > ^
56+
1 >
57+
>
58+
2 > }
59+
1 >Emitted(5, 5) Source(11, 5) + SourceIndex(0)
60+
2 >Emitted(5, 6) Source(11, 6) + SourceIndex(0)
61+
---
62+
>>>}
63+
1 >^
64+
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
65+
1 >
66+
>}
67+
1 >Emitted(6, 2) Source(12, 2) + SourceIndex(0)
68+
---
69+
>>>exports.AppComponent = AppComponent;
70+
1->
71+
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
72+
1->
73+
2 >export class AppComponent {
74+
> render() {
75+
> return <div />;
76+
> }
77+
>}
78+
1->Emitted(7, 1) Source(8, 1) + SourceIndex(0)
79+
2 >Emitted(7, 37) Source(12, 2) + SourceIndex(0)
80+
---
81+
>>>//# sourceMappingURL=test.js.map
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
tests/cases/compiler/test.tsx(10,17): error TS2304: Cannot find name 'MyElement'.
2+
3+
4+
==== tests/cases/compiler/test.tsx (1 errors) ====
5+
6+
declare module JSX {
7+
interface IntrinsicElements {
8+
[s: string]: any;
9+
}
10+
}
11+
12+
export class AppComponent {
13+
render(createElement) {
14+
return <div />;
15+
~~~
16+
!!! error TS2304: Cannot find name 'MyElement'.
17+
}
18+
}

0 commit comments

Comments
 (0)