source: trip-planner-front/node_modules/es-module-lexer/types/lexer.d.ts@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1export interface ImportSpecifier {
2 /**
3 * Module name
4 *
5 * To handle escape sequences in specifier strings, the .n field of imported specifiers will be provided where possible.
6 *
7 * For dynamic import expressions, this field will be empty if not a valid JS string.
8 *
9 * @example
10 * const [imports1, exports1] = parse(String.raw`import './\u0061\u0062.js'`);
11 * imports1[0].n;
12 * // Returns "./ab.js"
13 *
14 * const [imports2, exports2] = parse(`import("./ab.js")`);
15 * imports2[0].n;
16 * // Returns "./ab.js"
17 *
18 * const [imports3, exports3] = parse(`import("./" + "ab.js")`);
19 * imports3[0].n;
20 * // Returns undefined
21 */
22 readonly n: string | undefined;
23 /**
24 * Start of module specifier
25 *
26 * @example
27 * const source = `import { a } from 'asdf'`;
28 * const [imports, exports] = parse(source);
29 * source.substring(imports[0].s, imports[0].e);
30 * // Returns "asdf"
31 */
32 readonly s: number;
33 /**
34 * End of module specifier
35 */
36 readonly e: number;
37
38 /**
39 * Start of import statement
40 *
41 * @example
42 * const source = `import { a } from 'asdf'`;
43 * const [imports, exports] = parse(source);
44 * source.substring(imports[0].ss, imports[0].se);
45 * // Returns "import { a } from 'asdf';"
46 */
47 readonly ss: number;
48 /**
49 * End of import statement
50 */
51 readonly se: number;
52
53 /**
54 * If this import statement is a dynamic import, this is the start value.
55 * Otherwise this is `-1`.
56 */
57 readonly d: number;
58
59 /**
60 * If this import has an import assertion, this is the start value.
61 * Otherwise this is `-1`.
62 */
63 readonly a: number;
64}
65
66/**
67 * Wait for init to resolve before calling `parse`.
68 */
69export const init: Promise<void>;
70
71/**
72 * Outputs the list of exports and locations of import specifiers,
73 * including dynamic import and import meta handling.
74 *
75 * @param source Source code to parser
76 * @param name Optional sourcename
77 * @returns Tuple contaning imports list and exports list.
78 */
79export function parse(
80 source: string,
81 name?: string
82): readonly [
83 imports: ReadonlyArray<ImportSpecifier>,
84 exports: ReadonlyArray<string>
85];
Note: See TracBrowser for help on using the repository browser.