Sunday, May 14, 2023
HomeReactBabel Module Resolver with TypeScript

Babel Module Resolver with TypeScript


This tutorial is an element 2 of two within the collection.

Right here you’ll discover ways to use TypeScript with Babel Module Resolver for aliases which can be outlined in your .babelrc file:

{

...

"plugins": [

[

"module-resolver",

{

"root": ["./"],

"alias": {

"@parts": "./src/parts",

"@constants": "./src/constants",

}

}

],

]

}

With a purpose to get the identical alias mappings to TypeScript, the tsconfig.json file must appear to be this:

{

"compilerOptions": {

...

"baseUrl": ".",

"paths": {

"@parts/*": ["./src/components/*"],

"@constants/*": ["./src/constants/*"]

}

},

...

}

Now you should utilize import statemes with aliases in your TypeScript recordsdata too.

RELATED ARTICLES

Most Popular

Recent Comments