Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a builder definition including name for tsTypeParameter (#10319)
- Loading branch information
1 parent
f0c2364
commit eb3767d
Showing
3 changed files
with
49 additions
and
0 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
24 changes: 24 additions & 0 deletions
24
packages/babel-types/test/builders/typescript/__snapshots__/tsTypeParameter.js.snap
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,24 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`builders typescript tsTypeParameter accept name as argument for tsTypeParameter 1`] = ` | ||
Object { | ||
"constraint": Object { | ||
"type": "TSTypeReference", | ||
"typeName": Object { | ||
"name": "bar", | ||
"type": "Identifier", | ||
}, | ||
"typeParameters": null, | ||
}, | ||
"default": Object { | ||
"type": "TSTypeReference", | ||
"typeName": Object { | ||
"name": "baz", | ||
"type": "Identifier", | ||
}, | ||
"typeParameters": null, | ||
}, | ||
"name": "foo", | ||
"type": "TSTypeParameter", | ||
} | ||
`; |
24 changes: 24 additions & 0 deletions
24
packages/babel-types/test/builders/typescript/tsTypeParameter.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,24 @@ | ||
import * as t from "../../.."; | ||
|
||
describe("builders", function() { | ||
describe("typescript", function() { | ||
describe("tsTypeParameter", function() { | ||
it("accept name as argument for tsTypeParameter", function() { | ||
const tsTypeParameter = t.tsTypeParameter( | ||
t.tsTypeReference(t.identifier("bar")), | ||
t.tsTypeReference(t.identifier("baz")), | ||
"foo", | ||
); | ||
expect(tsTypeParameter).toMatchSnapshot(); | ||
}); | ||
it("throws when name is missing", function() { | ||
expect(() => { | ||
t.tsTypeParameter( | ||
t.tsTypeReference(t.identifier("bar")), | ||
t.tsTypeReference(t.identifier("baz")), | ||
); | ||
}).toThrow("Property name expected type of string but got null"); | ||
}); | ||
}); | ||
}); | ||
}); |