Skip to content

TS4078 brings for destructured varaible, but not for just variable #30598

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

Closed
timocov opened this issue Mar 26, 2019 · 0 comments · Fixed by #48869
Closed

TS4078 brings for destructured varaible, but not for just variable #30598

timocov opened this issue Mar 26, 2019 · 0 comments · Fixed by #48869
Labels
Bug A bug in TypeScript
Milestone

Comments

@timocov
Copy link
Contributor

timocov commented Mar 26, 2019

TypeScript Version: [email protected]

Search Terms: "declaration emit", "has or is using private name"

Code

const a = 123;
const { b } = { b: 123 };

export function foo(
    d: typeof a, // no error
    e: typeof b // error TS4078: Parameter 'e' of exported function has or is using private name 'b'.
): void {}

./node_modules/.bin/tsc --declaration true

Expected behavior:

Error for both d and e args.

Actual behavior:

Error for e arg only.

Related Issues: #23127, #22798, #20080, #5284

If I comment e: typeof b and const { b } = { b: 123 } then this may produce runtime error as soon all members from declaration file can be imported (but there is no export with name a), but it looks like export {}; statement does something that disabled it, right? Could you please point what does it mean for TypeScript (link or description)? (I found only one mention in handbook, but it says about "exports nothing" only). When I should use it when write declaration by myself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
2 participants