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

Mangled (unbound) type-parameter names in merged declarations #137

Closed
chocolateboy opened this issue Feb 1, 2021 · 1 comment
Closed

Comments

@chocolateboy
Copy link

chocolateboy commented Feb 1, 2021

keywords: alias, dollar, dollars, interface, mangle, mangled, mangling, name, naming, parameter, rename, undeclared

System

  • rollup-plugin-ts: 1.3.8
  • typescript: 4.1.3
  • node: v14.15.4
  • OS: Linux (Arch)

Description

I'm getting unbound type-parameters in a declaration file generated for an index.ts entry which exports types from two modules. The exports have overlapping parameter names but don't reference each other or conflict in any way. Rather than preserving the original type-parameter names, new (undeclared) names are used in the body of the declaration, which results in the following error:

Cannot find name 'T$0'.

The unbound parameter names are of the form <letter><dollar><number>, e.g. T$0, R$0. These names aren't used in the code, and aren't generated for the standalone modules, only for the merged index declaration. I can't reproduce this with tsc, but then it doesn't merge the declarations.

Reproduction

Expected Behavior

interface Foo {
    <T, R>(value: T, fn: (value: T) => R): R;
}

declare const foo: Foo;

interface Bar {
    <T, R>(value: T, fn: (value: T) => R): R;
}

declare const bar: Bar;

export { foo, bar };

Actual Behavior

interface Foo {
    <T, R>(value: T, fn: (value: T) => R): R;
}

declare const foo: Foo;

interface Bar {
    // XXX error: Cannot find name 'T$0'.
    // XXX error: Cannot find name 'R$0'.
    <T, R>(value: T$0, fn: (value: T$0) => R$0): R$0;
}

declare const bar: Bar;

export { foo, bar };

See Also

@wessberg
Copy link
Owner

wessberg commented Apr 13, 2021

Hey there. Thanks for the repro, and sorry for the late follow-up. This problem was caused by the deconflicting layer of the declaration bundler that didn't handle CallSignatureDeclarations. I've added support for nodes of that kind in this commit and it will be published to npm as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants