fix(babel-types): Add assertions to ExportAllDeclaration (#12273)

This commit is contained in:
Sosuke Suzuki 2020-10-29 22:24:56 +09:00 committed by GitHub
parent b7754d3c82
commit d04b4dd116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -248,6 +248,17 @@ describe("@babel/template", function () {
expect(result.assertions[0].type).toBe("ImportAttribute"); expect(result.assertions[0].type).toBe("ImportAttribute");
}); });
it("should return assertions in ExportAllDeclaration when using .ast", () => {
const result = template.ast(
`export * from "foo.json" assert { type: "json" };`,
{
plugins: ["importAssertions"],
},
);
expect(result.assertions[0].type).toBe("ImportAttribute");
});
it("should replace JSX placeholder", () => { it("should replace JSX placeholder", () => {
const result = template.expression( const result = template.expression(
` `

View File

@ -1401,6 +1401,12 @@ defineType("ExportAllDeclaration", {
source: { source: {
validate: assertNodeType("StringLiteral"), validate: assertNodeType("StringLiteral"),
}, },
assertions: {
validate: chain(
assertValueType("array"),
assertNodeType("ImportAttribute"),
),
},
}, },
}); });