Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 13.8k
Auto-include types for the jsx import source in the new jsx transforms#41330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
6714998fe3b3438493ee8fe94a211e1ae30File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -276,5 +276,33 @@ export interface A { | ||
| ], | ||
| modifyFs: host => host.deleteFile(`${project}/globals.d.ts`) | ||
| }); | ||
| const jsxImportSourceOptions = { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react" }; | ||
| const jsxLibraryContent = `export namespace JSX { | ||
| interface Element {} | ||
| interface IntrinsicElements { | ||
| div: { | ||
| propA?: boolean; | ||
| }; | ||
| } | ||
| } | ||
| export function jsx(...args: any[]): void; | ||
| export function jsxs(...args: any[]): void; | ||
| export const Fragment: unique symbol; | ||
| `; | ||
| verifyIncrementalWatchEmit({ | ||
| subScenario: "jsxImportSource option changed", | ||
| files: () => [ | ||
| { path: libFile.path, content: libContent }, | ||
| { path: `${project}/node_modules/react/jsx-runtime/index.d.ts`, content: jsxLibraryContent }, | ||
| { path: `${project}/node_modules/react/package.json`, content: JSON.stringify({ name: "react", version: "0.0.1" }) }, | ||
| { path: `${project}/node_modules/preact/jsx-runtime/index.d.ts`, content: jsxLibraryContent.replace("propA", "propB") }, | ||
| { path: `${project}/node_modules/preact/package.json`, content: JSON.stringify({ name: "preact", version: "0.0.1" }) }, | ||
| { path: `${project}/index.tsx`, content: `export const App = () => <div propA={true}></div>;` }, | ||
| { path: configFile.path, content: JSON.stringify({ compilerOptions: jsxImportSourceOptions }) } | ||
| ], | ||
| modifyFs: host => host.writeFile(configFile.path, JSON.stringify({ compilerOptions: { ...jsxImportSourceOptions, jsxImportSource: "preact" } })) | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add another case hen preact*.d.ts file is missing and added. | ||
| }); | ||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations. | ||
| ==== tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImport.tsx (1 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| const a = <> | ||
| ~~ | ||
| !!! error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations. | ||
| <p></p> | ||
| text | ||
| <div className="foo"></div> | ||
| </> | ||
| export {}; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations. | ||
| ==== tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImport.tsx (1 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| const a = <> | ||
| ~~ | ||
| !!! error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations. | ||
| <p></p> | ||
| text | ||
| <div className="foo"></div> | ||
| </> | ||
| export {}; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| tests/cases/conformance/jsx/jsxs/preact.tsx(3,11): error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations. | ||
| ==== tests/cases/conformance/jsx/jsxs/react.tsx (0 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| /* @jsxImportSource react */ | ||
| import "./preact"; | ||
| const a = <> | ||
| <p></p> | ||
| text | ||
| <div className="foo"></div> | ||
| </> | ||
| export {}; | ||
| ==== tests/cases/conformance/jsx/jsxs/preact.tsx (1 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| /* @jsxImportSource preact */ | ||
| const a = <> | ||
| ~~ | ||
| !!! error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations. | ||
| <p></p> | ||
| text | ||
| <div className="foo"></div> | ||
| </> | ||
| export {}; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| tests/cases/conformance/jsx/jsxs/preact.tsx(3,11): error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations. | ||
| ==== tests/cases/conformance/jsx/jsxs/react.tsx (0 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| /* @jsxImportSource react */ | ||
| import "./preact"; | ||
| const a = <> | ||
| <p></p> | ||
| text | ||
| <div className="foo"></div> | ||
| </> | ||
| export {}; | ||
| ==== tests/cases/conformance/jsx/jsxs/preact.tsx (1 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| /* @jsxImportSource preact */ | ||
| const a = <> | ||
| ~~ | ||
| !!! error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations. | ||
| <p></p> | ||
| text | ||
| <div className="foo"></div> | ||
| </> | ||
| export {}; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImport.tsx(3,11): error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations. | ||
| ==== tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImport.tsx (1 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| const props = { answer: 42 } | ||
| const a = <div key="foo" {...props}>text</div>; | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations. | ||
| const b = <div {...props} key="bar">text</div>; | ||
| export {}; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImport.tsx(3,11): error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations. | ||
| ==== tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImport.tsx (1 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| const props = { answer: 42 } | ||
| const a = <div key="foo" {...props}>text</div>; | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations. | ||
| const b = <div {...props} key="bar">text</div>; | ||
| export {}; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| tests/cases/conformance/jsx/jsxs/preact.tsx(4,11): error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations. | ||
| ==== tests/cases/conformance/jsx/jsxs/react.tsx (0 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| /* @jsxImportSource react */ | ||
| import "./preact"; | ||
| const props2 = { answer: 42 } | ||
| const a2 = <div key="foo" {...props2}>text</div>; | ||
| const b2 = <div {...props2} key="bar">text</div>; | ||
| export {}; | ||
| ==== tests/cases/conformance/jsx/jsxs/preact.tsx (1 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| /* @jsxImportSource preact */ | ||
| const props = { answer: 42 } | ||
| const a = <div key="foo" {...props}>text</div>; | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations. | ||
| const b = <div {...props} key="bar">text</div>; | ||
| export {}; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| tests/cases/conformance/jsx/jsxs/preact.tsx(4,11): error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations. | ||
| ==== tests/cases/conformance/jsx/jsxs/react.tsx (0 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| /* @jsxImportSource react */ | ||
| import "./preact"; | ||
| const props2 = { answer: 42 } | ||
| const a2 = <div key="foo" {...props2}>text</div>; | ||
| const b2 = <div {...props2} key="bar">text</div>; | ||
| export {}; | ||
| ==== tests/cases/conformance/jsx/jsxs/preact.tsx (1 errors) ==== | ||
| /// <reference path="/.lib/react16.d.ts" /> | ||
| /* @jsxImportSource preact */ | ||
| const props = { answer: 42 } | ||
| const a = <div key="foo" {...props}>text</div>; | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations. | ||
| const b = <div {...props} key="bar">text</div>; | ||
| export {}; | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.