From cea9fd521881137df498e929fbd4a22959ad2d28 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Wed, 29 Jul 2015 12:37:41 -0700 Subject: [PATCH 1/6] Couple of fixes and deprecations in ESTree --- estree/estree.d.ts | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/estree/estree.d.ts b/estree/estree.d.ts index 329396b7c..be60f8dbf 100644 --- a/estree/estree.d.ts +++ b/estree/estree.d.ts @@ -22,7 +22,7 @@ declare module ESTree { } interface Program extends Node { - body: Array; + body: Array; sourceType: string; } @@ -72,7 +72,6 @@ declare module ESTree { interface SwitchStatement extends Statement { discriminant: Expression; cases: Array; - lexical: boolean; } interface ReturnStatement extends Statement { @@ -215,7 +214,6 @@ declare module ESTree { interface CatchClause extends Node { param: Pattern; - guard: any; body: BlockStatement; } @@ -227,7 +225,7 @@ declare module ESTree { value?: string | boolean | number | RegExp; } - interface RegexLiteral extends Literal { + interface RegExpLiteral extends Literal { regex: { pattern: string; flags: string; @@ -258,6 +256,7 @@ declare module ESTree { interface YieldExpression extends Expression { argument?: Expression; + delegate: boolean; } interface TemplateLiteral extends Expression { @@ -312,7 +311,7 @@ declare module ESTree { } interface MethodDefinition extends Node { - key: Identifier; + key: Expression; value: FunctionExpression; kind: string; computed: boolean; @@ -330,40 +329,40 @@ declare module ESTree { property: Identifier; } - interface ImportDeclaration extends Node { + interface ModuleDeclaration extends Node {} + + interface ModuleSpecifier extends Node { + local: Identifier; + } + + interface ImportDeclaration extends ModuleDeclaration { specifiers: Array; source: Literal; } - interface ImportSpecifier { + interface ImportSpecifier extends ModuleSpecifier { imported: Identifier; - local: Identifier; } - interface ImportDefaultSpecifier { - local: Identifier; - } + interface ImportDefaultSpecifier extends ModuleSpecifier {} - interface ImportNamespaceSpecifier { - local: Identifier; - } + interface ImportNamespaceSpecifier extends ModuleSpecifier {} - interface ExportNamedDeclaration extends Node { + interface ExportNamedDeclaration extends ModuleDeclaration { declaration?: Declaration; specifiers: Array; source?: Literal; } - interface ExportSpecifier { + interface ExportSpecifier extends ModuleSpecifier { exported: Identifier; - local: Identifier; } - interface ExportDefaultDeclaration extends Node { + interface ExportDefaultDeclaration extends ModuleDeclaration { declaration: Declaration | Expression; } - interface ExportAllDeclaration extends Node { + interface ExportAllDeclaration extends ModuleDeclaration { source: Literal; } -} \ No newline at end of file +} From 5e11cf3c90ae085c78b4d11e6b952a2ad3dedce0 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 30 Jul 2015 23:41:54 -0700 Subject: [PATCH 2/6] Update estree-tests.ts --- estree/estree-tests.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/estree/estree-tests.ts b/estree/estree-tests.ts index bbf16586d..d119f6ac0 100644 --- a/estree/estree-tests.ts +++ b/estree/estree-tests.ts @@ -59,7 +59,6 @@ expression = withStatement.object; var switchStatement: ESTree.SwitchStatement; expression = switchStatement.discriminant; switchCase = switchStatement.cases[0]; -boolean = switchStatement.lexical; // ReturnStatement var returnStatement: ESTree.ReturnStatement; @@ -164,7 +163,6 @@ statement = switchCase.consequent[0]; // CatchClause string = catchClause.type; pattern = catchClause.param; -expression = catchClause.guard; blockStatement = catchClause.body; // Misc From 702708845497a9e65430518b4ad8222e2800911f Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 30 Jul 2015 23:46:34 -0700 Subject: [PATCH 3/6] Add definitions for Facebook Flow AST extensions --- estree/flow.d.ts | 174 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 estree/flow.d.ts diff --git a/estree/flow.d.ts b/estree/flow.d.ts new file mode 100644 index 000000000..43281c6c8 --- /dev/null +++ b/estree/flow.d.ts @@ -0,0 +1,174 @@ +// Type definitions for ESTree AST extensions for Facebook Flow +// Project: https://github.com/estree/estree +// Definitions by: RReverser +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module ESTree { + interface FlowTypeAnnotation extends Node { + _flowTypeAnnotationBrand: any; + } + + interface FlowBaseTypeAnnotation extends FlowTypeAnnotation {} + + interface FlowLiteralTypeAnnotation extends FlowTypeAnnotation, Literal {} + + interface FlowDeclaration extends Declaration {} + + interface AnyTypeAnnotation extends FlowBaseTypeAnnotation {} + + interface ArrayTypeAnnotation extends FlowTypeAnnotation { + elementType: FlowTypeAnnotation; + } + + interface BooleanLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {} + + interface BooleanTypeAnnotation extends FlowBaseTypeAnnotation {} + + interface ClassImplements extends Node { + id: Identifier; + typeParameters?: TypeParameterInstantiation; + } + + interface ClassProperty { + key: Expression; + value?: Expression; + typeAnnotation?: TypeAnnotation; + computed: boolean; + static: boolean; + } + + interface DeclareClass extends FlowDeclaration { + id: Identifier; + typeParameters?: TypeParameterDeclaration; + body: ObjectTypeAnnotation; + extends: Array; + } + + interface DeclareFunction extends FlowDeclaration { + id: Identifier; + } + + interface DeclareModule extends FlowDeclaration { + id: Literal | Identifier; + body: BlockStatement; + } + + interface DeclareVariable extends FlowDeclaration { + id: Identifier; + } + + interface FunctionTypeAnnotation extends FlowTypeAnnotation { + params: Array; + returnType: FlowTypeAnnotation; + rest?: FunctionTypeParam; + typeParameters?: TypeParameterDeclaration; + } + + interface FunctionTypeParam { + name: Identifier; + typeAnnotation: FlowTypeAnnotation; + optional: boolean; + } + + interface GenericTypeAnnotation extends FlowTypeAnnotation { + id: Identifier | QualifiedTypeIdentifier; + typeParameters?: TypeParameterInstantiation; + } + + interface InterfaceExtends extends Node { + id: Identifier | QualifiedTypeIdentifier; + typeParameters?: TypeParameterInstantiation; + } + + interface InterfaceDeclaration extends FlowDeclaration { + id: Identifier; + typeParameters?: TypeParameterDeclaration; + extends: Array; + body: ObjectTypeAnnotation; + } + + interface IntersectionTypeAnnotation extends FlowTypeAnnotation { + types: Array; + } + + interface MixedTypeAnnotation extends FlowBaseTypeAnnotation {} + + interface NullableTypeAnnotation extends FlowTypeAnnotation { + typeAnnotation: TypeAnnotation; + } + + interface NumberLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {} + + interface NumberTypeAnnotation extends FlowBaseTypeAnnotation {} + + interface StringLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {} + + interface StringTypeAnnotation extends FlowBaseTypeAnnotation {} + + interface TupleTypeAnnotation extends FlowTypeAnnotation { + types: Array; + } + + interface TypeofTypeAnnotation extends FlowTypeAnnotation { + argument: FlowTypeAnnotation; + } + + interface TypeAlias extends FlowDeclaration { + id: Identifier; + typeParameters?: TypeParameterDeclaration; + right: FlowTypeAnnotation; + } + + interface TypeAnnotation extends Node { + typeAnnotation: FlowTypeAnnotation; + } + + interface TypeCastExpression extends Expression { + expression: Expression; + typeAnnotation: TypeAnnotation; + } + + interface TypeParameterDeclaration extends Node { + params: Array; + } + + interface TypeParameterInstantiation extends Node { + params: Array; + } + + interface ObjectTypeAnnotation extends FlowTypeAnnotation { + properties: Array; + indexers: Array; + callProperties: Array; + } + + interface ObjectTypeCallProperty extends Node { + value: FunctionTypeAnnotation; + static: boolean; + } + + interface ObjectTypeIndexer extends Node { + id: Identifier; + key: FlowTypeAnnotation; + value: FlowTypeAnnotation; + static: boolean; + } + + interface ObjectTypeProperty extends Node { + key: Expression; + value: FlowTypeAnnotation; + optional: boolean; + static: boolean; + } + + interface QualifiedTypeIdentifier extends Node { + qualification: Identifier | QualifiedTypeIdentifier; + id: Identifier; + } + + interface UnionTypeAnnotation extends FlowTypeAnnotation { + types: Array; + } + + interface VoidTypeAnnotation extends FlowBaseTypeAnnotation {} +} From f6aec8b1c50cc6d1b12b1c3a8d89de227c0d3721 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 30 Jul 2015 23:49:13 -0700 Subject: [PATCH 4/6] Fix TemplateElement.value.value -> .value.raw Issue: https://github.com/estree/estree/issues/97 --- estree/estree.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/estree/estree.d.ts b/estree/estree.d.ts index be60f8dbf..76bc94279 100644 --- a/estree/estree.d.ts +++ b/estree/estree.d.ts @@ -273,7 +273,7 @@ declare module ESTree { tail: boolean; value: { cooked: string; - value: string; + raw: string; }; } From 7bcd3629afaaf7ee3092cf40c4adb54641c0d541 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 30 Jul 2015 23:51:34 -0700 Subject: [PATCH 5/6] Remove brand property as it's not used in other ESTree defs --- estree/flow.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/estree/flow.d.ts b/estree/flow.d.ts index 43281c6c8..7ebb56e50 100644 --- a/estree/flow.d.ts +++ b/estree/flow.d.ts @@ -4,9 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module ESTree { - interface FlowTypeAnnotation extends Node { - _flowTypeAnnotationBrand: any; - } + interface FlowTypeAnnotation extends Node {} interface FlowBaseTypeAnnotation extends FlowTypeAnnotation {} From b8b75340b71b8de2b16e0bec47c36567c12e4faa Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 30 Jul 2015 23:53:32 -0700 Subject: [PATCH 6/6] Add reference to estree.d.ts as dependency --- estree/flow.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/estree/flow.d.ts b/estree/flow.d.ts index 7ebb56e50..b34e56fb9 100644 --- a/estree/flow.d.ts +++ b/estree/flow.d.ts @@ -3,6 +3,8 @@ // Definitions by: RReverser // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module ESTree { interface FlowTypeAnnotation extends Node {}