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

@segment/facade: Remove module augmentation (declare module) in type declaration file #192

Open
SplinterStan opened this issue Sep 19, 2024 · 0 comments

Comments

@SplinterStan
Copy link

General info

  • Package: @segment/facade
  • version: 3.4.10

Current state

  • Currently, the @segment/facade package is referring to type definitions inside its index.d.ts.
  • Those type definitions are being declared inside an augmented module via declare module ...:
declare module '@segment/facade' {
  interface Options {
    clone?: boolean;
    traverse?: boolean;
  }
  export class Facade<T = { [key: string]: any }> {
    constructor(object: { [key: string]: any }, options?: Options);
    ...
  }
  ...
}

Issue

  • When generating type defintions for a consumer of segment it is impossible for the compiler to get exported members of the @segment/facade module, which results in an error: "Facade" is not exported by "node_modules/@segment/facade/index.d.ts", imported by "node_modules/@segment/analytics-next/dist/types/lib/to-facade.d.ts".
  • btw.: this is the only @segment/... module that is using augmentation in type definitions.

Proposition

  1. Remove the wrapping module augmentation declare module... as it's not really needed as the types can be easily imported by using the module's name @segment/facade declared in package.json.
  2. Add export modifier to the Options interface declaration, so that is can be consumed from outside:
export interface Options {
    clone?: boolean;
    traverse?: boolean;
}
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

1 participant