Typescript isolatedModules `export type { T } from './file'` vs `export { type T } from './file'` syntax

Viewed 25

When I copied some code from one of my create-react-app projects to another. I've got these kind of errors:

SyntaxError: .../index.ts: Unexpected token, expected "," (3:47)

> 3 | export { default, type TimeInputProps } from "./TimeInput";
    |                        ^

The error is gone after changing the line to:

export { default } from "./TimeInput";
export type { TimeInputProps } from "./TimeInput";

One project works with both syntaxes but the other one only accepts the second syntax. Typescript version is 4.7.4 in both. What is the reason for it? Is there any difference? Couldn't find any documentation on it.

0 Answers
Related