Merge pull request babel/babel-eslint#118 from hzoo/poly-types
add flow exceptions for polymorphic types (<A>) - Ref babel/babel-eslint#109
This commit is contained in:
parent
ade0b3b21b
commit
6a2938deaa
@ -163,6 +163,10 @@ function monkeypatch() {
|
||||
if (node.typeAnnotation) {
|
||||
visitTypeAnnotation.call(this, node.typeAnnotation);
|
||||
} else if (node.type === "Identifier") {
|
||||
// exception for polymorphic types: <T>, <A>, etc
|
||||
if (node.name.length === 1 && node.name === node.name.toUpperCase()) {
|
||||
return;
|
||||
}
|
||||
this.visit(node);
|
||||
} else {
|
||||
visitTypeAnnotation.call(this, node);
|
||||
|
||||
@ -296,6 +296,26 @@ describe("verify", function () {
|
||||
);
|
||||
});
|
||||
|
||||
it("polymorphpic types #109", function () {
|
||||
verifyAndAssertMessages([
|
||||
"export default function groupByEveryN<T>(array: Array<T>, n: number): Array<Array<?T>> {}"
|
||||
].join("\n"),
|
||||
{ "no-unused-vars": 1, "no-undef": 1 },
|
||||
[]
|
||||
);
|
||||
});
|
||||
|
||||
it("types definition from import", function () {
|
||||
verifyAndAssertMessages([
|
||||
"import type Promise from 'bluebird';",
|
||||
"type Operation = () => Promise;",
|
||||
"x: Operation;"
|
||||
].join("\n"),
|
||||
{ "no-unused-vars": 1, "no-undef": 1 },
|
||||
[]
|
||||
);
|
||||
});
|
||||
|
||||
it("1", function () {
|
||||
verifyAndAssertMessages(
|
||||
[
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user