Open KurtPreston opened 2 years ago
Does export {default as MyJsonFile} from './myJsonFile.json';
work?
@fisker Unfortunately not. It results in this error:
Module '"./myJsonFile.json"' has no exported member 'default'.ts(2305)
Is this a typescript issue?
I can confirm that this is a TypeScript issue.
A few notes:
import x from './file.json' with {type: 'json'}
(works in TS)export {x}
to export {default as x} from from './file.json' with {type: 'json'}
(works in TS)with {type: 'json'}
, your code works in Node 22 (but still doesn't in TS 5.5)Given that unicorn produces valid code, this isn't a bug here. I'm reclassifying it as a feature request to improve support with TS until TS fixes their own bug.
If you file a report with TS or find an open bug, please link it here.
I have the following TypeScript code:
The
prefer-export-from
rule wants me to change the line toUnfortunately, this results in the TypeScript compilation error:
Ideally,
prefer-export-from
would be able to ignoreexport =
modules which are incompatible with the syntax. If that is not possible to infer, then it would be nice to be able to specify certain patterns to exclude from the rule, like: