Using type-only imports/exports in an older CRA project - how do I update babel loaders?

591 views Asked by At

I want to use the type-only import/export syntax in an existing project generated by an older version of CRA. I upgraded TypeScript to 3.9.3, but when I try to yarn start, I also upgraded babel via yarn upgrade Babel, but I get the following error:

Module parse failed: Unexpected token (3:12)
File was processed with these loaders:
* ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
* ./node_modules/react-scripts/node_modules/eslint-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
> import type { Type } from "./Source";

same thing happens when I try exporting a type like export type { Type }, but export Type = _Type works fine.

I suppose I don't have the right babel loaders, how do I get them? Or is it something else? I use react-scripts 3.2.0

0

There are 0 answers