Fix variance (#5320)

This commit is contained in:
Daniel Tschinder 2017-02-15 22:37:19 +01:00 committed by GitHub
parent 9188be9ed5
commit ca78da6501
2 changed files with 8 additions and 10 deletions

View File

@ -146,10 +146,12 @@ export function _interfaceish(node: Object) {
}
export function _variance(node) {
if (node.variance === "plus") {
this.token("+");
} else if (node.variance === "minus") {
this.token("-");
if (node.variance) {
if (node.variance.kind === "plus") {
this.token("+");
} else if (node.variance.kind === "minus") {
this.token("-");
}
}
}

View File

@ -2,14 +2,10 @@ import * as t from "babel-types";
import jsesc from "jsesc";
export function Identifier(node: Object) {
// FIXME: We hang variance off Identifer to support Flow's def-site variance.
// This is a terrible hack, but changing type annotations to use a new,
// dedicated node would be a breaking change. This should be cleaned up in
// the next major.
if (node.variance) {
if (node.variance === "plus") {
if (node.variance.kind === "plus") {
this.token("+");
} else if (node.variance === "minus") {
} else if (node.variance.kind === "minus") {
this.token("-");
}
}