mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-26 21:05:54 -06:00
Add test cases for when jsxFactory cannot be resolved
This commit is contained in:
parent
c6b1bbe12d
commit
a88c2ae1e4
24
tests/baselines/reference/jsxFactoryIdentifierAsParameter.js
Normal file
24
tests/baselines/reference/jsxFactoryIdentifierAsParameter.js
Normal file
@ -0,0 +1,24 @@
|
||||
//// [test.tsx]
|
||||
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render(createElement) {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
class AppComponent {
|
||||
render(createElement) {
|
||||
return createElement("div", null);
|
||||
}
|
||||
}
|
||||
exports.AppComponent = AppComponent;
|
||||
//# sourceMappingURL=test.js.map
|
||||
@ -0,0 +1,2 @@
|
||||
//// [test.js.map]
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAOA;IACI,MAAM,CAAC,aAAa;QAChB,MAAM,CAAC,0BAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"}
|
||||
@ -0,0 +1,87 @@
|
||||
===================================================================
|
||||
JsFile: test.js
|
||||
mapUrl: test.js.map
|
||||
sourceRoot:
|
||||
sources: test.tsx
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/test.js
|
||||
sourceFile:test.tsx
|
||||
-------------------------------------------------------------------
|
||||
>>>"use strict";
|
||||
>>>class AppComponent {
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>declare module JSX {
|
||||
> interface IntrinsicElements {
|
||||
> [s: string]: any;
|
||||
> }
|
||||
>}
|
||||
>
|
||||
>
|
||||
1 >Emitted(2, 1) Source(8, 1) + SourceIndex(0)
|
||||
---
|
||||
>>> render(createElement) {
|
||||
1->^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^
|
||||
5 > ^^^^^^^^^^^^^^^^^^^->
|
||||
1->export class AppComponent {
|
||||
>
|
||||
2 > render
|
||||
3 > (
|
||||
4 > createElement
|
||||
1->Emitted(3, 5) Source(9, 5) + SourceIndex(0)
|
||||
2 >Emitted(3, 11) Source(9, 11) + SourceIndex(0)
|
||||
3 >Emitted(3, 12) Source(9, 12) + SourceIndex(0)
|
||||
4 >Emitted(3, 25) Source(9, 25) + SourceIndex(0)
|
||||
---
|
||||
>>> return createElement("div", null);
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
5 > ^
|
||||
1->) {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > <div />
|
||||
5 > ;
|
||||
1->Emitted(4, 9) Source(10, 9) + SourceIndex(0)
|
||||
2 >Emitted(4, 15) Source(10, 15) + SourceIndex(0)
|
||||
3 >Emitted(4, 16) Source(10, 16) + SourceIndex(0)
|
||||
4 >Emitted(4, 42) Source(10, 23) + SourceIndex(0)
|
||||
5 >Emitted(4, 43) Source(10, 24) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(5, 5) Source(11, 5) + SourceIndex(0)
|
||||
2 >Emitted(5, 6) Source(11, 6) + SourceIndex(0)
|
||||
---
|
||||
>>>}
|
||||
1 >^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>}
|
||||
1 >Emitted(6, 2) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>exports.AppComponent = AppComponent;
|
||||
1->
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
1->
|
||||
2 >export class AppComponent {
|
||||
> render(createElement) {
|
||||
> return <div />;
|
||||
> }
|
||||
>}
|
||||
1->Emitted(7, 1) Source(8, 1) + SourceIndex(0)
|
||||
2 >Emitted(7, 37) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=test.js.map
|
||||
@ -0,0 +1,25 @@
|
||||
=== tests/cases/compiler/test.tsx ===
|
||||
|
||||
declare module JSX {
|
||||
>JSX : Symbol(JSX, Decl(test.tsx, 0, 0))
|
||||
|
||||
interface IntrinsicElements {
|
||||
>IntrinsicElements : Symbol(IntrinsicElements, Decl(test.tsx, 1, 20))
|
||||
|
||||
[s: string]: any;
|
||||
>s : Symbol(s, Decl(test.tsx, 3, 9))
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
>AppComponent : Symbol(AppComponent, Decl(test.tsx, 5, 1))
|
||||
|
||||
render(createElement) {
|
||||
>render : Symbol(AppComponent.render, Decl(test.tsx, 7, 27))
|
||||
>createElement : Symbol(createElement, Decl(test.tsx, 8, 11))
|
||||
|
||||
return <div />;
|
||||
>div : Symbol(unknown)
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/test.tsx ===
|
||||
|
||||
declare module JSX {
|
||||
>JSX : any
|
||||
|
||||
interface IntrinsicElements {
|
||||
>IntrinsicElements : IntrinsicElements
|
||||
|
||||
[s: string]: any;
|
||||
>s : string
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
>AppComponent : AppComponent
|
||||
|
||||
render(createElement) {
|
||||
>render : (createElement: any) => any
|
||||
>createElement : any
|
||||
|
||||
return <div />;
|
||||
><div /> : any
|
||||
>div : any
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
tests/cases/compiler/test.tsx(10,17): error TS2304: Cannot find name 'createElement'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/test.tsx (1 errors) ====
|
||||
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render() {
|
||||
return <div />;
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'createElement'.
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
//// [test.tsx]
|
||||
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
class AppComponent {
|
||||
render() {
|
||||
return createElement("div", null);
|
||||
}
|
||||
}
|
||||
exports.AppComponent = AppComponent;
|
||||
//# sourceMappingURL=test.js.map
|
||||
@ -0,0 +1,2 @@
|
||||
//// [test.js.map]
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAOA;IACI,MAAM;QACF,MAAM,CAAC,0BAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"}
|
||||
@ -0,0 +1,81 @@
|
||||
===================================================================
|
||||
JsFile: test.js
|
||||
mapUrl: test.js.map
|
||||
sourceRoot:
|
||||
sources: test.tsx
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/test.js
|
||||
sourceFile:test.tsx
|
||||
-------------------------------------------------------------------
|
||||
>>>"use strict";
|
||||
>>>class AppComponent {
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>declare module JSX {
|
||||
> interface IntrinsicElements {
|
||||
> [s: string]: any;
|
||||
> }
|
||||
>}
|
||||
>
|
||||
>
|
||||
1 >Emitted(2, 1) Source(8, 1) + SourceIndex(0)
|
||||
---
|
||||
>>> render() {
|
||||
1->^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1->export class AppComponent {
|
||||
>
|
||||
2 > render
|
||||
1->Emitted(3, 5) Source(9, 5) + SourceIndex(0)
|
||||
2 >Emitted(3, 11) Source(9, 11) + SourceIndex(0)
|
||||
---
|
||||
>>> return createElement("div", null);
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
5 > ^
|
||||
1->() {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > <div />
|
||||
5 > ;
|
||||
1->Emitted(4, 9) Source(10, 9) + SourceIndex(0)
|
||||
2 >Emitted(4, 15) Source(10, 15) + SourceIndex(0)
|
||||
3 >Emitted(4, 16) Source(10, 16) + SourceIndex(0)
|
||||
4 >Emitted(4, 42) Source(10, 23) + SourceIndex(0)
|
||||
5 >Emitted(4, 43) Source(10, 24) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(5, 5) Source(11, 5) + SourceIndex(0)
|
||||
2 >Emitted(5, 6) Source(11, 6) + SourceIndex(0)
|
||||
---
|
||||
>>>}
|
||||
1 >^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>}
|
||||
1 >Emitted(6, 2) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>exports.AppComponent = AppComponent;
|
||||
1->
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
1->
|
||||
2 >export class AppComponent {
|
||||
> render() {
|
||||
> return <div />;
|
||||
> }
|
||||
>}
|
||||
1->Emitted(7, 1) Source(8, 1) + SourceIndex(0)
|
||||
2 >Emitted(7, 37) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=test.js.map
|
||||
@ -0,0 +1,18 @@
|
||||
tests/cases/compiler/test.tsx(10,17): error TS2304: Cannot find name 'MyElement'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/test.tsx (1 errors) ====
|
||||
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render(createElement) {
|
||||
return <div />;
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'MyElement'.
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
//// [test.tsx]
|
||||
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render(createElement) {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
//// [test.js]
|
||||
"use strict";
|
||||
class AppComponent {
|
||||
render(createElement) {
|
||||
return MyElement.createElement("div", null);
|
||||
}
|
||||
}
|
||||
exports.AppComponent = AppComponent;
|
||||
//# sourceMappingURL=test.js.map
|
||||
@ -0,0 +1,2 @@
|
||||
//// [test.js.map]
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":";AAOA;IACI,MAAM,CAAC,aAAa;QAChB,MAAM,CAAC,oCAAO,CAAC;IACnB,CAAC;CACJ;AAJD,oCAIC"}
|
||||
@ -0,0 +1,87 @@
|
||||
===================================================================
|
||||
JsFile: test.js
|
||||
mapUrl: test.js.map
|
||||
sourceRoot:
|
||||
sources: test.tsx
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/test.js
|
||||
sourceFile:test.tsx
|
||||
-------------------------------------------------------------------
|
||||
>>>"use strict";
|
||||
>>>class AppComponent {
|
||||
1 >
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>declare module JSX {
|
||||
> interface IntrinsicElements {
|
||||
> [s: string]: any;
|
||||
> }
|
||||
>}
|
||||
>
|
||||
>
|
||||
1 >Emitted(2, 1) Source(8, 1) + SourceIndex(0)
|
||||
---
|
||||
>>> render(createElement) {
|
||||
1->^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^
|
||||
5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1->export class AppComponent {
|
||||
>
|
||||
2 > render
|
||||
3 > (
|
||||
4 > createElement
|
||||
1->Emitted(3, 5) Source(9, 5) + SourceIndex(0)
|
||||
2 >Emitted(3, 11) Source(9, 11) + SourceIndex(0)
|
||||
3 >Emitted(3, 12) Source(9, 12) + SourceIndex(0)
|
||||
4 >Emitted(3, 25) Source(9, 25) + SourceIndex(0)
|
||||
---
|
||||
>>> return MyElement.createElement("div", null);
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^
|
||||
3 > ^
|
||||
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
5 > ^
|
||||
1->) {
|
||||
>
|
||||
2 > return
|
||||
3 >
|
||||
4 > <div />
|
||||
5 > ;
|
||||
1->Emitted(4, 9) Source(10, 9) + SourceIndex(0)
|
||||
2 >Emitted(4, 15) Source(10, 15) + SourceIndex(0)
|
||||
3 >Emitted(4, 16) Source(10, 16) + SourceIndex(0)
|
||||
4 >Emitted(4, 52) Source(10, 23) + SourceIndex(0)
|
||||
5 >Emitted(4, 53) Source(10, 24) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(5, 5) Source(11, 5) + SourceIndex(0)
|
||||
2 >Emitted(5, 6) Source(11, 6) + SourceIndex(0)
|
||||
---
|
||||
>>>}
|
||||
1 >^
|
||||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1 >
|
||||
>}
|
||||
1 >Emitted(6, 2) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>exports.AppComponent = AppComponent;
|
||||
1->
|
||||
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
1->
|
||||
2 >export class AppComponent {
|
||||
> render(createElement) {
|
||||
> return <div />;
|
||||
> }
|
||||
>}
|
||||
1->Emitted(7, 1) Source(8, 1) + SourceIndex(0)
|
||||
2 >Emitted(7, 37) Source(12, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=test.js.map
|
||||
18
tests/cases/compiler/jsxFactoryIdentifierAsParameter.ts
Normal file
18
tests/cases/compiler/jsxFactoryIdentifierAsParameter.ts
Normal file
@ -0,0 +1,18 @@
|
||||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@jsxFactory: createElement
|
||||
//@sourcemap: true
|
||||
|
||||
// @filename: test.tsx
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render(createElement) {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@jsxFactory: createElement
|
||||
//@sourcemap: true
|
||||
|
||||
// @filename: test.tsx
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render() {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
//@jsx: react
|
||||
//@target: es6
|
||||
//@module: commonjs
|
||||
//@jsxFactory: MyElement.createElement
|
||||
//@sourcemap: true
|
||||
|
||||
// @filename: test.tsx
|
||||
declare module JSX {
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
export class AppComponent {
|
||||
render(createElement) {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user