This commit is contained in:
@@ -2,7 +2,7 @@ import { TraitClass } from "./Trait"
|
|||||||
import { trait } from "./TraitBuilder"
|
import { trait } from "./TraitBuilder"
|
||||||
import { Implements, ImplementsStatic, TraitExpressionClass } from "./TraitExpression"
|
import { Implements, ImplementsStatic, TraitExpressionClass } from "./TraitExpression"
|
||||||
import { expression } from "./TraitExpressionBuilder"
|
import { expression } from "./TraitExpressionBuilder"
|
||||||
import { Extendable } from "./util"
|
import { Extendable, NonExtendableKeys } from "./util"
|
||||||
|
|
||||||
|
|
||||||
const PrintsHelloOnNew = trait
|
const PrintsHelloOnNew = trait
|
||||||
@@ -84,7 +84,7 @@ class User extends exp.extends implements Implements<typeof exp> {
|
|||||||
console.log(new User())
|
console.log(new User())
|
||||||
|
|
||||||
|
|
||||||
type T = Extendable<[
|
type T = NonExtendableKeys<[
|
||||||
{ prout: string },
|
{ prout: string },
|
||||||
{ prout: "gneugneu" },
|
{ prout: "gneugneu" },
|
||||||
]>
|
]>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export type Extend<T extends readonly object[]> = (
|
|||||||
T extends [
|
T extends [
|
||||||
infer Super,
|
infer Super,
|
||||||
infer Self,
|
infer Self,
|
||||||
...infer Rest extends object[]
|
...infer Rest extends object[],
|
||||||
]
|
]
|
||||||
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
||||||
? Extend<[
|
? Extend<[
|
||||||
@@ -39,13 +39,13 @@ export type Extend<T extends readonly object[]> = (
|
|||||||
|
|
||||||
export type Extendable<T extends readonly object[]> = (
|
export type Extendable<T extends readonly object[]> = (
|
||||||
T extends [
|
T extends [
|
||||||
infer Super extends object,
|
infer Super,
|
||||||
infer Self extends object,
|
infer Self,
|
||||||
...infer Rest extends object[],
|
...infer Rest extends object[],
|
||||||
]
|
]
|
||||||
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
? Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
|
||||||
? Extendable<[
|
? Extendable<[
|
||||||
Super & Self,
|
Omit<Super, CommonKeys<Self, Super>> & Self,
|
||||||
...Rest,
|
...Rest,
|
||||||
]>
|
]>
|
||||||
: false
|
: false
|
||||||
@@ -53,7 +53,19 @@ export type Extendable<T extends readonly object[]> = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
export type NonExtendableKeys<T extends readonly object[]> = (
|
export type NonExtendableKeys<T extends readonly object[]> = (
|
||||||
Extendable<T> extends false
|
T extends [
|
||||||
? {}
|
infer Super extends object,
|
||||||
: never
|
infer Self extends object,
|
||||||
|
...infer Rest extends object[],
|
||||||
|
]
|
||||||
|
? {
|
||||||
|
[K in keyof Super & keyof Self]: Self[K] extends Super[K]
|
||||||
|
? never
|
||||||
|
: K
|
||||||
|
}[keyof Super & keyof Self]
|
||||||
|
| NonExtendableKeys<[
|
||||||
|
Super & Self,
|
||||||
|
...Rest,
|
||||||
|
]>
|
||||||
|
: void
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user