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