A VSCode extension that transforms React component props between three different TypeScript patterns using AST-based transformations.

Features
Transform between three prop definition patterns:
- Interface Pattern
interface DrawerProps {
header: string;
}
function Drawer({ header }: DrawerProps) {
return <></>;
}
- Type Alias Pattern
type DrawerProps = {
header: string;
};
function Drawer({ header }: DrawerProps) {
return <></>;
}
- Inline Pattern
function Drawer({ header }: { header: string }) {
return <></>;
}
Usage
- Place your cursor on a React component function name
- Press
Cmd+. (or Ctrl+. on Windows/Linux) to open the Quick Fix menu
- Select one of the transformation options:
- "Convert to interface"
- "Convert to type alias"
- "Convert to inline props"
The extension uses the TypeScript Compiler API to safely transform your code while preserving:
- Type parameters (generics)
- Export modifiers
- Comments and formatting
- Heritage clauses (extends/implements)
Installation for Development
- Clone this repository
- Run
npm install
- Run
npm run compile
- Press F5 to launch the Extension Development Host
- Open a
.tsx or .ts file with React components
- Test the transformations
Limitations
- Cannot inline types that are used in multiple places (shared types)
- Cannot inline exported types (to preserve exports)
- Only works with React components (functions that return JSX)
- Interface extends clauses are converted to intersection types when converting to type alias
License
MIT
| |