### Install compatfactory with npm Source: https://github.com/wessberg/compatfactory/blob/master/README.md Install the compatfactory package using npm. ```bash $ npm install compatfactory ``` -------------------------------- ### Install compatfactory with pnpm Source: https://github.com/wessberg/compatfactory/blob/master/README.md Install the compatfactory package using pnpm. ```bash $ pnpm add compatfactory ``` -------------------------------- ### Install compatfactory with Yarn Source: https://github.com/wessberg/compatfactory/blob/master/README.md Install the compatfactory package using Yarn. ```bash $ yarn add compatfactory ``` -------------------------------- ### Using ensureNodeFactory in a Custom Transformer Source: https://github.com/wessberg/compatfactory/blob/master/README.md Example of using ensureNodeFactory inside a Custom Transformer context to handle both modern and legacy TypeScript APIs. ```ts import {ensureNodeFactory} from "compatfactory"; import type TS from "typescript"; function getCustomTransformers(typescript: typeof TS): TS.CustomTransformers { return { before: [ context => { const factory = ensureNodeFactory(context.factory ?? typescript); return sourceFile => { return factory.updateSourceFile( sourceFile // ... ); }; } ] }; } ``` -------------------------------- ### Basic usage of ensureNodeFactory Source: https://github.com/wessberg/compatfactory/blob/master/README.md Basic usage of ensureNodeFactory to obtain a Node Factory that works with the TypeScript API. ```ts import {ensureNodeFactory} from "compatfactory"; // Will use typescript.factory if available, and otherwise return an object that wraps typescript's helper functions // but makes them conform with the Node Factory API const factory = ensureNodeFactory(typescript); factory.createClassDeclaration(/* ... */); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.