You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reacted by John Louderback, Michael Kauzmann, Jóhann Guðmundsson, Dmitriy Zasukha, Tim Peko, Thundercraft5, AlexeiA, Henderson Pinto, MetaCrawler, Victorien Elvinger and 9 more
Reacted by Henrique Silvério, Marek Legris and Martin Rabaud
TypeScript 5.0 (in #52203) introduced a new option called --verbatimModuleSyntax that makes the following code produce the following error: An 'export default' must reference a value when 'verbatimModuleSyntax' is enabled, but 'X' only refers to a type., because the default export X is not clearly marked as a type:
typeX=number|string;exportdefaultX;
And a workaround is to mark X as a type in the export declaration by using a named export:
typeX=number|string;exporttype{Xasdefault};// or export {type X as default};
But that looks fairly indirect. Having export default type X; would also help making that more straightforward.
Reacted by Andrei, whzx5byb, Andre-John Mas, Son Nguyen and Squidgical
because it doesn't allow multiple default exports.
As pointed out earlier, it means that my clients will need to write import { Fraction } from "fractions"; rather than import Fraction from "fractions";, and that the default export is not treated the same as the other exports.
Would very much like to see this. I'm using verbatimModuleSyntax, and while I can default export interfaces just fine, I can't do that for type aliases. It's causing me to use an unpleasant mix of // @ts-* comments and breaking my own conventions.
Activity
harrysolovay commentedon Dec 3, 2020
I often want to export values which double as types. For instance.
It feels to me like this should be possible with default exports as well.
hopeless-programmer-online commentedon Apr 16, 2021
Any updates on this?
PolariTOON commentedon Mar 28, 2023
TypeScript 5.0 (in #52203) introduced a new option called
--verbatimModuleSyntaxthat makes the following code produce the following error:An 'export default' must reference a value when 'verbatimModuleSyntax' is enabled, but 'X' only refers to a type., because the default exportXis not clearly marked as a type:And a workaround is to mark
Xas a type in theexportdeclaration by using a named export:But that looks fairly indirect. Having
export default type X;would also help making that more straightforward.AndreiSoroka commentedon Sep 9, 2023
was:
now:
seems like a bug, because I have 1 type in 1 file
switch Card form interface to type
movahhedi commentedon May 14, 2024
For those who were looking for "Type annotations for
export default", follow #13626.Gouvernathor commentedon Jul 19, 2025
In addition, while the following is possible :
The following gives an error :
because it doesn't allow multiple default exports.
As pointed out earlier, it means that my clients will need to write
import { Fraction } from "fractions";rather thanimport Fraction from "fractions";, and that the default export is not treated the same as the other exports.Squidgical commentedon Nov 29, 2025
Would very much like to see this. I'm using
verbatimModuleSyntax, and while I can default export interfaces just fine, I can't do that for type aliases. It's causing me to use an unpleasant mix of// @ts-*comments and breaking my own conventions.