Skip to content

Conversation

@runspired
Copy link
Contributor

@runspired runspired commented Aug 18, 2025

very borked, mostly a skratchpad for toying around with the types. Best I can tell there's no path to typing generator functions adequately, we'll want to compile similar to ember-concurrency.

I would update the compiler semantics though to make it more of a direct sugar overtop of generator functions. Something like this, though perhaps we can setup generator-transforms to understand a few functions whose arguments should be considered to be generators.

import { task } from '@warp-drive/experiments/task';
import { _f, _yield, _yieldX } from 'generator-transforms';

const task = createTask(_f(async function doThing() {
  // not yielded
  const result = await otherThing();
  // yield
  const state = await _yield(doStillMore());
  // yield*
  const moreState = await _yieldX(stuff());
}));
const task = createTask(function* doThing() {
  const state1 = yield doStillMore();
  const state2 = yield* stuff();
});

const task2 = createTask(async function* doAsyncThing() {
  const result = await otherThing();
  const state1 = yield doStillMore(result);
  const state2 = yield* stuff();
});
@localResource('my-key')
class MyComponent extends Component {
  @property isExpanded = false;
  
  @signal myTask = null;
  
  update = () => { this.myTask = myTask(); }
  
  <template></template>
}

Related: microsoft/TypeScript#42033

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants