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