Registry / type-stubs / typescript-yield

typescript-yield

JSON →
library0.1.2jsnpmunverified

A transpiler that enables use of ES6 yield statements in TypeScript before native support was available. Version 0.1.2 is a proof-of-concept with limited documentation. It transforms yield-based async patterns (often used with the 'suspend' library) into plain JavaScript. The tool requires manual preparation of type definition files and forbids the use of 'yield' anywhere else in the codebase. It has been largely superseded by native async/await and TypeScript's built-in generator support. Not recommended for new projects.

npm install typescript-yield
INSTALL
IMPORT
SIG · TYPESCRIPT-YIELD
T
typescript-yield
type-stubsjavascriptv0.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

yield
No import needed; transpiler processes files globally
import { yield } from 'typescript-yield'
The tool operates as a transpiler, not a runtime library. The 'yield' function is injected during transpilation.
async
import { async } from 'suspend'
import { async } from 'typescript-yield'
The 'async' wrapper comes from the 'suspend' library, not from typescript-yield.
resume
No explicit import; provided by the transpiler
import { resume } from 'typescript-yield'
'resume' is a helper function injected by the transpiler.

Shows how to use typescript-yield with the suspend library: define async function with callback, then use yield and resume.

// Install: npm install typescript-yield suspend // Prepare a TypeScript file (e.g., src/example.ts): /// <reference path='../node_modules/typescript-yield/...' /> var async = require('suspend').async; var foo = async(function(param: boolean): boolean { return true; }); var a: boolean = yield(foo(true), resume()); // Transpile: npx ts-yield -o build src/**.ts // Then compile with tsc
yield --version
Debug
Known issues
deprecatedtypescript-yield is no longer maintained; use async/await or TypeScript generators.
fix
Prefer native async/await or TypeScript's built-in generator support (function*).
affects: all
gotchaThe word 'yield' cannot be used anywhere else in the codebase (e.g., in strings or as a variable name).
fix
Avoid using 'yield' outside of the transpiler context; rename variables or use alternative wording.
affects: all
gotchaThe transpiler modifies TypeScript source files in-place; no backup is created by default.
fix
Always work on a copy of your files, or version-control before running the transpiler.
affects: all
breakingThe tool expects a specific pattern: yield(func(args...), resume()). Other patterns may not transpile correctly.
fix
Ensure all async calls follow the exact yield + resume pattern as shown in documentation.
affects: all
Errors
Common errors & fixes
TypeError: yield is not a function
Trying to call 'yield' at runtime without transpiling first.
fix
Run 'ts-yield' on your source files before compilation. 'yield' is only available after transpilation.
error TS2304: Cannot find name 'yield'
TypeScript compiler doesn't recognize 'yield' as a function.
fix
Add a type declaration for 'yield' (e.g., declare function yield(...args: any[]): any;) or run the transpiler before tsc.
error TS2322: Type 'void' is not assignable to type 'boolean'
The async function's return type is not inferred correctly after transpilation.
fix
Manually adjust the return type annotation on the async function, or ensure the transpiler output functions have correct signatures.
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
22
OpenAI (training)
1
Resources
typescript-yield — npm install typescript-yield · libregistry