From de40546d941fa94473d605efd2085a839729077e Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Mon, 23 May 2016 10:17:36 +0300 Subject: [PATCH] refactoring --- package.json | 2 +- typings.json | 2 +- typings/browser.d.ts | 9 +- typings/browser/ambient/escodegen/index.d.ts | 300 ++++++++---------- typings/browser/ambient/estraverse/index.d.ts | 24 ++ typings/main.d.ts | 1 + typings/main/ambient/escodegen/index.d.ts | 26 -- typings/main/ambient/estraverse/index.d.ts | 24 ++ 8 files changed, 193 insertions(+), 195 deletions(-) create mode 100644 typings/browser/ambient/estraverse/index.d.ts create mode 100644 typings/main/ambient/estraverse/index.d.ts diff --git a/package.json b/package.json index 05244365..38d54ba2 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "tsc:w": "tsc -w", "lite": "lite-server", "start": "concurrent \"npm run tsc:w\" \"npm run lite\" ", - "test": "node tests/dev-test.js" + "tests": "node tests/dev-test.js" }, "author": { "name": "sanex3339" diff --git a/typings.json b/typings.json index fe51b9e8..2e55983e 100644 --- a/typings.json +++ b/typings.json @@ -6,6 +6,6 @@ "estree": "github:DefinitelyTyped/DefinitelyTyped/estree/estree.d.ts", "esprima": "github:DefinitelyTyped/DefinitelyTyped/esprima/esprima.d.ts", "escodegen": "github:DefinitelyTyped/DefinitelyTyped/escodegen/escodegen.d.ts", - "estraverse": "github:DefinitelyTyped/DefinitelyTyped/escodegen/estraverse.d.ts" + "estraverse": "github:DefinitelyTyped/DefinitelyTyped/estraverse/estraverse.d.ts" } } diff --git a/typings/browser.d.ts b/typings/browser.d.ts index e89af714..2d06ba72 100644 --- a/typings/browser.d.ts +++ b/typings/browser.d.ts @@ -1,4 +1,5 @@ -/// -/// -/// -/// +/// +/// +/// +/// +/// \ No newline at end of file diff --git a/typings/browser/ambient/escodegen/index.d.ts b/typings/browser/ambient/escodegen/index.d.ts index 235ad973..51aba52e 100644 --- a/typings/browser/ambient/escodegen/index.d.ts +++ b/typings/browser/ambient/escodegen/index.d.ts @@ -7,171 +7,145 @@ declare module 'escodegen' { - export interface FormatOptions { - /** - * The indent options - */ - indent?: IndentOptions; - /** - * New line string. Default is '\n'. - */ - newline?: string; - /** - * White space string. Default is standard ' ' (\x20). - */ - space?: string; - /** - * Enforce JSON format of numeric and string literals. This option takes precedence over option.format.hexadecimal and option.format.quotes. Default is false. - */ - json?: boolean; - /** - * Try to generate shorter numeric literals than toString() (9.8.1). Default is false. - */ - renumber?: boolean; - /** - * Generate hexadecimal a numeric literal if it is shorter than its equivalents. Requires option.format.renumber. Default is false. - */ - hexadecimal?: boolean; - /** - * Delimiter to use for string literals. Accepted values are: 'single', 'double', and 'auto'. When 'auto' is specified, escodegen selects a delimiter that results in a shorter literal. Default is 'single'. - */ - quotes?: string; - /** - * Escape as few characters in string literals as necessary. Default is false. - */ - escapeless?: boolean; - /** - * Do not include superfluous whitespace characters and line terminators. Default is false. - */ - compact?: boolean; - /** - * Preserve parentheses in new expressions that have no arguments. Default is true. - */ - parentheses?: boolean; - /** - * Preserve semicolons at the end of blocks and programs. Default is true. - */ - semicolons?: boolean; - safeConcatenation?: boolean; - preserveBlankLines?: boolean; - } - - export interface IndentOptions { - /** - * Indent string. Default is 4 spaces (' '). - */ - style?: string; - /** - * Base indent level. Default is 0. - */ - base?: number; - /** - * Adjust the indentation of multiline comments to keep asterisks vertically aligned. Default is false. - */ - adjustMultilineComment?: boolean; - } - - export interface MozillaOptions { - /** - * Default: false - */ - starlessGenerator?: boolean; - /** - * Default: false - */ - parenthesizedComprehensionBlock?: boolean; - /** - * Default: false - */ - comprehensionExpressionStartsWithAssignment?: boolean; - } - - export interface GenerateOptions { - /** - * The format options - */ - format?: FormatOptions; - moz?: MozillaOptions; - /** - * Mozilla Parser API compatible parse function, e.g., the parse function exported by esprima. If it is provided, generator tries to use the 'raw' representation. See esprima raw information. Default is null. - */ - parse?: Function; - /** - * If comments are attached to AST, escodegen is going to emit comments to output code. Default is false. - */ - comment?: boolean; - /** - * sourceMap is the source maps's source filename, that's a name that will show up in the browser debugger for the generated source (if source-maps is enabled). - * If a non-empty string value is provided, generate a source map. - */ - sourceMap?: string; - /** - * . If sourceMapWithCode is true generator returns output hash, where output.map is a source-map representation, which can be serialized as output.map.toString(). output.code is a string with generated JS code (note that it's not going to have //@ sourceMappingURL comment in it). - */ - sourceMapWithCode?: boolean; - /** - * Optionally option.sourceContent string can be passed (which represents original source of the file, for example it could be a source of coffeescript from which JS is being generated), if provided generated source map will have original source embedded in it. - */ - sourceContent?: string; - sourceCode?: string; - /** - * Optionally option.sourceMapRoot can be provided, in which case option.sourceMap will be treated as relative to it. For more information about source map itself, see source map library document, V3 draft and HTML5Rocks introduction. Default is undefined - * sourceMapRoot is the source root for the source map (see the Mozilla documentation). If sourceMapWithCode is truthy, an object is returned from generate() of the form: { code: .. , map: .. }. If file is provided, it will be used as file property of generated source map. - */ - sourceMapRoot?: string; - /** - * Recognize DirectiveStatement and distinguish it from ExpressionStatement. Default: false - */ - directive?: boolean; - /** - * If file is provided, it will be used as file property of generated source map. - */ - file?: string; - /** - * Providing verbatim code generation option to Expression nodes. - * verbatim option is provided by user as string. When generating Expression code, - * looking up node[option.verbatim] value and dump it instead of normal code generation. - * - * @example - * - */ - verbatim?: string; - } - - export enum Precedence { - Sequence, - Yield, - Await, - Assignment, - Conditional, - ArrowFunction, - LogicalOR, - LogicalAND, - BitwiseOR, - BitwiseXOR, - BitwiseAND, - Equality, - Relational, - BitwiseSHIFT, - Additive, - Multiplicative, - Unary, - Postfix, - Call, - New, - TaggedTemplate, - Member, - Primary - } - + export interface FormatOptions { /** - * Produces given Abstract Syntax Tree as javascript code - * @param ast The Abstract Syntax Tree to generate code from - * @param options The generation options + * The indent options */ - export function generate(ast: any, options?: GenerateOptions): string; + indent?: IndentOptions; /** - * Attaching the comments is needed to keep the comments and to allow blank lines to be preserved. + * New line string. Default is '\n'. */ - export function attachComments(ast: any, comments: any, tokens: any): any; + newline?: string; + /** + * White space string. Default is standard ' ' (\x20). + */ + space?: string; + /** + * Enforce JSON format of numeric and string literals. This option takes precedence over option.format.hexadecimal and option.format.quotes. Default is false. + */ + json?: boolean; + /** + * Try to generate shorter numeric literals than toString() (9.8.1). Default is false. + */ + renumber?: boolean; + /** + * Generate hexadecimal a numeric literal if it is shorter than its equivalents. Requires option.format.renumber. Default is false. + */ + hexadecimal?: boolean; + /** + * Delimiter to use for string literals. Accepted values are: 'single', 'double', and 'auto'. When 'auto' is specified, escodegen selects a delimiter that results in a shorter literal. Default is 'single'. + */ + quotes?: string; + /** + * Escape as few characters in string literals as necessary. Default is false. + */ + escapeless?: boolean; + /** + * Do not include superfluous whitespace characters and line terminators. Default is false. + */ + compact?: boolean; + /** + * Preserve parentheses in new expressions that have no arguments. Default is true. + */ + parentheses?: boolean; + /** + * Preserve semicolons at the end of blocks and programs. Default is true. + */ + semicolons?: boolean; + safeConcatenation?: boolean; + preserveBlankLines?: boolean; + } + + export interface IndentOptions { + /** + * Indent string. Default is 4 spaces (' '). + */ + style?: string; + /** + * Base indent level. Default is 0. + */ + base?: number; + /** + * Adjust the indentation of multiline comments to keep asterisks vertically aligned. Default is false. + */ + adjustMultilineComment?: boolean; + } + + export interface MozillaOptions { + /** + * Default: false + */ + starlessGenerator?: boolean; + /** + * Default: false + */ + parenthesizedComprehensionBlock?: boolean; + /** + * Default: false + */ + comprehensionExpressionStartsWithAssignment?: boolean; + } + + export interface GenerateOptions { + /** + * The format options + */ + format?: FormatOptions; + moz?: MozillaOptions; + /** + * Mozilla Parser API compatible parse function, e.g., the parse function exported by esprima. If it is provided, generator tries to use the 'raw' representation. See esprima raw information. Default is null. + */ + parse?: Function; + /** + * If comments are attached to AST, escodegen is going to emit comments to output code. Default is false. + */ + comment?: boolean; + /** + * sourceMap is the source maps's source filename, that's a name that will show up in the browser debugger for the generated source (if source-maps is enabled). + * If a non-empty string value is provided, generate a source map. + */ + sourceMap?: string; + /** + * . If sourceMapWithCode is true generator returns output hash, where output.map is a source-map representation, which can be serialized as output.map.toString(). output.code is a string with generated JS code (note that it's not going to have //@ sourceMappingURL comment in it). + */ + sourceMapWithCode?: boolean; + /** + * Optionally option.sourceContent string can be passed (which represents original source of the file, for example it could be a source of coffeescript from which JS is being generated), if provided generated source map will have original source embedded in it. + */ + sourceContent?: string; + sourceCode?: string; + /** + * Optionally option.sourceMapRoot can be provided, in which case option.sourceMap will be treated as relative to it. For more information about source map itself, see source map library document, V3 draft and HTML5Rocks introduction. Default is undefined + * sourceMapRoot is the source root for the source map (see the Mozilla documentation). If sourceMapWithCode is truthy, an object is returned from generate() of the form: { code: .. , map: .. }. If file is provided, it will be used as file property of generated source map. + */ + sourceMapRoot?: string; + /** + * Recognize DirectiveStatement and distinguish it from ExpressionStatement. Default: false + */ + directive?: boolean; + /** + * If file is provided, it will be used as file property of generated source map. + */ + file?: string; + /** + * Providing verbatim code generation option to Expression nodes. + * verbatim option is provided by user as string. When generating Expression code, + * looking up node[option.verbatim] value and dump it instead of normal code generation. + * + * @example + * + */ + verbatim?: string; + } + + /** + * Produces given Abstract Syntax Tree as javascript code + * @param ast The Abstract Syntax Tree to generate code from + * @param options The generation options + */ + export function generate(ast: any, options?: GenerateOptions): string; + /** + * Attaching the comments is needed to keep the comments and to allow blank lines to be preserved. + */ + export function attachComments(ast: any, comments: any, tokens: any): any; } \ No newline at end of file diff --git a/typings/browser/ambient/estraverse/index.d.ts b/typings/browser/ambient/estraverse/index.d.ts new file mode 100644 index 00000000..17519ced --- /dev/null +++ b/typings/browser/ambient/estraverse/index.d.ts @@ -0,0 +1,24 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/estraverse/estraverse.d.ts +// Type definitions for estraverse +// Project: https://github.com/estools/estraverse +// Definitions by: Sanex3339 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'estraverse' { + export interface Visitor { + enter?: (node: any, parentNode: any) => any; + leave?: (node: any, parentNode: any) => any; + + fallback?: string; + + keys?: {}; + } + + export enum VisitorOption { + Skip, Break, Remove + } + + export function traverse (ast: any, visitor: Visitor): any; + export function replace (ast: any, visitor: Visitor): any; +} \ No newline at end of file diff --git a/typings/main.d.ts b/typings/main.d.ts index e89af714..037c3ccc 100644 --- a/typings/main.d.ts +++ b/typings/main.d.ts @@ -1,4 +1,5 @@ /// /// +/// /// /// diff --git a/typings/main/ambient/escodegen/index.d.ts b/typings/main/ambient/escodegen/index.d.ts index a94827d3..51aba52e 100644 --- a/typings/main/ambient/escodegen/index.d.ts +++ b/typings/main/ambient/escodegen/index.d.ts @@ -138,32 +138,6 @@ declare module 'escodegen' { verbatim?: string; } - export enum Precedence { - Sequence, - Yield, - Await, - Assignment, - Conditional, - ArrowFunction, - LogicalOR, - LogicalAND, - BitwiseOR, - BitwiseXOR, - BitwiseAND, - Equality, - Relational, - BitwiseSHIFT, - Additive, - Multiplicative, - Unary, - Postfix, - Call, - New, - TaggedTemplate, - Member, - Primary -} - /** * Produces given Abstract Syntax Tree as javascript code * @param ast The Abstract Syntax Tree to generate code from diff --git a/typings/main/ambient/estraverse/index.d.ts b/typings/main/ambient/estraverse/index.d.ts new file mode 100644 index 00000000..17519ced --- /dev/null +++ b/typings/main/ambient/estraverse/index.d.ts @@ -0,0 +1,24 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/estraverse/estraverse.d.ts +// Type definitions for estraverse +// Project: https://github.com/estools/estraverse +// Definitions by: Sanex3339 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'estraverse' { + export interface Visitor { + enter?: (node: any, parentNode: any) => any; + leave?: (node: any, parentNode: any) => any; + + fallback?: string; + + keys?: {}; + } + + export enum VisitorOption { + Skip, Break, Remove + } + + export function traverse (ast: any, visitor: Visitor): any; + export function replace (ast: any, visitor: Visitor): any; +} \ No newline at end of file