-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Ensure factory symbol remains unused in react-jsx mode when not referenced in user code #41905
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/reactImportUnusedInNewJSXEmit(jsx=react-jsx).errors.txt
This file contains hidden or 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,17 @@ | ||
tests/cases/compiler/index.tsx(3,1): error TS6133: 'React' is declared but its value is never read. | ||
|
||
|
||
==== tests/cases/compiler/index.tsx (1 errors) ==== | ||
/// <reference path="/.lib/react16.d.ts" /> | ||
|
||
import React from "react"; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS6133: 'React' is declared but its value is never read. | ||
|
||
function Bar() { | ||
return <div />; | ||
} | ||
|
||
export function Foo() { | ||
return <Bar />; | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/reactImportUnusedInNewJSXEmit(jsx=react-jsx).js
This file contains hidden or 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,25 @@ | ||
//// [index.tsx] | ||
/// <reference path="/.lib/react16.d.ts" /> | ||
|
||
import React from "react"; | ||
|
||
function Bar() { | ||
return <div />; | ||
} | ||
|
||
export function Foo() { | ||
return <Bar />; | ||
} | ||
|
||
//// [index.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.Foo = void 0; | ||
var jsx_runtime_1 = require("react/jsx-runtime"); | ||
function Bar() { | ||
return jsx_runtime_1.jsx("div", {}, void 0); | ||
} | ||
function Foo() { | ||
return jsx_runtime_1.jsx(Bar, {}, void 0); | ||
} | ||
exports.Foo = Foo; |
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/reactImportUnusedInNewJSXEmit(jsx=react-jsx).symbols
This file contains hidden or 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,19 @@ | ||
=== tests/cases/compiler/index.tsx === | ||
/// <reference path="react16.d.ts" /> | ||
|
||
import React from "react"; | ||
>React : Symbol(React, Decl(index.tsx, 2, 6)) | ||
|
||
function Bar() { | ||
>Bar : Symbol(Bar, Decl(index.tsx, 2, 26)) | ||
|
||
return <div />; | ||
>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2420, 114)) | ||
} | ||
|
||
export function Foo() { | ||
>Foo : Symbol(Foo, Decl(index.tsx, 6, 1)) | ||
|
||
return <Bar />; | ||
>Bar : Symbol(Bar, Decl(index.tsx, 2, 26)) | ||
} |
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/reactImportUnusedInNewJSXEmit(jsx=react-jsx).types
This file contains hidden or 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,21 @@ | ||
=== tests/cases/compiler/index.tsx === | ||
/// <reference path="react16.d.ts" /> | ||
|
||
import React from "react"; | ||
>React : typeof React | ||
|
||
function Bar() { | ||
>Bar : () => JSX.Element | ||
|
||
return <div />; | ||
><div /> : JSX.Element | ||
>div : any | ||
} | ||
|
||
export function Foo() { | ||
>Foo : () => JSX.Element | ||
|
||
return <Bar />; | ||
><Bar /> : JSX.Element | ||
>Bar : () => JSX.Element | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/reactImportUnusedInNewJSXEmit(jsx=react-jsxdev).errors.txt
This file contains hidden or 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,17 @@ | ||
tests/cases/compiler/index.tsx(3,1): error TS6133: 'React' is declared but its value is never read. | ||
|
||
|
||
==== tests/cases/compiler/index.tsx (1 errors) ==== | ||
/// <reference path="/.lib/react16.d.ts" /> | ||
|
||
import React from "react"; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS6133: 'React' is declared but its value is never read. | ||
|
||
function Bar() { | ||
return <div />; | ||
} | ||
|
||
export function Foo() { | ||
return <Bar />; | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/reactImportUnusedInNewJSXEmit(jsx=react-jsxdev).js
This file contains hidden or 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,26 @@ | ||
//// [index.tsx] | ||
/// <reference path="/.lib/react16.d.ts" /> | ||
|
||
import React from "react"; | ||
|
||
function Bar() { | ||
return <div />; | ||
} | ||
|
||
export function Foo() { | ||
return <Bar />; | ||
} | ||
|
||
//// [index.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.Foo = void 0; | ||
var jsx_dev_runtime_1 = require("react/jsx-dev-runtime"); | ||
var _jsxFileName = "tests/cases/compiler/index.tsx"; | ||
function Bar() { | ||
return jsx_dev_runtime_1.jsxDEV("div", {}, void 0, false, { fileName: _jsxFileName, lineNumber: 6, columnNumber: 9 }, this); | ||
} | ||
function Foo() { | ||
return jsx_dev_runtime_1.jsxDEV(Bar, {}, void 0, false, { fileName: _jsxFileName, lineNumber: 10, columnNumber: 9 }, this); | ||
} | ||
exports.Foo = Foo; |
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/reactImportUnusedInNewJSXEmit(jsx=react-jsxdev).symbols
This file contains hidden or 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,19 @@ | ||
=== tests/cases/compiler/index.tsx === | ||
/// <reference path="react16.d.ts" /> | ||
|
||
import React from "react"; | ||
>React : Symbol(React, Decl(index.tsx, 2, 6)) | ||
|
||
function Bar() { | ||
>Bar : Symbol(Bar, Decl(index.tsx, 2, 26)) | ||
|
||
return <div />; | ||
>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2420, 114)) | ||
} | ||
|
||
export function Foo() { | ||
>Foo : Symbol(Foo, Decl(index.tsx, 6, 1)) | ||
|
||
return <Bar />; | ||
>Bar : Symbol(Bar, Decl(index.tsx, 2, 26)) | ||
} |
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/reactImportUnusedInNewJSXEmit(jsx=react-jsxdev).types
This file contains hidden or 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,21 @@ | ||
=== tests/cases/compiler/index.tsx === | ||
/// <reference path="react16.d.ts" /> | ||
|
||
import React from "react"; | ||
>React : typeof React | ||
|
||
function Bar() { | ||
>Bar : () => JSX.Element | ||
|
||
return <div />; | ||
><div /> : JSX.Element | ||
>div : any | ||
} | ||
|
||
export function Foo() { | ||
>Foo : () => JSX.Element | ||
|
||
return <Bar />; | ||
><Bar /> : JSX.Element | ||
>Bar : () => JSX.Element | ||
} |
This file contains hidden or 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,16 @@ | ||
// @esModuleInterop: true | ||
// @noUnusedLocals: true | ||
// @jsx: react-jsx,react-jsxdev | ||
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. 🤯 TIL |
||
// @skipLibCheck: true | ||
// @filename: index.tsx | ||
/// <reference path="/.lib/react16.d.ts" /> | ||
|
||
import React from "react"; | ||
|
||
function Bar() { | ||
return <div />; | ||
} | ||
|
||
export function Foo() { | ||
return <Bar />; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense, but it’s unintuitive as to why it fixes this particular bug. Something later in this function marked
React
as referenced, for some reason?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - looking up it's type to see if it had call signatures.