type-plus
Advanced tools
Comparing version 1.34.0 to 1.35.0
@@ -8,1 +8,6 @@ import { IsDisjoint } from './IsDisjoint'; | ||
export declare type BNotA<A extends object, B extends object> = ANotB<B, A>; | ||
export declare type LeftJoin<A extends object, B extends object> = IsSame<A, B> extends true ? never : IsDisjoint<A, B> extends true ? A : { | ||
[k in Exclude<keyof A, keyof B>]: A[k]; | ||
} & { | ||
[k in keyof B]: B[k]; | ||
}; |
{ | ||
"name": "type-plus", | ||
"version": "1.34.0", | ||
"version": "1.35.0", | ||
"description": "Provides additional types for `typescript`.", | ||
@@ -54,13 +54,13 @@ "homepage": "https://github.com/unional/type-plus", | ||
"devDependencies": { | ||
"@commitlint/cli": "^8.3.4", | ||
"@commitlint/cli": "^8.3.5", | ||
"@commitlint/config-conventional": "^8.3.4", | ||
"@size-limit/preset-small-lib": "^3.0.0", | ||
"@unional/devpkg-node": "^1.4.2", | ||
"@size-limit/preset-small-lib": "^4.0.1", | ||
"@unional/devpkg-node": "^1.5.0", | ||
"assertron": "^7.1.2", | ||
"codacy-coverage": "^3.4.0", | ||
"codecov": "^3.6.1", | ||
"codecov": "^3.6.5", | ||
"commitlint-circle": "^1.0.0", | ||
"husky": "^4.0.0", | ||
"semantic-release": "^15.14.0", | ||
"size-limit": "^4.0.0" | ||
"husky": "^4.2.3", | ||
"semantic-release": "^17.0.4", | ||
"size-limit": "^4.0.1" | ||
}, | ||
@@ -67,0 +67,0 @@ "size-limit": [ |
@@ -70,2 +70,3 @@ # type-plus | ||
- `KnownKeys<T>`: extract known (defined) keys from type `T`. | ||
- `LeftJoin<A, B>`: left join `A` with `B` | ||
- `Omit<T, K>`: From `T`, pick a set of properties whose keys are not in the union `K`. This is the opposite of `Pick<T, K>`. | ||
@@ -72,0 +73,0 @@ - `PartialExcept<T, U>`: Deprecated. Same as `PartialOmit<T, U>`. |
@@ -1,2 +0,2 @@ | ||
import { ANotB, assertType, BNotA, IsDisjoint } from '.'; | ||
import { ANotB, assertType, BNotA, IsDisjoint, LeftJoin } from '.'; | ||
@@ -61,1 +61,9 @@ describe('ANotB<A, B>', () => { | ||
}); | ||
describe('LeftJoin', () => { | ||
test('replaces property in A with property in B', () => { | ||
type Orig = { type: 'a' | 'b', value: string } | ||
const actual = {} as LeftJoin<Orig, { value: number }> | ||
assertType<{ type: 'a' | 'b', value: number }>(actual) | ||
}) | ||
}); |
@@ -13,1 +13,10 @@ import { IsDisjoint } from './IsDisjoint'; | ||
export type BNotA<A extends object, B extends object> = ANotB<B, A> | ||
export type LeftJoin<A extends object, B extends object> = | ||
IsSame<A, B> extends true ? never : | ||
IsDisjoint<A, B> extends true ? A : | ||
{ | ||
[k in Exclude<keyof A, keyof B>]: A[k] | ||
} & { | ||
[k in keyof B]: B[k] | ||
} |
130577
2222
191