swc-project / swc

Rust-based platform for the Web
https://swc.rs
Apache License 2.0
31.26k stars 1.23k forks source link

[Enhancement][dts]: align the tsc error format of `isolatedDeclaration` #9718

Open SoonIter opened 2 weeks ago

SoonIter commented 2 weeks ago

Summary

deno's implementation is earlier than tsc, so it has its own error format.

But presently, tsc has its standard error format, and users would use it with tsc isolatedDeclaration: true in tsconfig.json and wish they both have the same error diagnostic behavior

there is one case

input

import { useState } from 'react';
import './App.css';

function App() {
    return (
        <div className="App"></div>
    );
}

export default App;

expected behavior

src/App.tsx(4,10): error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations.

actual behavior

output successfully

import { useState } from 'react';
import './App.css';
declare function App(); // -> 'App' implicitly has an 'any' return type
export default App;

Related links

https://github.com/swc-project/swc/issues/9715#issuecomment-2456761751_

https://github.com/web-infra-dev/rspack/pull/8097

CPunisher commented 2 weeks ago

In order to be fully aligned with tsc (in fact I plan to refer to oxc for convenience 😅), we need a lot of refactoring. Maybe nearly rewrite everything to determine some errors to be thrown somewhere. Also that means we will never follow the deno's implementation. I'm glad to do but I can't make sure when it will be done since this is time-consuming. What do you think? @kdy1

kdy1 commented 2 weeks ago

I think it may create too much maintenance burden. And I can't make the time to maintain isolated dts frequently, so please do what you want. I'll be able to help a bit or review PRs, though.