New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow exporting TSDeclareFunction
as default
#14763
fix: allow exporting TSDeclareFunction
as default
#14763
Conversation
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" modifier export declare default function f(): any; // lots of parsing errors export 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test so that we don't accidentally break this again?
TSDeclareFunction
as default
Updating
@babel/types
to allowTSDeclareFunction
in default export.It was working earlier, but stopped somewhere in between
7.18.2
and current (7.18.8
) version