fix: allow exporting TSDeclareFunction as default#14763
fix: allow exporting TSDeclareFunction as default#14763nicolo-ribaudo merged 3 commits intobabel:mainfrom
TSDeclareFunction as default#14763Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52535/ |
|
What is the corresponding TS syntax? All of these error in the TS playground 🤔 declare export default function f(): any; // "export" modifier must precede "declare" modifierexport declare default function f(): any; // lots of parsing errorsexport default declare function f(): any; // expects a ; after declare |
|
example with the syntax(playground): export default function test(a: number): boolean;
export default function test(a: boolean): boolean;
export default function test(a: any): boolean {
return false;
}; |
|
It looks like this. |
|
@liuxingbaoyu here is it in astexplorer (for babel parser it is to be |
|
Related to this. |
| // @ts-expect-error TSDeclareFunction is not expected here | ||
| path.replaceWith(buildExportCall("default", declar)); |
There was a problem hiding this comment.
from my understanding TSDeclareFunction is not expected to get there(I would assume it is to be removed somewhere earlier, and it is fine to ignore this)
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
Can you add a test so that we don't accidentally break this again?
TSDeclareFunction as default

Updating
@babel/typesto allowTSDeclareFunctionin default export.It was working earlier, but stopped somewhere in between
7.18.2and current (7.18.8) version