Skip to content

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

@SplinterStan

Description

@SplinterStan

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions