UNPKG

1.63 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at
5 * http://polymer.github.io/LICENSE.txt
6 * The complete set of authors may be found at
7 * http://polymer.github.io/AUTHORS.txt
8 * The complete set of contributors may be found at
9 * http://polymer.github.io/CONTRIBUTORS.txt
10 * Code distributed by Google as part of the polymer project is also
11 * subject to an additional IP rights grant found at
12 * http://polymer.github.io/PATENTS.txt
13 */
14import * as babel from '@babel/types';
15import { Node } from '@babel/types';
16import { SourceRange } from '../model/model';
17import { Options as ParsedDocumentOptions, ParsedDocument, StringifyOptions } from '../parser/document';
18import { Visitor } from './estree-visitor';
19export { Visitor } from './estree-visitor';
20export interface Options extends ParsedDocumentOptions<babel.File> {
21 parsedAsSourceType: 'script' | 'module';
22}
23export declare class JavaScriptDocument extends ParsedDocument<Node, Visitor> {
24 readonly type = "js";
25 private visitorSkips;
26 ast: babel.File;
27 /**
28 * How the js document was parsed. If 'module' then the source code is
29 * definitely an ES6 module, as it has imports or exports. If 'script' then
30 * it may be an ES6 module with no imports or exports, or it may be a
31 * script.
32 */
33 parsedAsSourceType: 'script' | 'module';
34 constructor(from: Options);
35 visit(visitors: Visitor[]): void;
36 protected _sourceRangeForNode(node: Node): SourceRange | undefined;
37 stringify(options?: StringifyOptions): string;
38}