{"id":26556,"library":"typescript-yield","title":"typescript-yield","description":"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.","status":"deprecated","version":"0.1.2","language":"javascript","source_language":"en","source_url":"git@github.com:TobiaszCudnik/typescript-yield","tags":["javascript","typescript","yield","generators","async"],"install":[{"cmd":"npm install typescript-yield","lang":"bash","label":"npm"},{"cmd":"yarn add typescript-yield","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript-yield","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The tool operates as a transpiler, not a runtime library. The 'yield' function is injected during transpilation.","wrong":"import { yield } from 'typescript-yield'","symbol":"yield","correct":"No import needed; transpiler processes files globally"},{"note":"The 'async' wrapper comes from the 'suspend' library, not from typescript-yield.","wrong":"import { async } from 'typescript-yield'","symbol":"async","correct":"import { async } from 'suspend'"},{"note":"'resume' is a helper function injected by the transpiler.","wrong":"import { resume } from 'typescript-yield'","symbol":"resume","correct":"No explicit import; provided by the transpiler"}],"quickstart":{"code":"// Install: npm install typescript-yield suspend\n// Prepare a TypeScript file (e.g., src/example.ts):\n/// <reference path='../node_modules/typescript-yield/...' />\n\nvar async = require('suspend').async;\n\nvar foo = async(function(param: boolean): boolean {\n    return true;\n});\n\nvar a: boolean = yield(foo(true), resume());\n\n// Transpile: npx ts-yield -o build src/**.ts\n// Then compile with tsc\n","lang":"typescript","description":"Shows how to use typescript-yield with the suspend library: define async function with callback, then use yield and resume."},"warnings":[{"fix":"Prefer native async/await or TypeScript's built-in generator support (function*).","message":"typescript-yield is no longer maintained; use async/await or TypeScript generators.","severity":"deprecated","affected_versions":"all"},{"fix":"Avoid using 'yield' outside of the transpiler context; rename variables or use alternative wording.","message":"The word 'yield' cannot be used anywhere else in the codebase (e.g., in strings or as a variable name).","severity":"gotcha","affected_versions":"all"},{"fix":"Always work on a copy of your files, or version-control before running the transpiler.","message":"The transpiler modifies TypeScript source files in-place; no backup is created by default.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure all async calls follow the exact yield + resume pattern as shown in documentation.","message":"The tool expects a specific pattern: yield(func(args...), resume()). Other patterns may not transpile correctly.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'ts-yield' on your source files before compilation. 'yield' is only available after transpilation.","cause":"Trying to call 'yield' at runtime without transpiling first.","error":"TypeError: yield is not a function"},{"fix":"Add a type declaration for 'yield' (e.g., declare function yield(...args: any[]): any;) or run the transpiler before tsc.","cause":"TypeScript compiler doesn't recognize 'yield' as a function.","error":"error TS2304: Cannot find name 'yield'"},{"fix":"Manually adjust the return type annotation on the async function, or ensure the transpiler output functions have correct signatures.","cause":"The async function's return type is not inferred correctly after transpilation.","error":"error TS2322: Type 'void' is not assignable to type 'boolean'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}