0.1.16 #16
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@thilawyn/traitify-ts",
|
"name": "@thilawyn/traitify-ts",
|
||||||
"version": "0.1.15",
|
"version": "0.1.16",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://git.jvalver.de/api/packages/thilawyn/npm/"
|
"registry": "https://git.jvalver.de/api/packages/thilawyn/npm/"
|
||||||
@@ -29,18 +29,18 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"type-fest": "^4.12.0"
|
"type-fest": "^4.13.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"bun-types": "latest",
|
"bun-types": "latest",
|
||||||
"npm-check-updates": "^16.14.15",
|
"npm-check-updates": "^16.14.17",
|
||||||
"npm-sort": "^0.0.4",
|
"npm-sort": "^0.0.4",
|
||||||
"rollup": "^4.12.1",
|
"rollup": "^4.13.0",
|
||||||
"rollup-plugin-cleanup": "^3.2.1",
|
"rollup-plugin-cleanup": "^3.2.1",
|
||||||
"rollup-plugin-ts": "^3.4.5",
|
"rollup-plugin-ts": "^3.4.5",
|
||||||
"tsx": "^4.7.1",
|
"tsx": "^4.7.1",
|
||||||
"typescript": "^5.4.2"
|
"typescript": "^5.4.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AbstractClass, Simplify } from "type-fest"
|
import { AbstractClass, Class, Simplify } from "type-fest"
|
||||||
import { Trait } from "./Trait"
|
import { Trait } from "./Trait"
|
||||||
import { TraitExpression } from "./TraitExpression"
|
import { TraitExpression } from "./TraitExpression"
|
||||||
import { Extend, StaticMembers } from "./util"
|
import { Extend, StaticMembers } from "./util"
|
||||||
@@ -128,6 +128,40 @@ export type ImplStatic<
|
|||||||
>
|
>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
export function implStaticThis<
|
||||||
|
ImplClass extends AbstractClass<object> & { readonly [implSuperSymbol]: true },
|
||||||
|
This extends AbstractClass<object>,
|
||||||
|
>(
|
||||||
|
_Impl: ImplClass,
|
||||||
|
thisArg: This,
|
||||||
|
) {
|
||||||
|
return thisArg as unknown as (
|
||||||
|
AbstractClass<
|
||||||
|
InstanceType<ImplClass> & InstanceType<This>,
|
||||||
|
ConstructorParameters<This>
|
||||||
|
> &
|
||||||
|
ImplStatic<ImplClass> &
|
||||||
|
StaticMembers<This>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function implStaticInstantiableThis<
|
||||||
|
ImplClass extends AbstractClass<object> & { readonly [implSuperSymbol]: true },
|
||||||
|
This extends Class<object>,
|
||||||
|
>(
|
||||||
|
_Impl: ImplClass,
|
||||||
|
thisArg: This,
|
||||||
|
) {
|
||||||
|
return thisArg as unknown as (
|
||||||
|
Class<
|
||||||
|
InstanceType<ImplClass> & InstanceType<This>,
|
||||||
|
ConstructorParameters<This>
|
||||||
|
> &
|
||||||
|
ImplStatic<ImplClass> &
|
||||||
|
StaticMembers<This>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const trait = new TraitBuilder(
|
export const trait = new TraitBuilder(
|
||||||
new TraitExpression(TraitExpression.NullSuperclass, []),
|
new TraitExpression(TraitExpression.NullSuperclass, []),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export { Trait, TraitClass, TraitConcreteClass, TraitInstance, TraitStaticMembers, TraitTuple } from "./Trait"
|
export { Trait, TraitClass, TraitConcreteClass, TraitInstance, TraitStaticMembers, TraitTuple } from "./Trait"
|
||||||
export { ImplStatic, TraitBuilder, trait } from "./TraitBuilder"
|
export { ImplStatic, TraitBuilder, implStaticInstantiableThis, implStaticThis, trait } from "./TraitBuilder"
|
||||||
export { Implements, StaticImplements, TraitExpression, TraitExpressionClass, TraitExpressionConcreteClass, TraitExpressionInstance, TraitExpressionStaticMembers } from "./TraitExpression"
|
export { Implements, StaticImplements, TraitExpression, TraitExpressionClass, TraitExpressionConcreteClass, TraitExpressionInstance, TraitExpressionStaticMembers } from "./TraitExpression"
|
||||||
export { TraitExpressionBuilder, expression } from "./TraitExpressionBuilder"
|
export { TraitExpressionBuilder, expression } from "./TraitExpressionBuilder"
|
||||||
|
|||||||
@@ -28,6 +28,15 @@ const Identifiable = <ID>() => trait
|
|||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
const ImplementsIdentifiable = <ID>(defaultID: ID) => expression
|
||||||
|
.expresses(Identifiable<ID>())
|
||||||
|
.build()
|
||||||
|
.subtrait()
|
||||||
|
.implement(Super => class ImplementsIdentifiable extends Super {
|
||||||
|
readonly id = defaultID
|
||||||
|
})
|
||||||
|
.build()
|
||||||
|
|
||||||
const StatefulSubscription = trait
|
const StatefulSubscription = trait
|
||||||
.abstract(Super => class extends Super {
|
.abstract(Super => class extends Super {
|
||||||
declare readonly isStatefulSubscription: true
|
declare readonly isStatefulSubscription: true
|
||||||
|
|||||||
Reference in New Issue
Block a user