typescript-yield

Transpiler that helps using the ES6 yield statement in TypeScript today

npm install typescript-yield
8 downloads in the last week
9 downloads in the last month

Transpiler that helps using the ES6 yield statement in TypeScript today. Works well with the suspend library.

Features

  • full type awareness (input params, return value)
  • needs only small d.ts changes (signature overload)
  • simply use yield as a function, with a callback as a last param

Install

npm install typescript-yield

Example

var async = require('suspend').async;

var foo = async(function(param: boolean): boolean {
    return true;
});

var a: boolean = yield(foo(true), resume());

Definition file preparation

  • find all callback and promise async functions
  • refactor callback param value to be function's return value
  • refactor promise generic type to be function's return value

Limitations

  • dont use yield anywhere else in the codebase! (like strings)
npm loves you