Add method property to ObjectTypeProperty (#7005)

This commit is contained in:
Brian Ng
2017-12-11 09:32:16 -06:00
committed by GitHub
parent 42f66782be
commit f5ef928586
54 changed files with 1491 additions and 16 deletions

View File

@@ -751,6 +751,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
let optional = false;
if (this.isRelational("<") || this.match(tt.parenL)) {
// This is a method property
node.method = true;
if (variance) {
this.unexpected(variance.start);
}
@@ -763,6 +765,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
} else {
if (kind !== "init") this.unexpected();
node.method = false;
if (this.eat(tt.question)) {
optional = true;
}

View File

@@ -284,6 +284,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 25,

View File

@@ -111,6 +111,7 @@
},
"static": false,
"kind": "get",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 20,
@@ -179,6 +180,7 @@
},
"static": false,
"kind": "set",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 39,
@@ -299,6 +301,7 @@
},
"static": false,
"kind": "get",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 65,
@@ -370,6 +373,7 @@
},
"static": false,
"kind": "set",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 86,
@@ -490,6 +494,7 @@
},
"static": false,
"kind": "get",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 114,
@@ -561,6 +566,7 @@
},
"static": false,
"kind": "set",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 133,

View File

@@ -111,6 +111,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "GenericTypeAnnotation",
"start": 28,

View File

@@ -174,6 +174,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 50,

View File

@@ -105,6 +105,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 26,

View File

@@ -157,6 +157,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 37,

View File

@@ -151,6 +151,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 45,

View File

@@ -111,6 +111,7 @@
},
"static": true,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 18,
@@ -179,6 +180,7 @@
},
"static": true,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 51,

View File

@@ -111,6 +111,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 27,
@@ -250,6 +251,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "GenericTypeAnnotation",
"start": 66,

View File

@@ -111,6 +111,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 22,
@@ -162,6 +163,7 @@
},
"static": true,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 41,
@@ -213,6 +215,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 53,

View File

@@ -111,6 +111,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 29,

View File

@@ -227,6 +227,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 37,

View File

@@ -161,6 +161,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "BooleanTypeAnnotation",
"start": 22,
@@ -212,6 +213,7 @@
},
"static": true,
"kind": "init",
"method": false,
"value": {
"type": "BooleanTypeAnnotation",
"start": 62,

View File

@@ -111,6 +111,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "FunctionTypeAnnotation",
"start": 19,

View File

@@ -111,6 +111,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 56,

View File

@@ -109,6 +109,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 11,

View File

@@ -124,6 +124,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 23,
@@ -200,6 +201,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 38,
@@ -525,6 +527,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "UnionTypeAnnotation",
"start": 147,
@@ -589,6 +592,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 156,
@@ -665,6 +669,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 174,
@@ -783,6 +788,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "IntersectionTypeAnnotation",
"start": 212,
@@ -847,6 +853,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 221,
@@ -923,6 +930,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringLiteralTypeAnnotation",
"start": 239,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 14,
@@ -187,6 +188,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 25,
@@ -450,6 +452,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 71,
@@ -501,6 +504,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 82,
@@ -864,6 +868,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "ObjectTypeAnnotation",
"start": 148,
@@ -913,6 +918,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 154,
@@ -964,6 +970,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 165,
@@ -1022,6 +1029,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "BooleanTypeAnnotation",
"start": 179,
@@ -1388,6 +1396,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "ObjectTypeAnnotation",
"start": 242,
@@ -1437,6 +1446,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 247,
@@ -1488,6 +1498,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 258,
@@ -1546,6 +1557,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "BooleanTypeAnnotation",
"start": 271,

View File

@@ -109,6 +109,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "GenericTypeAnnotation",
"start": 13,

View File

@@ -109,6 +109,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "GenericTypeAnnotation",
"start": 13,

View File

@@ -109,6 +109,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "ObjectTypeAnnotation",
"start": 15,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 16,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 16,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 16,

View File

@@ -150,6 +150,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 17,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 16,
@@ -187,6 +188,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 32,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "ObjectTypeAnnotation",
"start": 16,
@@ -185,6 +186,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 25,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NullableTypeAnnotation",
"start": 16,
@@ -199,6 +200,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 26,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 16,
@@ -187,6 +188,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 32,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 16,
@@ -187,6 +188,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 33,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 8,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 9,

View File

@@ -191,6 +191,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 13,

View File

@@ -191,6 +191,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 13,

View File

@@ -196,6 +196,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 23,

View File

@@ -136,6 +136,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 17,
@@ -187,6 +188,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 33,
@@ -238,6 +240,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 49,

View File

@@ -0,0 +1,12 @@
type T = { a: () => void };
type T = { a: <T>() => void };
type T = { a(): void };
type T = { a<T>(): void };
type T = { (): number };
type T = { <T>(x: T): number; }
declare class T { foo(): number; }
declare class T { static foo(): number; }
declare class T { (): number }
declare class T { static (): number }

File diff suppressed because it is too large Load Diff

View File

@@ -128,6 +128,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 26,
@@ -300,6 +301,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "GenericTypeAnnotation",
"start": 65,

View File

@@ -111,6 +111,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 20,
@@ -212,6 +213,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 41,
@@ -313,6 +315,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 62,
@@ -414,6 +417,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 82,
@@ -515,6 +519,7 @@
},
"static": true,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 99,
@@ -616,6 +621,7 @@
},
"static": true,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 127,
@@ -717,6 +723,7 @@
},
"static": true,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 155,
@@ -818,6 +825,7 @@
},
"static": true,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 182,

View File

@@ -111,6 +111,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 24,
@@ -212,6 +213,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 45,
@@ -313,6 +315,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 66,
@@ -414,6 +417,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 86,

View File

@@ -111,6 +111,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 16,
@@ -212,6 +213,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 37,
@@ -313,6 +315,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 58,
@@ -414,6 +417,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 78,

View File

@@ -109,6 +109,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 13,
@@ -210,6 +211,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 34,
@@ -311,6 +313,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 55,
@@ -412,6 +415,7 @@
},
"static": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 75,

View File

@@ -246,6 +246,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "NumberTypeAnnotation",
"start": 29,
@@ -297,6 +298,7 @@
},
"static": false,
"kind": "init",
"method": false,
"value": {
"type": "StringTypeAnnotation",
"start": 42,