Skip to content

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

Closed
@timocov

Description

@timocov

TypeScript Version: typescript@3.4.0-dev.20190326

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions