Merge branch 'master' of github.com:babel/babel

This commit is contained in:
Sebastian McKenzie 2015-06-02 16:18:13 +01:00
commit 0abd34f7e6
5 changed files with 40 additions and 6 deletions

View File

@ -415,6 +415,9 @@ pp.flow_identToTypeAnnotation = function (start, node, id) {
case "boolean":
return this.finishNode(node, "BooleanTypeAnnotation")
case "mixed":
return this.finishNode(node, "MixedTypeAnnotation")
case "number":
return this.finishNode(node, "NumberTypeAnnotation")

View File

@ -103,6 +103,10 @@ export function IntersectionTypeAnnotation(node, print) {
print.join(node.types, { separator: " & " });
}
export function MixedTypeAnnotation() {
this.push("mixed");
}
export function NullableTypeAnnotation(node, print) {
this.push("?");
print.plain(node.typeAnnotation);

View File

@ -93,6 +93,7 @@
"InterfaceExtends": ["Flow"],
"InterfaceDeclaration": ["Flow", "Statement", "Declaration"],
"IntersectionTypeAnnotation": ["Flow"],
"MixedTypeAnnotation": ["Flow"],
"NullableTypeAnnotation": ["Flow"],
"NumberTypeAnnotation": ["Flow"],
"StringLiteralTypeAnnotation": ["Flow"],

View File

@ -91,6 +91,7 @@
"InterfaceExtends": ["id", "typeParameters"],
"InterfaceDeclaration": ["id", "typeParameters", "extends", "body"],
"IntersectionTypeAnnotation": ["types"],
"MixedTypeAnnotation": [],
"NullableTypeAnnotation": ["typeAnnotation"],
"NumberTypeAnnotation": [],
"StringLiteralTypeAnnotation": [],

View File

@ -2,7 +2,7 @@
var fbTestFixture = {
'Type Annotations': {
'function foo(numVal: any){}': {
'function foo(numVal: any, otherVal: mixed){}': {
type: 'FunctionDeclaration',
id: {
type: 'Identifier',
@ -37,22 +37,47 @@ var fbTestFixture = {
start: { line: 1, column: 13 },
end: { line: 1, column: 24 }
}
},
{
type: 'Identifier',
name: 'otherVal',
typeAnnotation: {
type: 'TypeAnnotation',
typeAnnotation: {
type: 'MixedTypeAnnotation',
range: [36, 41],
loc: {
start: { line: 1, column: 36 },
end: { line: 1, column: 41 }
}
},
range: [34, 41],
loc: {
start: { line: 1, column: 34 },
end: { line: 1, column: 41 }
}
},
range: [26, 41],
loc: {
start: { line: 1, column: 26 },
end: { line: 1, column: 41 }
}
}],
body: {
type: 'BlockStatement',
body: [],
range: [25, 27],
range: [42, 44],
loc: {
start: { line: 1, column: 25 },
end: { line: 1, column: 27 }
start: { line: 1, column: 42 },
end: { line: 1, column: 44 }
}
},
generator: false,
expression: false,
range: [0, 27],
range: [0, 44],
loc: {
start: { line: 1, column: 0 },
end: { line: 1, column: 27 }
end: { line: 1, column: 44 }
}
},
'function foo(numVal: number){}': {