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.
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.
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:
- Short description of what new type does in README.md > API, e.g.
StrictOmit<Type, Keys>
- Constructs a type by picking all properties fromType
and then removingKeys
. This is stricter version ofOmit
- 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 fromType
and then removingKeys
interface CatInfo { age: number; breed: string; } type CatInfoWithoutBreed = StrictOmit<CatInfo, "breed">; // ^? { age: number }This is stricter version of
Omit
, meaningStrictOmit
validates that propertiesKeys
exist in typeType
// 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
- Tests for new type in
lib/<type-name>.ts
, e.g.test/strict-omit.ts
When you're done with your changes:
-
use
yarn test:fix
to runprettier
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 ofOmit
. It validates that propertiesKeys
exist in typeType
To see examples of merged PRs for Releases, use this link 🔗
Thanks! 🙏🏻