Rich-Harris / dts-buddy

WORK IN PROGRESS DO NOT USE
MIT License
317 stars 12 forks source link

dts-buddy exposes private types #81

Closed dummdidumm closed 4 months ago

dummdidumm commented 5 months ago

dts-buddy creates code like this:

declare module "x" {
  type Foo = ..;
  export type Bar = { foo: Foo }
}

...in hopes that Foo is private. But that's not how declare module works, every definition inside it is automatically exposed (don't ask me why ...). As a consequence, internal types that shouldn't be revealed are exposed.

We should see how we can fix this. Maybe it's possible to move the private type definitions outside of the declare module in a way that still keeps the file as a whole ambient. Doing so should happen in a major because it's a breaking change downstream for projects.

dummdidumm commented 4 months ago

Fixed by #82