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

[dts]: remove unused import in isolatedDeclaration #9705

Open
SoonIter opened this issue Nov 1, 2024 · 0 comments · May be fixed by #9715
Open

[dts]: remove unused import in isolatedDeclaration #9705

SoonIter opened this issue Nov 1, 2024 · 0 comments · May be fixed by #9715
Milestone

Comments

@SoonIter
Copy link

SoonIter commented Nov 1, 2024

Describe the feature

some differences between swc and tsc

source code

import { useState } from "react";
import reactLogo from "./assets/react.svg";
import "./App.css";

function App(): JSX.Element {
	const [count, setCount] = useState(0);

	return (
		<div className="App">
			<div>
				<a href="https://reactjs.org" target="_blank" rel="noreferrer">
					<img src={reactLogo} className="logo react" alt="React logo" />
				</a>
			</div>
			<h1>Rspack + React + TypeScript</h1>
			<div className="card">
				<button type="button" onClick={() => setCount(count => count + 1)}>
					count is {count}
				</button>
				<p>
					Edit <code>src/App.tsx</code> and save to test HMR
				</p>
			</div>
			<p className="read-the-docs">
				Click on the Rspack and React logos to learn more
			</p>
		</div>
	);
}

export default App;

expected output

the same as tsc

import "./App.css";
declare function App(): JSX.Element;
export default App;

actual output

import { useState } from "react"; // unused
import reactLogo from "./assets/react.svg"; // unused and would emit type error
import "./App.css";

declare function App(): JSX.Element;
export default App;

Babel plugin or link to the feature description

No response

Additional context

Related links

https://github.com/oxc-project/oxc/blob/0bb1aa4c6472d2553154fe2f1d8939abb69ed915/crates/oxc_isolated_declarations/src/lib.rs#L359
web-infra-dev/rspack#8097

@kdy1 kdy1 self-assigned this Nov 4, 2024
@kdy1 kdy1 added this to the Planned milestone Nov 4, 2024
@kdy1 kdy1 removed their assignment Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants