diff --git a/src/tersible.spec.ts b/src/tersible.spec.ts index 24688c6..9fe4041 100644 --- a/src/tersible.spec.ts +++ b/src/tersible.spec.ts @@ -19,7 +19,7 @@ test('inject to class', t => { return `a = ${this.a}` }) - let f = new Foo() as Foo & Tersible + let f = new Foo() as Tersible t.is(f.tersify(), 'a = 1') f.a = 2 diff --git a/src/tersible.ts b/src/tersible.ts index ab90975..5b60345 100644 --- a/src/tersible.ts +++ b/src/tersible.ts @@ -1,4 +1,4 @@ -export interface Tersible { +export type Tersible = T & { tersify(): string } @@ -29,7 +29,7 @@ export function Tersiblized {}>(Base: C, tersi * but it cannot be done otherwise. * How can I "clone" a function or class? */ -export function tersible(subject: T, tersify: (this: T) => string): T & Tersible { +export function tersible(subject: T, tersify: (this: T) => string): Tersible { return Object.assign( subject, { @@ -38,6 +38,6 @@ export function tersible(subject: T, tersify: (this: T) => string): T & Tersi ) } -export function isTersible(obj): obj is Tersible { - return typeof obj.tersify === 'function' +export function isTersible(obj: T): obj is Tersible { + return typeof obj['tersify'] === 'function' }