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

Add PackageJson and LiteralUnion types #5

Merged
merged 13 commits into from
Mar 15, 2019
14 changes: 14 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import * as Npm from './npm';

export {Npm};

// TODO: Add more examples

// TODO: This can just be `export type Primitive = not object` when the `not` keyword is out.
Expand Down Expand Up @@ -84,3 +88,13 @@ const ab: Merge<Foo, Bar> = {a: 1, b: 2};
```
*/
export type Merge<FirstType, SecondType> = Omit<FirstType, Extract<keyof FirstType, keyof SecondType>> & SecondType;

/**
This type is a workaround for the TypeScript issue https:/Microsoft/TypeScript/issues/29729.

BendingBender marked this conversation as resolved.
Show resolved Hide resolved
It will be removed as soon as it's not needed any more.
*/
export type LiteralUnion<
LiteralType extends BaseType,
BaseType extends Primitive
> = LiteralType | (BaseType & {_?: never});
1 change: 1 addition & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable import/no-unassigned-import */
import './test/omit';
import './test/merge';
import './test/npm';

// TODO: Add negative tests. Blocked by: https:/SamVerschueren/tsd-check/issues/2
Loading