Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow exporting
TSDeclareFunction
as default (#14763)
- Loading branch information
Showing
5 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/babel-types/test/builders/typescript/exportDefaultDeclaration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as t from "../../../lib/index.js"; | ||
|
||
describe("builders", function () { | ||
describe("typescript", function () { | ||
describe("exportDefaultDeclaration", function () { | ||
it("accept TSDeclareFunction as argument for exportDefaultDeclaration", function () { | ||
// this can be used when having function overrides for function exported as default | ||
// export default function test(); | ||
// export default function test() {}; | ||
expect(() => { | ||
t.exportDefaultDeclaration( | ||
t.tsDeclareFunction( | ||
t.identifier("test"), | ||
null, | ||
[], | ||
t.tsTypeAnnotation(t.tsVoidKeyword()), | ||
), | ||
); | ||
}).not.toThrow(); | ||
}); | ||
}); | ||
}); | ||
}); |