UNPKG

1.48 kBTypeScriptView Raw
1export declare type Token =
2 | { type: "StringLiteral"; value: string; closed: boolean }
3 | { type: "NoSubstitutionTemplate"; value: string; closed: boolean }
4 | { type: "TemplateHead"; value: string }
5 | { type: "TemplateMiddle"; value: string }
6 | { type: "TemplateTail"; value: string; closed: boolean }
7 | { type: "RegularExpressionLiteral"; value: string; closed: boolean }
8 | { type: "MultiLineComment"; value: string; closed: boolean }
9 | { type: "SingleLineComment"; value: string }
10 | { type: "HashbangComment"; value: string }
11 | { type: "IdentifierName"; value: string }
12 | { type: "PrivateIdentifier"; value: string }
13 | { type: "NumericLiteral"; value: string }
14 | { type: "Punctuator"; value: string }
15 | { type: "WhiteSpace"; value: string }
16 | { type: "LineTerminatorSequence"; value: string }
17 | { type: "Invalid"; value: string };
18
19export declare type JSXToken =
20 | { type: "JSXString"; value: string; closed: boolean }
21 | { type: "JSXText"; value: string }
22 | { type: "JSXIdentifier"; value: string }
23 | { type: "JSXPunctuator"; value: string }
24 | { type: "JSXInvalid"; value: string };
25
26declare function jsTokens(
27 input: string,
28 options: { jsx: true }
29): Iterable<Token | JSXToken>;
30
31declare function jsTokens(
32 input: string,
33 options?: { jsx?: boolean }
34): Iterable<Token>;
35
36// @ts-expect-error TypeScript complains about _both_ exporting types _and_ using `export =` but it seems to work fine in practice.
37export = jsTokens;