| 1 |
import * as t from "../../../lib/index.js"; |
| 2 |
|
| 3 |
describe("builders", function () { |
| 4 |
describe("flow", function () { |
| 5 |
describe("declareClass", function () { |
| 6 |
it("accept TypeParameterDeclaration as typeParameters", function () { |
| 7 |
const typeParameter = t.typeParameter(null, null, null); |
| 8 |
typeParameter.name = "T"; |
| 9 |
const declaredClass = t.declareClass( |
| 10 |
t.identifier("A"), |
| 11 |
t.typeParameterDeclaration([typeParameter]), |
| 12 |
[], |
| 13 |
t.objectTypeAnnotation([], [], [], []), |
| 14 |
); |
| 15 |
expect(t.isDeclareClass(declaredClass)).toBe(true); |
| 16 |
}); |
| 17 |
|
| 18 |
it("not accept typeParameterInstantiation as typeParameters", function () { |
| 19 |
expect(() => |
| 20 |
t.declareClass( |
| 21 |
t.identifier("A"), |
| 22 |
t.typeParameterInstantiation([ |
| 23 |
t.genericTypeAnnotation(t.identifier("T")), |
| 24 |
]), |
| 25 |
[], |
| 26 |
t.objectTypeAnnotation([], [], [], []), |
| 27 |
), |
| 28 |
).toThrow(Error); |
| 29 |
}); |
| 30 |
}); |
| 31 |
}); |
| 32 |
}); |