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

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

Open
mike-north opened this issue Jul 27, 2018 · 0 comments
Open

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

mike-north opened this issue Jul 27, 2018 · 0 comments

Comments

@mike-north
Copy link

mike-north commented Jul 27, 2018

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.

@mike-north mike-north changed the title It's very easy to accidentally release libs with missing .d.ts It's very easy to accidentally release libs with missing types Jul 27, 2018
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