machty / ember-concurrency

ember-concurrency is an Ember Addon that enables you to write concise, worry-free, cancelable, restartable, asynchronous tasks.
http://ember-concurrency.com
MIT License
690 stars 157 forks source link

add types definitions that also support ember-concurrency-decorators #355

Closed NullVoxPopuli closed 4 years ago

NullVoxPopuli commented 4 years ago

After initial review


Huge thanks to @buschtoens for the work done in https://github.com/machty/ember-concurrency/pull/319

these types enable the following, given these helper functions:

import Task from 'ember-concurrency/task';

type ECTask<Args extends Array<any>, Return> = (
  ...args: Args
) => Generator<any /* potentially yielded types */, Return, unknown>;

export function taskFor<Args extends any[], Return = void>(generatorFn: ECTask<Args, Return>) {
  return (generatorFn as any) as Task<Args, Return>;
}

we can have inferred types from ember-concurrency-decorators! image

image

NullVoxPopuli commented 4 years ago

Could you provide some details on what's different here versus #319?

the main difference is that I've added some generics that help with type inference with decorators (see screenshots in original comment)

Does it address feedback raised there?

nope, I need to look at that

Are there TypeScript version considerations?

no clue, I'm only using 3.7.x in my apps

Is there a way to test/validate these (something that could be thrown in CI)?

yea - we could build this in to the repo with full ember apps that aren't the dummy app, and try to use all of the APIs and make sure there are no type errors?

maxfierke commented 4 years ago

Thanks so much for your work on this! However, we're closing this in favor of #357, which has been merged and will be part of 1.2.0