Import external Typescript file in Next.js app

Viewed 809

I have a Next.js app A with only Typescript files and a package B with this index.tsx file:

export default () => {
    console.log('hi');
}

When I import it in any file of my Next.js app A by doing:

import f from 'B';

I get this error:

ModuleParseError: Module parse failed: Unexpected token (15:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

that seems related to Webpack but I have no idea how to solve it.

0 Answers
Related