@@ -6,12 +6,12 @@ import { Project } from "ts-morph";
6
6
7
7
import { ignoreErrors } from "./ignoreErrors" ;
8
8
9
- const PROJECT_ROOT = path . resolve (
10
- import . meta. dirname ,
11
- "__fixtures__/sample-project" ,
12
- ) ;
13
-
14
9
test ( "should work" , ( t ) => {
10
+ const PROJECT_ROOT = path . resolve (
11
+ import . meta. dirname ,
12
+ "__fixtures__/sample-project" ,
13
+ ) ;
14
+
15
15
const project = new Project ( {
16
16
tsConfigFilePath : path . resolve ( PROJECT_ROOT , "tsconfig.json" ) ,
17
17
} ) ;
@@ -50,3 +50,40 @@ a = "foo";
50
50
` ,
51
51
) ;
52
52
} ) ;
53
+
54
+ test ( "tsx" , ( t ) => {
55
+ const PROJECT_ROOT = path . resolve (
56
+ import . meta. dirname ,
57
+ "__fixtures__/sample-project-react" ,
58
+ ) ;
59
+
60
+ const project = new Project ( {
61
+ tsConfigFilePath : path . resolve ( PROJECT_ROOT , "tsconfig.json" ) ,
62
+ } ) ;
63
+
64
+ const diagnostics = project . getPreEmitDiagnostics ( ) ;
65
+ ignoreErrors ( diagnostics ) ;
66
+
67
+ const sourceFile = project . getSourceFile ( "index.tsx" ) ;
68
+ assert ( sourceFile , "File should exist" ) ;
69
+ assert . equal (
70
+ sourceFile . getText ( ) ,
71
+ `\
72
+ function Component() {
73
+ const doc = "foo"
74
+
75
+ // @ts-expect-error TS(2339) FIXME: Property 'foo' does not exist on type '"foo"'.
76
+ doc.foo
77
+
78
+ return <>
79
+ {/* @ts-expect-error TS(2304) FIXME: Cannot find name 'Foo'. */}
80
+ <Foo bar={bas} />
81
+ {/* @ts-expect-error TS(2339) FIXME: Property 'foo' does not exist on type '"foo"'. */}
82
+ {doc.foo}
83
+ </>;
84
+ }
85
+
86
+ export default Component
87
+ ` ,
88
+ ) ;
89
+ } ) ;
0 commit comments