Skip to content

It's very easy to accidentally release libs with missing types #13

Description

@mike-north

When certain TS errors are encountered while compiling a module, the /dist/types/*.d.ts file may omit interfaces, or be missing entirely. Neither npm run-script problems or npm test ends up catching this, making it very easy to release broken library versions.

To reproduce:

  1. Create a new library from the libkit blueprint
  2. Put this at the top of /src/index.ts
type WithHello<T> = T & { hello: 'world' };

export interface Foo {
  name: string;
}
export interface Bar extends WithHello<Foo> {}

export const x: Bar = {
  hello: 'world',
  name: 'libkit'
};
  1. Run npm run-script problems & npm run-script build (note it exits successfully)
  2. Check the contents of /dist/types. It will be empty
  3. Change /src/index.ts
- type WithHello<T> = T & { hello: 'world' };
+ export type WithHello<T> = T & { hello: 'world' };
  1. Run npm run-script problems & npm run-script build (note it exits successfully)
  2. Check the contents of /dist/types. It will contain the appropriate interfaces/types

This particular TS error is more likely to slip through -- it won't cause tests to fail. I suggest we either make npm run-script problems detect this kind of thing, or hard fail in the presence of any error that could result in incomplete output.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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