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

emit-dts fails with private function in class that is typed with non explicitly typed const #10034

Closed
menny opened this issue Feb 14, 2025 · 0 comments · Fixed by #10037
Closed
Assignees
Labels
Milestone

Comments

@menny
Copy link

menny commented Feb 14, 2025

Describe the bug

emit dts fails on non-exported expressions which are part of an exported class.
This fails with swc: playground
but passes with tsc: playground

Input code

const A_SYMBOL = Symbol("A_SYMBOL");
const func = () => null;

export class SomeClass {
    private func(
            queryFingerprint: string,
            onStale: () => void
        ): null | typeof A_SYMBOL {
            return null;
    };
    
    private func2(
            queryFingerprint: string,
            onStale: () => void
        ): null | typeof func {
            return null;
    };
}

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": true
    },
    "experimental": {
        "emitIsolatedDts": true
    }
  },
  "sourceMaps": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.10.16&code=H4sIAAAAAAAAA7WQMQ%2BCMBCF9%2F6KixMkTo4QTNTESePQyclgPQhJabFciQT579YKGuLg5C3v8vru%2BrVCq5pgdeLH%2FfqwgwR4W561DGajNQtjJnwos0q4QBBCsgRlpYwZw1ulDYGQaV0D1yVufNcxcFWZokkJ%2FWDgnbGuFk27LVSOxoUURVCT03w%2BSWnFKZUYDVc2uri8z8PII8AdqK1QZ58ndJMdBskaNeA%2Bjf4lX4CLvxP6%2F%2FtN17MHmuP435QBAAA%3D&config=H4sIAAAAAAAAA1WMOQ6AMAwEe14RueYF1DQUPCIKLoI4LNtIQYi%2FY64Iut0Z7W6Fc9BLgMptFq2QZ0HO3Yisk%2FpkBHQllMCRFMrXqpxKecGL7LcATIQcR7Tp8Dk7zRi1kXnwil2t8hsXzwHIvHDA1lP2%2BwE5e0RDqwAAAA%3D%3D

SWC Info output

x TS9010: Variable must have an explicit type annotation with --isolatedDeclarations.
,-[input.tsx:1:1]
1 | const A_SYMBOL = Symbol("A_SYMBOL");
: ^^^^^^^^
2 | const func = () => null;
3 |
4 | export class SomeClass {
---- x TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. ,-[input.tsx:2:1] 1 | const A_SYMBOL = Symbol("A_SYMBOL"); 2 | const func = () => null; : ^^^^^^^ 3 | 4 | export class SomeClass { 5 | private func( ----

Expected behavior

shoud emit this dts:

export declare class SomeClass {
    private func;
    private func2;
}

Actual behavior

Fails to output dts

Version

1.10.16

Additional context

No response

@menny menny added the C-bug label Feb 14, 2025
@CPunisher CPunisher self-assigned this Feb 14, 2025
@kdy1 kdy1 added this to the Planned milestone Feb 14, 2025
@kdy1 kdy1 closed this as completed in 8410b59 Feb 15, 2025
@kdy1 kdy1 modified the milestones: Planned, v1.10.17 Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants