diff --git a/addon/index.d.ts b/addon/index.d.ts index 97f0ef505..71e835ba7 100644 --- a/addon/index.d.ts +++ b/addon/index.d.ts @@ -1,3 +1,4 @@ +import EmberObject from '@ember/object'; import ComputedProperty from '@ember/object/computed'; export type TaskGenerator = Generator; @@ -29,7 +30,7 @@ export type EncapsulatedTaskDescriptorReturnType { +export interface Task extends EmberObject { /** * `true` if any current task instances are running. */ @@ -141,7 +142,7 @@ export interface Task { * }); * ``` */ -export interface TaskGroup { +export interface TaskGroup extends EmberObject { /** * `true` if any current task instances are running. */ @@ -234,7 +235,7 @@ export interface TaskGroup { * because concurrency policy enforced by a * {@linkcode TaskProperty Task Modifier} canceled the task instance. */ -export interface TaskInstance extends Promise { +export interface TaskInstance extends Promise, EmberObject { /** * If this TaskInstance runs to completion by returning a property * other than a rejecting promise, this property will be set diff --git a/tests/types/ember-concurrency-test.ts b/tests/types/ember-concurrency-test.ts index 4b56b6283..8d6fe1917 100644 --- a/tests/types/ember-concurrency-test.ts +++ b/tests/types/ember-concurrency-test.ts @@ -112,6 +112,12 @@ module('unit tests', () => { expect(t.lastIncomplete).toEqualTypeOf(); expect(t.performCount).toBeNumber(); + expect(t.get).toBeCallableWith('isRunning'); + expect(t.get('isRunning')).toBeBoolean(); + + // @ts-expect-error + t.get('nonexistentProperty'); + expect(t.cancelAll).toBeCallableWith(); expect(t.cancelAll).toBeCallableWith({}); expect(t.cancelAll).toBeCallableWith({ reason: 'why do you care' }); @@ -168,6 +174,12 @@ module('unit tests', () => { expect(tg.lastIncomplete).toEqualTypeOf(); expect(tg.performCount).toBeNumber(); + expect(tg.get).toBeCallableWith('isRunning'); + expect(tg.get('isRunning')).toEqualTypeOf() + + // @ts-expect-error + tg.get('nonexistentProperty'); + expect(tg.cancelAll).toBeCallableWith(); expect(tg.cancelAll).toBeCallableWith({}); expect(tg.cancelAll).toBeCallableWith({ reason: 'why do you care' }); @@ -206,6 +218,12 @@ module('unit tests', () => { expect(t.state).toEqualTypeOf<'dropped' | 'canceled' | 'finished' | 'running' | 'waiting'>(); expect(t.isDropped).toBeBoolean(); + expect(t.get).toBeCallableWith('value'); + expect(t.get('value')).toEqualTypeOf() + + // @ts-expect-error + t.get('nonexistentProperty'); + expect(t.cancel).toBeCallableWith(); expect(t.cancel).toBeCallableWith('why do you care'); expect(t.cancel).parameters.toEqualTypeOf<[string?]>();