UNPKG

3.95 kBTypeScriptView Raw
1// Type definitions for Esprima 4.0
2// Project: http://esprima.org
3// Definitions by: teppeis <https://github.com/teppeis>, RReverser <https://github.com/RReverser>, peter-scott <https://github.com/peter-scott>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6import * as ESTree from 'estree';
7
8export const version: string;
9
10export function parseScript(input: string, config?: ParseOptions, delegate?: (node: ESTree.Node, meta: any) => void): Program;
11export function parseModule(input: string, config?: ParseOptions, delegate?: (node: ESTree.Node, meta: any) => void): Program;
12export function tokenize(input: string, config?: TokenizeOptions): Token[];
13
14export interface Program extends ESTree.Program {
15 tokens?: Token[] | undefined;
16}
17
18export interface Token {
19 type: string;
20 value: string;
21}
22
23export interface ParseOptions {
24 jsx?: boolean | undefined;
25 range?: boolean | undefined;
26 loc?: boolean | undefined;
27 tolerant?: boolean | undefined;
28 tokens?: boolean | undefined;
29 comment?: boolean | undefined;
30}
31
32export interface TokenizeOptions {
33 tolerant?: boolean | undefined;
34 range?: boolean | undefined;
35 loc?: boolean | undefined;
36 comment?: boolean | undefined;
37}
38
39export const Syntax: {
40 ArrayExpression: 'ArrayExpression',
41 ArrayPattern: 'ArrayPattern',
42 ArrowFunctionExpression: 'ArrowFunctionExpression',
43 AssignmentExpression: 'AssignmentExpression',
44 AssignmentPattern: 'AssignmentPattern',
45 AwaitExpression: 'AwaitExpression',
46 BinaryExpression: 'BinaryExpression',
47 BlockStatement: 'BlockStatement',
48 BreakStatement: 'BreakStatement',
49 CallExpression: 'CallExpression',
50 CatchClause: 'CatchClause',
51 ClassBody: 'ClassBody',
52 ClassDeclaration: 'ClassDeclaration',
53 ClassExpression: 'ClassExpression',
54 ConditionalExpression: 'ConditionalExpression',
55 ContinueStatement: 'ContinueStatement',
56 DebuggerStatement: 'DebuggerStatement',
57 DoWhileStatement: 'DoWhileStatement',
58 EmptyStatement: 'EmptyStatement',
59 ExportAllDeclaration: 'ExportAllDeclaration',
60 ExportDefaultDeclaration: 'ExportDefaultDeclaration',
61 ExportNamedDeclaration: 'ExportNamedDeclaration',
62 ExportSpecifier: 'ExportSpecifier',
63 ExpressionStatement: 'ExpressionStatement',
64 ForInStatement: 'ForInStatement',
65 ForOfStatement: 'ForOfStatement',
66 ForStatement: 'ForStatement',
67 FunctionDeclaration: 'FunctionDeclaration',
68 FunctionExpression: 'FunctionExpression',
69 Identifier: 'Identifier',
70 IfStatement: 'IfStatement',
71 Import: 'Import',
72 ImportDeclaration: 'ImportDeclaration',
73 ImportDefaultSpecifier: 'ImportDefaultSpecifier',
74 ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
75 ImportSpecifier: 'ImportSpecifier',
76 LabeledStatement: 'LabeledStatement',
77 Literal: 'Literal',
78 LogicalExpression: 'LogicalExpression',
79 MemberExpression: 'MemberExpression',
80 MetaProperty: 'MetaProperty',
81 MethodDefinition: 'MethodDefinition',
82 NewExpression: 'NewExpression',
83 ObjectExpression: 'ObjectExpression',
84 ObjectPattern: 'ObjectPattern',
85 Program: 'Program',
86 Property: 'Property',
87 RestElement: 'RestElement',
88 ReturnStatement: 'ReturnStatement',
89 SequenceExpression: 'SequenceExpression',
90 SpreadElement: 'SpreadElement',
91 Super: 'Super',
92 SwitchCase: 'SwitchCase',
93 SwitchStatement: 'SwitchStatement',
94 TaggedTemplateExpression: 'TaggedTemplateExpression',
95 TemplateElement: 'TemplateElement',
96 TemplateLiteral: 'TemplateLiteral',
97 ThisExpression: 'ThisExpression',
98 ThrowStatement: 'ThrowStatement',
99 TryStatement: 'TryStatement',
100 UnaryExpression: 'UnaryExpression',
101 UpdateExpression: 'UpdateExpression',
102 VariableDeclaration: 'VariableDeclaration',
103 VariableDeclarator: 'VariableDeclarator',
104 WhileStatement: 'WhileStatement',
105 WithStatement: 'WithStatement',
106 YieldExpression: 'YieldExpression'
107};