-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Bug report
Describe the bug
As I wrote an issue in @zeit/next-typescript some months ago, Babel does not support to import types or interfaces from re-export files such as index.ts .
On large project, developers create index.js (or index.ts ) to encapsulate the API calls from the web app into a single folder.
@zeit/next-typescript throws warnings when importing re-exported types, but Next.js 9 (using built-in TypeScript transpile system) throws errors in that case. So we cannot develop using re-export files.
To Reproduce
// packages/package-1.ts
export type TypeA = {};
// packages/index.ts
export { TypeA } from "./package-1";
// main.ts
import { TypeA } from "./packages";Next.js throws errors like the following if the above code is contained in some pages.
Attempted import error: 'TypeA' is not exported from './package-1'.
Expected behavior
Do not raise any errors and warnings.
Additional context
Babel v7 supports to transpile TypeScript files but it is only to remove types from TypeScript files. At this time, the target of import from intersection (index) files will be removed.
// After transpile by Babel...
// ---
// packages/package-1.ts
// export type TypeA = {}; // REMOVED!
// packages/index.ts
export { TypeA } from "./package-1"; // NOT FOUND!To solve this issue at its foundation, Babel should support re-export files and we should wait to do. However I think that to filter and ignore these errors using regular expressions makes to solve.