Barrel Imports Expansion Ts

/icons/calendar.svg

Last update

May 14, 2024

Description

A sample ast-grep codemod for barrel imports in TS.

h/t HerringtonDarkholme

Before

import { A, B, C } from './barrel';
function Component() {
const [name, setName] = useState < string > ('React');
}

After

import A from './barrel/A'
import B from './barrel/B'
import C from './barrel/C'
function Component() {
const [name, setName] = useState < string > ('React');
}

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now