-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix import fix on react or react dev (#41950)
- Loading branch information
Showing
4 changed files
with
93 additions
and
5 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
43 changes: 43 additions & 0 deletions
43
tests/cases/fourslash/codeFixAddMissingImportForReactJsx1.ts
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,43 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
// @jsx: react-jsx | ||
|
||
// @Filename: node_modules/react/index.d.ts | ||
////export declare var React: any; | ||
|
||
// @Filename: node_modules/react/package.json | ||
////{ | ||
//// "name": "react", | ||
//// "types": "./index.d.ts" | ||
////} | ||
|
||
// @Filename: foo.tsx | ||
//// export default function Foo(){ | ||
//// return <></>; | ||
//// } | ||
|
||
// @Filename: bar.tsx | ||
//// export default function Bar(){ | ||
//// return <Foo></Foo>; | ||
//// } | ||
|
||
// @Filename: package.json | ||
////{ | ||
//// "dependencies": { | ||
//// "react": "*" | ||
//// } | ||
////} | ||
|
||
goTo.file('bar.tsx') | ||
|
||
verify.codeFixAll({ | ||
fixId: "fixMissingImport", | ||
fixAllDescription: "Add all missing imports", | ||
newFileContent: | ||
`import Foo from "./foo"; | ||
export default function Bar(){ | ||
return <Foo></Foo>; | ||
}`, | ||
}); | ||
|
43 changes: 43 additions & 0 deletions
43
tests/cases/fourslash/codeFixAddMissingImportForReactJsx2.ts
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,43 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
// @jsx: react-jsxdev | ||
|
||
// @Filename: node_modules/react/index.d.ts | ||
////export declare var React: any; | ||
|
||
// @Filename: node_modules/react/package.json | ||
////{ | ||
//// "name": "react", | ||
//// "types": "./index.d.ts" | ||
////} | ||
|
||
// @Filename: foo.tsx | ||
//// export default function Foo(){ | ||
//// return <></>; | ||
//// } | ||
|
||
// @Filename: bar.tsx | ||
//// export default function Bar(){ | ||
//// return <Foo></Foo>; | ||
//// } | ||
|
||
// @Filename: package.json | ||
////{ | ||
//// "dependencies": { | ||
//// "react": "*" | ||
//// } | ||
////} | ||
|
||
goTo.file('bar.tsx') | ||
|
||
verify.codeFixAll({ | ||
fixId: "fixMissingImport", | ||
fixAllDescription: "Add all missing imports", | ||
newFileContent: | ||
`import Foo from "./foo"; | ||
export default function Bar(){ | ||
return <Foo></Foo>; | ||
}`, | ||
}); | ||
|