Fix support for Flow's DeclareClass type parameters (#9459)
This commit is contained in:
parent
07b0f22a3f
commit
738060ebfa
@ -72,7 +72,7 @@ defineType("ClassImplements", {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
defineInterfaceishType("DeclareClass", "TypeParameterInstantiation");
|
defineInterfaceishType("DeclareClass");
|
||||||
|
|
||||||
defineType("DeclareFunction", {
|
defineType("DeclareFunction", {
|
||||||
visitor: ["id"],
|
visitor: ["id"],
|
||||||
|
|||||||
32
packages/babel-types/test/builders/flow/declareClass.js
Normal file
32
packages/babel-types/test/builders/flow/declareClass.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import * as t from "../../..";
|
||||||
|
|
||||||
|
describe("builders", function() {
|
||||||
|
describe("flow", function() {
|
||||||
|
describe("declareClass", function() {
|
||||||
|
it("accept TypeParameterDeclaration as typeParameters", function() {
|
||||||
|
const typeParameter = t.typeParameter(null, null, null);
|
||||||
|
typeParameter.name = "T";
|
||||||
|
const declaredClass = t.declareClass(
|
||||||
|
t.identifier("A"),
|
||||||
|
t.typeParameterDeclaration([typeParameter]),
|
||||||
|
[],
|
||||||
|
t.objectTypeAnnotation([], [], [], []),
|
||||||
|
);
|
||||||
|
expect(t.isDeclareClass(declaredClass)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("not accept typeParameterInstantiation as typeParameters", function() {
|
||||||
|
expect(() =>
|
||||||
|
t.declareClass(
|
||||||
|
t.identifier("A"),
|
||||||
|
t.typeParameterInstantiation([
|
||||||
|
t.genericTypeAnnotation(t.identifier("T")),
|
||||||
|
]),
|
||||||
|
[],
|
||||||
|
t.objectTypeAnnotation([], [], [], []),
|
||||||
|
),
|
||||||
|
).toThrow(Error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user