typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

Update “Declaration emit” in README progress table

Open controversial opened this issue 6 months ago • 5 comments

Follow up to update the README now that #791 is merged!

I tried to write notes based on the TODOs in the PR but please correct me if I’m misrepresenting the status of this feature.

controversial avatar May 29 '25 15:05 controversial

Actually, it seems like declaration support for JS files / JSDoc is working; a fresh build of tsgo transforms this .js file

/**
 * @param {number} a
 * @param {number} b
 */
export function func1(a, b) {
    return a + b;
}
export function func2() {
    const a = 1;
    return a;
}

into this .d.ts file:

/**
 * @param {number} a
 * @param {number} b
 */
export declare function func1(a: number, b: number): number;
export declare function func2(): unknown;

so maybe I’m misinterpreting

  • [ ] JS declaration emit support (will need to be substantively rewritten given different upfront parsing and checking of JSDoc structures - likely for the better)

controversial avatar May 29 '25 16:05 controversial

The new codebase uses an all-new method to handle JSDoc where we actually rewrite the AST during parse to inject type nodes where TS files would have them, so some JS stuff is likely to "just work" without any other work. But, not everything works with that method.

jakebailey avatar May 29 '25 16:05 jakebailey

It's not incorrect; it's definitely not thoroughly tested. We're not even claiming JS/JSDoc is done, so it would be weird to say that its declaration emit is already done.

jakebailey avatar May 29 '25 16:05 jakebailey

got it, awesome!

I did notice that tsgo emits export declare function statements for that .js file, where tsc emitted plain export function statements (but both use export declare in declarations for typescript source files)

controversial avatar May 29 '25 16:05 controversial

We're not even claiming JS/JSDoc is done, so it would be weird to say that its declaration emit is already done

I removed the part of the note that makes claims about JS/JSDoc for now, since it seems untrue that it doesn’t work.

it's definitely not thoroughly tested

Understand if you want to hold off on making claims about declaration emit in the status table until there’s been more thorough testing! Excited about the progress here.

controversial avatar May 29 '25 16:05 controversial