Skip to content

Latest commit

 

History

History
69 lines (50 loc) · 2.67 KB

CONTRIBUTING.md

File metadata and controls

69 lines (50 loc) · 2.67 KB

Contributing

All contributions to ts-essentials are welcomed.

Do you have idea for a new type? Please, first submit a GitHub issue (or send me PM) and describe your proposal.

Conventions

To follow ts-essentials conventions, please check CONVENTIONS.md. Anything missing or something is unclear? Don't hesitate to suggest it in a GitHub issue and please don't forget to add the convention label.

Adding new types

  • lib/functions — functions that incur some runtime overhead
  • Other folders (e.g. lib/merge) — pure types, with 0 runtime overhead

Please make sure to add:

  • StrictOmit<Type, Keys> - Constructs a type by picking all properties from Type and then removing Keys. This is stricter version of Omit
  • Documentation with short examples and link to TS Playground in lib/<type-name>/README.md, e.g.

StrictOmit<Type, Keys> constructs a type by picking all properties from Type and then removing Keys

interface CatInfo {
  age: number;
  breed: string;
}

type CatInfoWithoutBreed = StrictOmit<CatInfo, "breed">;
//   ^? { age: number }

This is stricter version of Omit, meaning StrictOmit validates that properties Keys exist in type Type

// error: Type '"height"' does not satisfy the constraint 'keyof CatInfo'
type CatInfoWithoutHeight = StrictOmit<CatInfo, "height">;

// error: Type '"age" | "weight"' does not satisfy the constraint 'keyof CatInfo'
// Type '"weight"' is not assignable to type 'keyof CatInfo'
type CatInfoWithoutAgeAndWeight = StrictOmit<CatInfo, "age" | "weight">;

TS Playground – https://tsplay.dev/N9jPjm

When you're done with your changes:

  • use yarn test:fix to run prettier to reformat code

  • use yarn test to make sure that there are no compilation errors

  • use yarn changeset to create changelog with meaningful description as it will be visible in Releases, e.g.

Add StrictOmit<Type, Keys>, a stricter version of Omit. It validates that properties Keys exist in type Type

To see examples of merged PRs for Releases, use this link 🔗

Thanks! 🙏🏻