### Install ts-migrate-server via package managers Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-server/README.md Instructions for installing the migration runner as a development dependency using npm or yarn. ```bash npm install --save-dev ts-migrate-server ``` ```bash yarn add --dev ts-migrate-server ``` -------------------------------- ### Install ts-migrate-plugins using npm or yarn Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-plugins/README.md Instructions for installing the ts-migrate-plugins package as a development dependency using either npm or yarn. ```bash npm install --save-dev ts-migrate-plugins ``` ```bash yarn add --dev ts-migrate-plugins ``` -------------------------------- ### Run ts-migrate with ts-ignore plugin Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-plugins/README.md Example of how to use the ts-migrate server to run a migration with the ts-ignore plugin. This code imports necessary modules, sets up the migration configuration with the ts-ignore plugin, and executes the migration process. ```typescript import path from 'path'; import { tsIgnorePlugin } from 'ts-migrate-plugins'; import { migrate, MigrateConfig } from 'ts-migrate-server'; // get input files folder const inputDir = path.resolve(__dirname, 'input'); // create new migration config and add ts-ignore plugin with empty options const config = new MigrateConfig().addPlugin(tsIgnorePlugin, {}); // run migration const exitCode = await migrate({ rootDir: inputDir, config }); process.exit(exitCode); ``` -------------------------------- ### Code Transformation Example Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-example/README.md Demonstrates the input JavaScript function and the resulting TypeScript output after applying custom migration plugins. The transformation includes identifier reversal, logging injection, and type annotation. ```javascript function mult(first, second) { return first * second; } ``` ```typescript function tlum(tsrif: number, dnoces: number): number { console.log(`args: ${arguments}`) return tsrif * dnoces; } ``` -------------------------------- ### Install ts-migrate using npm or yarn Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate/README.md Instructions for installing the ts-migrate package as a development dependency using either npm or yarn package managers. ```bash npm install --save-dev ts-migrate ``` ```bash yarn add --dev ts-migrate ``` -------------------------------- ### Partial migration with --sources flag Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate/README.md Examples demonstrating how to use the --sources flag for partial migrations on specific sub-directories or files within a project. It also shows how to include ambient type definitions. ```bash # Run everything on a sub-directory npx ts-migrate-full /path/to/your/project --sources "some/components/**/*" # Or run just one sub-command npx ts-migrate -- rename /path/to/your/project -s "some/components/**/*" npx ts-migrate-full /path/to/your/project \ --sources "some/components/**/*" \ --sources "node_modules/**/*.d.ts" ``` -------------------------------- ### Develop a Custom TypeScript Plugin for ts-migrate Source: https://context7.com/airbnb/ts-migrate/llms.txt Illustrates how to create a custom plugin by implementing the Plugin interface from 'ts-migrate-server'. This example shows how to access the TypeScript language service, perform AST analysis, and modify code based on provided options. ```typescript import ts from 'typescript'; import { Plugin, PluginParams } from 'ts-migrate-server'; interface MyPluginOptions { prefix?: string; enableFeature?: boolean; } const myCustomPlugin: Plugin = { name: 'my-custom-plugin', async run(params: PluginParams): Promise { const { fileName, sourceFile, text, options, rootDir, getLanguageService } = params; // Access TypeScript language service for diagnostics const languageService = getLanguageService(); const diagnostics = languageService.getSemanticDiagnostics(fileName); // Use sourceFile for AST analysis const functions = sourceFile.statements.filter(ts.isFunctionDeclaration); // Return modified text or undefined to skip if (options.enableFeature) { return text.replace(/oldPattern/g, options.prefix || 'newPattern'); } return undefined; }, // Optional validation for plugin options validate(options: unknown): options is MyPluginOptions { if (typeof options !== 'object' || options === null) return false; const opts = options as MyPluginOptions; if (opts.prefix !== undefined && typeof opts.prefix !== 'string') return false; if (opts.enableFeature !== undefined && typeof opts.enableFeature !== 'boolean') return false; return true; } }; export default myCustomPlugin; ``` -------------------------------- ### Develop a JSCodeshift-based Plugin for ts-migrate Source: https://context7.com/airbnb/ts-migrate/llms.txt Shows how to create a plugin that leverages jscodeshift for Abstract Syntax Tree (AST) transformations. This example focuses on renaming identifiers within the code, demonstrating the power of AST manipulation for refactoring. ```typescript import jscodeshift from 'jscodeshift'; import { Plugin } from 'ts-migrate-server'; type Options = { renameFrom?: string; renameTo?: string; }; const j = jscodeshift.withParser('tsx'); const jscodeshiftPlugin: Plugin = { name: 'jscodeshift-rename-plugin', async run({ text, options }) { const { renameFrom = 'oldName', renameTo = 'newName' } = options; const root = j(text); // Find and rename all matching identifiers root .find(j.Identifier, { name: renameFrom }) .replaceWith((path) => j.identifier(renameTo)); return root.toSource(); }, }; export default jscodeshiftPlugin; ``` -------------------------------- ### Create a Simple Text-Based Plugin for ts-migrate Source: https://context7.com/airbnb/ts-migrate/llms.txt Provides an example of a straightforward text transformation plugin. This plugin demonstrates how to manipulate the source code as plain text, specifically by inserting a console log statement before each return statement. ```typescript import { Plugin } from 'ts-migrate-server'; type Options = {}; const textPlugin: Plugin = { name: 'example-text-plugin', async run({ text }) { // Add console.log before each return statement const returnIndex = text.indexOf('return'); const logStatement = 'console.log(`args: ${arguments}`)\n'; if (returnIndex > -1) { return text.substring(0, returnIndex) + logStatement + text.substr(returnIndex); } return text; }, }; export default textPlugin; ``` -------------------------------- ### Create Custom TypeScript AST Plugin Source: https://context7.com/airbnb/ts-migrate/llms.txt Demonstrates how to implement a custom plugin using the TypeScript Compiler API to perform source text updates. This example specifically targets function declarations containing multiplication operations to inject number type annotations. ```typescript import ts from 'typescript'; import { Plugin } from 'ts-migrate-server'; import { updateSourceText, SourceTextUpdate } from 'ts-migrate-plugins'; type Options = { addNumberTypes?: boolean; }; const tsAstPlugin: Plugin = { name: 'ts-ast-plugin', async run({ sourceFile, text, options }) { const updates: SourceTextUpdate[] = []; const printer = ts.createPrinter(); const functionDeclarations = sourceFile.statements.filter(ts.isFunctionDeclaration); functionDeclarations.forEach((funcDecl) => { if (!options.addNumberTypes) return; const hasMultiplication = funcDecl.body?.statements.some( (stmt) => ts.isReturnStatement(stmt) && stmt.expression && ts.isBinaryExpression(stmt.expression) && stmt.expression.operatorToken.kind === ts.SyntaxKind.AsteriskToken ); if (hasMultiplication && funcDecl.parameters.length === 2) { const newFuncDecl = ts.factory.createFunctionDeclaration( funcDecl.decorators, funcDecl.modifiers, funcDecl.asteriskToken, funcDecl.name, funcDecl.typeParameters, funcDecl.parameters.map((param) => ts.factory.createParameterDeclaration( param.decorators, param.modifiers, param.dotDotDotToken, param.name, param.questionToken, ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword), param.initializer ) ), ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword), funcDecl.body ); const newText = printer.printNode(ts.EmitHint.Unspecified, newFuncDecl, sourceFile); updates.push({ kind: 'replace', index: funcDecl.pos, length: funcDecl.end - funcDecl.pos, text: newText, }); } }); return updateSourceText(text, updates); }, }; export default tsAstPlugin; ``` -------------------------------- ### Add Accessibility Modifiers to Class Members (TypeScript) Source: https://context7.com/airbnb/ts-migrate/llms.txt The memberAccessibilityPlugin automatically adds accessibility modifiers (public, private, protected) to class members based on predefined naming conventions. It uses regular expressions to identify members that should be private (starting with '_') or protected (starting with '__'). ```typescript import { memberAccessibilityPlugin } from 'ts-migrate-plugins'; import { MigrateConfig } from 'ts-migrate-server'; const config = new MigrateConfig() .addPlugin(memberAccessibilityPlugin, { defaultAccessibility: 'public', privateRegex: '^_', protectedRegex: '^__', publicRegex: undefined, }); // Input: // class MyClass { // _privateField = 1; // __protectedMethod() {} // publicMethod() {} // } // Output: // class MyClass { // private _privateField = 1; // protected __protectedMethod() {} // public publicMethod() {} // } ``` -------------------------------- ### Run TypeScript migrations programmatically Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-server/README.md Demonstrates how to initialize a migration configuration and execute the migration process against a specified root directory using the ts-migrate-server API. ```typescript import path from 'path'; import { migrate, MigrateConfig } from 'ts-migrate-server'; // get input files folder const inputDir = path.resolve(__dirname, 'input'); // create new migration config. You can add your plugins there const config = new MigrateConfig(); // run migration const exitCode = await migrate({ rootDir: inputDir, config }); process.exit(exitCode); ``` -------------------------------- ### Programmatic Migration API (TypeScript) Source: https://context7.com/airbnb/ts-migrate/llms.txt Demonstrates how to use the `migrate` function from `ts-migrate-server` programmatically. It shows how to import necessary modules, configure plugins like `explicitAnyPlugin`, `tsIgnorePlugin`, and `eslintFixPlugin`, and run the migration process with specified root directory and sources. ```typescript import path from 'path'; import { migrate, MigrateConfig } from 'ts-migrate-server'; import { tsIgnorePlugin, explicitAnyPlugin, eslintFixPlugin } from 'ts-migrate-plugins'; async function runMigration() { const inputDir = path.resolve(__dirname, 'src'); // Create configuration with plugins const config = new MigrateConfig() .addPlugin(explicitAnyPlugin, { anyAlias: '$TSFixMe' }) .addPlugin(tsIgnorePlugin, { useTsIgnore: false, // Use @ts-expect-error instead of @ts-ignore messageLimit: 50, messagePrefix: 'FIXME' }) .addPlugin(eslintFixPlugin, {}); // Run migration const { exitCode, updatedSourceFiles } = await migrate({ rootDir: inputDir, config, sources: ['**/*.ts', '**/*.tsx'], // Optional: specify sources }); console.log(`Updated ${updatedSourceFiles.size} files`); process.exit(exitCode); } runMigration(); ``` -------------------------------- ### ts-migrate CLI commands Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate/README.md Overview of individual ts-migrate commands available via npm run. These include initializing tsconfig.json, renaming files, migrating errors, and re-ignoring errors. ```bash $ npx ts-migrate -- --help npm run ts-migrate -- [options] Commands: npm run ts-migrate -- init Initialize tsconfig.json file in npm run ts-migrate -- rename *Rename files in folder from JS/JSX to TS/TSX npm run ts-migrate -- migrate *Fix TypeScript errors, using codemods npm run ts-migrate -- reignore Re-run ts-ignore on a project * These commands can be passed a --sources (or -s) flag. This flag accepts a relative path to a subset of your project as a string (glob patterns are allowed). When this flag is used, ts-migrate ignores your project's default source files in favor of the ones you've listed. It is effectively the same as replacing your tsconfig.json's `include` property with the provided sources. The flag can be passed multiple times. Options: -h, -- help Show help -i, -- init Initialize TypeScript (tsconfig.json) in -m, -- migrate Fix TypeScript errors, using codemods -rn, -- rename Rename files in from JS/JSX to TS/TSX -ri, -- reignore Re-run ts-ignore on a project Examples: npm run ts-migrate -- --help Show help npm run ts-migrate -- init frontend/foo Create tsconfig.json file at frontend/foo/tsconfig.json npm run ts-migrate -- rename frontend/foo Rename files in frontend/foo from JS/JSX to TS/TSX ``` -------------------------------- ### Initialize TypeScript Configuration (CLI) Source: https://context7.com/airbnb/ts-migrate/llms.txt Creates a tsconfig.json file in the target directory. It supports creating a default configuration using `tsc --init` or an extended configuration that inherits from a base config. This is a foundational step for setting up TypeScript in a project. ```bash npx ts-migrate -- init frontend/foo npx ts-migrate -- init:extended frontend/foo ``` -------------------------------- ### Run ts-migrate with specific sources Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate/README.md Command to perform a full migration on a subset of a project. It allows specifying source files and ambient type definitions to include in the migration process. ```bash npx ts-migrate-full \ --sources="relative/path/to/subset/**/*" \ --sources="node_modules/**/*.d.ts" ``` -------------------------------- ### Run Full Project Migration (CLI) Source: https://context7.com/airbnb/ts-migrate/llms.txt Executes a complete migration of a project folder or a specified subset of files. It can automatically create git commits after each migration step. This command is useful for migrating an entire codebase or specific parts of it. ```bash npx -p ts-migrate -c "ts-migrate-full " npx ts-migrate-full /path/to/project \ --sources="relative/path/to/subset/**/*" \ --sources="node_modules/**/*.d.ts" ``` -------------------------------- ### Configure ts-migrate with Full React Migration Plugins Source: https://context7.com/airbnb/ts-migrate/llms.txt Demonstrates how to build a comprehensive plugin pipeline for React code migration using the MigrateConfig class. It adds various plugins for handling TypeScript-specific features and React patterns, with options for customization. ```typescript import { MigrateConfig } from 'ts-migrate-server'; import { stripTSIgnorePlugin, hoistClassStaticsPlugin, reactPropsPlugin, reactClassStatePlugin, reactClassLifecycleMethodsPlugin, reactDefaultPropsPlugin, declareMissingClassPropertiesPlugin, memberAccessibilityPlugin, explicitAnyPlugin, addConversionsPlugin, eslintFixPlugin, tsIgnorePlugin, } from 'ts-migrate-plugins'; // Full React migration configuration const config = new MigrateConfig() .addPlugin(stripTSIgnorePlugin, {}) .addPlugin(hoistClassStaticsPlugin, { anyAlias: '$TSFixMe' }) .addPlugin(reactPropsPlugin, { anyAlias: '$TSFixMe', anyFunctionAlias: '$TSFixMeFunction', shouldUpdateAirbnbImports: true, shouldKeepPropTypes: false, }) .addPlugin(reactClassStatePlugin, { anyAlias: '$TSFixMe' }) .addPlugin(reactClassLifecycleMethodsPlugin, { force: true }) .addPlugin(reactDefaultPropsPlugin, { useDefaultPropsHelper: false }) .addPlugin(declareMissingClassPropertiesPlugin, { anyAlias: '$TSFixMe' }) .addPlugin(memberAccessibilityPlugin, { defaultAccessibility: 'public', privateRegex: '^_', protectedRegex: '^__', publicRegex: undefined, }) .addPlugin(explicitAnyPlugin, { anyAlias: '$TSFixMe' }) .addPlugin(addConversionsPlugin, { anyAlias: '$TSFixMe' }) .addPlugin(eslintFixPlugin, {}) .addPlugin(tsIgnorePlugin, {}) .addPlugin(eslintFixPlugin, {}); // Run again after ts-ignore ``` -------------------------------- ### Run ts-migrate full migration Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate/README.md Command to perform a full migration of a frontend application to TypeScript. This command automatically adds and commits changes after major migration steps. ```bash npx -p ts-migrate -c "ts-migrate-full " ``` -------------------------------- ### Run ESLint Autofix (TypeScript) Source: https://context7.com/airbnb/ts-migrate/llms.txt The eslintFixPlugin integrates ESLint's autofix functionality into the migration process. After other transformations are applied, this plugin runs `eslint --fix` on each file to automatically correct formatting issues and apply linting rules. ```typescript import { eslintFixPlugin } from 'ts-migrate-plugins'; import { MigrateConfig } from 'ts-migrate-server'; const config = new MigrateConfig() .addPlugin(eslintFixPlugin, {}); // Runs eslint --fix on each file to fix formatting issues ``` -------------------------------- ### Define ts-migrate Plugin Interface (TypeScript) Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate-plugins/README.md This snippet defines the core interfaces for creating a ts-migrate plugin. It outlines the structure for a plugin's name and its `run` method, which accepts parameters like file name, root directory, and source code. Dependencies include the TypeScript compiler API (`ts`). ```typescript interface Plugin { name: string run(params: PluginParams): Promise | string | void } interface PluginParams { options: TPluginOptions; fileName: string; rootDir: string; text: string; sourceFile: ts.SourceFile; getLanguageService: () => ts.LanguageService; } ``` -------------------------------- ### Run Migration with Type Fixes (CLI) Source: https://context7.com/airbnb/ts-migrate/llms.txt Executes the migration pipeline, including codemods to fix TypeScript errors. It allows specifying subsets of files, using ambient types, running specific plugins like 'jsdoc', and configuring member accessibility rules (e.g., default accessibility, private/protected regex patterns). ```bash npx ts-migrate -- migrate frontend/foo npx ts-migrate -- migrate /frontend/foo \ -s "bar/**/*" \ -s "node_modules/**/*.d.ts" npx ts-migrate -- migrate frontend/foo --plugin jsdoc npx ts-migrate -- migrate frontend/foo \ --defaultAccessibility private \ --privateRegex "^_ " --protectedRegex "^__" ``` -------------------------------- ### Rename JavaScript to TypeScript Files (CLI) Source: https://context7.com/airbnb/ts-migrate/llms.txt Renames JavaScript (.js/.jsx) files to TypeScript (.ts/.tsx) based on content analysis. This command can be applied to an entire folder or specific subdirectories. It helps in the initial phase of transitioning file extensions. ```bash npx ts-migrate -- rename frontend/foo npx ts-migrate -- rename frontend/foo -s "components/**/*" ``` -------------------------------- ### Re-run ts-ignore Plugin (CLI) Source: https://context7.com/airbnb/ts-migrate/llms.txt Re-runs the ts-ignore plugin to add `@ts-expect-error` comments for newly identified TypeScript errors after project-wide changes. It can add comments for all type errors or include a custom message prefix. ```bash npx ts-migrate -- reignore frontend/foo npx ts-migrate -- reignore frontend/foo -p "TODO" ``` -------------------------------- ### Configure explicitAnyPlugin Source: https://context7.com/airbnb/ts-migrate/llms.txt Configures the explicitAnyPlugin to resolve 'implicit any' errors by inserting explicit type annotations, supporting custom aliases for the 'any' type. ```typescript import { explicitAnyPlugin } from 'ts-migrate-plugins'; import { MigrateConfig } from 'ts-migrate-server'; const config = new MigrateConfig() .addPlugin(explicitAnyPlugin, { anyAlias: '$TSFixMe', }); ``` -------------------------------- ### Configure reactPropsPlugin Source: https://context7.com/airbnb/ts-migrate/llms.txt Configures the reactPropsPlugin to automatically convert React PropTypes definitions into TypeScript interface or type alias definitions for component props. ```typescript import { reactPropsPlugin } from 'ts-migrate-plugins'; import { MigrateConfig } from 'ts-migrate-server'; const config = new MigrateConfig() .addPlugin(reactPropsPlugin, { anyAlias: '$TSFixMe', anyFunctionAlias: '$TSFixMeFunction', shouldUpdateAirbnbImports: false, shouldKeepPropTypes: false, }); ``` -------------------------------- ### Configure jsDocPlugin Source: https://context7.com/airbnb/ts-migrate/llms.txt Configures the jsDocPlugin to parse JSDoc @param and @returns annotations and convert them into native TypeScript type annotations within the source code. ```typescript import { jsDocPlugin } from 'ts-migrate-plugins'; import { MigrateConfig } from 'ts-migrate-server'; const config = new MigrateConfig() .addPlugin(jsDocPlugin, { anyAlias: '$TSFixMe', annotateReturns: true, typeMap: { 'CustomType': { tsName: 'MyType', acceptsTypeParameters: true }, }, }); ``` -------------------------------- ### Re-ignore TypeScript errors Source: https://github.com/airbnb/ts-migrate/blob/master/packages/ts-migrate/README.md Command to automatically add `any` or `@ts-expect-error` comments to TypeScript errors, making the project compilable. This is useful for gradual error fixing. ```bash npx ts-migrate -- reignore ``` -------------------------------- ### Configure tsIgnorePlugin Source: https://context7.com/airbnb/ts-migrate/llms.txt Configures the tsIgnorePlugin to suppress TypeScript errors by inserting @ts-expect-error or @ts-ignore comments. It allows customization of message prefixes and error limits. ```typescript import { tsIgnorePlugin } from 'ts-migrate-plugins'; import { MigrateConfig } from 'ts-migrate-server'; const config = new MigrateConfig() .addPlugin(tsIgnorePlugin, { useTsIgnore: false, messageLimit: 50, messagePrefix: 'FIXME', }); ``` -------------------------------- ### Add Type Conversions for Type Errors (TypeScript) Source: https://context7.com/airbnb/ts-migrate/llms.txt The addConversionsPlugin automatically inserts type conversion casts, such as `as $TSFixMe` or `as any`, into the code to resolve type errors. This is useful for quickly addressing type mismatches during migration. ```typescript import { addConversionsPlugin } from 'ts-migrate-plugins'; import { MigrateConfig } from 'ts-migrate-server'; const config = new MigrateConfig() .addPlugin(addConversionsPlugin, { anyAlias: '$TSFixMe', }); // Adds `as $TSFixMe` or `as any` casts where type errors occur ``` -------------------------------- ### Strip TS Ignore Comments (TypeScript) Source: https://context7.com/airbnb/ts-migrate/llms.txt The stripTSIgnorePlugin removes all `@ts-ignore` and `@ts-expect-error` comments from the codebase. This is typically done before re-running migrations to ensure that existing ignore comments do not mask new or unresolved type errors. ```typescript import { stripTSIgnorePlugin } from 'ts-migrate-plugins'; import { MigrateConfig } from 'ts-migrate-server'; const config = new MigrateConfig() .addPlugin(stripTSIgnorePlugin, {}); // Removes all @ts-ignore and @ts-expect-error comments ``` -------------------------------- ### Update Source Text with Multiple Transformations (TypeScript) Source: https://context7.com/airbnb/ts-migrate/llms.txt The `updateSourceText` utility function allows for applying a series of text modifications to a string, such as insertions, replacements, and deletions. It takes the original text and an array of `SourceTextUpdate` objects to produce the modified text. ```typescript import { updateSourceText, SourceTextUpdate } from 'ts-migrate-plugins'; const originalText = 'function add(a, b) { return a + b; }'; const updates: SourceTextUpdate[] = [ // Insert type annotation after 'a' { kind: 'insert', index: 14, text: ': number' }, // Insert type annotation after 'b' { kind: 'insert', index: 17, text: ': number' }, // Replace entire function with new version { kind: 'replace', index: 0, length: 35, text: 'function add(a: number, b: number): number { return a + b; }' }, // Delete a section { kind: 'delete', index: 10, length: 5 }, ]; const result = updateSourceText(originalText, updates); ``` -------------------------------- ### Declare Missing Class Properties (TypeScript) Source: https://context7.com/airbnb/ts-migrate/llms.txt The declareMissingClassPropertiesPlugin identifies and declares class properties that are assigned within the class but not explicitly declared. It helps in ensuring all class members are properly defined, using a specified alias for inferred types. ```typescript import { declareMissingClassPropertiesPlugin } from 'ts-migrate-plugins'; import { MigrateConfig } from 'ts-migrate-server'; const config = new MigrateConfig() .addPlugin(declareMissingClassPropertiesPlugin, { anyAlias: '$TSFixMe', }); // Input: // class MyClass { // constructor() { // this.name = 'test'; // this.count = 0; // } // } // Output: // class MyClass { // name: $TSFixMe; // count: $TSFixMe; // constructor() { // this.name = 'test'; // this.count = 0; // } // } ``` -------------------------------- ### Hoist Static Class Members (TypeScript) Source: https://context7.com/airbnb/ts-migrate/llms.txt The hoistClassStaticsPlugin moves static class members that are defined outside the class body into the class definition itself. This consolidates static properties and methods within the class scope, improving code organization. ```typescript import { hoistClassStaticsPlugin } from 'ts-migrate-plugins'; import { MigrateConfig } from 'ts-migrate-server'; const config = new MigrateConfig() .addPlugin(hoistClassStaticsPlugin, { anyAlias: '$TSFixMe', }); // Input: // class MyClass {} // MyClass.defaultProps = { size: 'medium' }; // MyClass.displayName = 'MyClass'; // Output: // class MyClass { // static defaultProps = { size: 'medium' }; // static displayName = 'MyClass'; // } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.