Skip to content
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

jsxFactory import showing as unused when TSX is configured via tsconfig and only contains fragments #60459

Open
neonstalwart opened this issue Nov 8, 2024 · 0 comments
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@neonstalwart
Copy link

neonstalwart commented Nov 8, 2024

πŸ”Ž Search Terms

TSX unused fragment jsxFactory

πŸ•— Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ for entries about "jsx"

⏯ Playground Link

https://www.typescriptlang.org/dev/bug-workbench/?noUnusedLocals=true&jsxFactory=element&jsxFragmentFactory=fragment#code/PTAEAECsGcA8C5QCcCmBDAxgFwFAgjLAGKZYD2SAnoigDYoC2KAdrvlHEUmgOZOslsFaqABm3PizZhwzMgFVmAV2goAJgBkyGNLWg48M0QEt6zNE0THmalLAB0WODmMMADhSygA3nUZSAGjEJfiwAX2CyBlAAcntgQhiAbgMMMmZoMnp7WjIeAAoAHgA+Ll5QwuBigEoUwwgTMwsUREJHfTsPJC9RJWZsY3TQP1D86p8wg07PMT6BofFyqTGJ0CA

πŸ’» Code

// @jsx: react
// @jsxFactory: element
// @jsxFragmentFactory: fragment
// @noUnusedLocals

// @filename: index.tsx
import {element, fragment} from './jsx';

console.log(<>Fragment</>);

// @filename: jsx.ts
export function element() {}

export function fragment() {} 

Workbench Repro

πŸ™ Actual behavior

'element' is declared but its value is never read.

πŸ™‚ Expected behavior

element is used in the generated output so should not be found as unused.

Generated output:

console.log(element(fragment, null, "Fragment"));

Additional information about the issue

Using pragmas instead of tsconfig works as expected so hopefully it's not a big gap to align these

// @jsx: react
// @noUnusedLocals

// @filename: index.tsx
/**
 * @jsx element
 * @jsxFrag fragment
 */
import {element, fragment} from './jsx';

console.log(<>Fragment</>);

// @filename: jsx.ts
export function element() {}

export function fragment() {} 

Workbench Repro

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Nov 12, 2024
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.8.0 milestone Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

3 participants