diff --git a/.changeset/token-delimiters.md b/.changeset/token-delimiters.md new file mode 100644 index 00000000..0f494099 --- /dev/null +++ b/.changeset/token-delimiters.md @@ -0,0 +1,5 @@ +--- +'esrap': minor +--- + +feat: add a `tokens` option to the `ts` and `tsx` languages. Pass the parser's tokens and everything inside a node that no node boundary locates is mapped to its source position: the brackets of computed keys, the parentheses of parameter lists, calls and control-flow heads, the braces of import and export lists, enums and static blocks, template interpolations, and keywords after a node's first token such as `function` after `async`, `else`, `finally`, `while`, `default`, `type`, class and member modifiers, `extends`, `implements`, `in`, `of`, `as` and `satisfies`. Closing delimiters at a node's end are mapped from the node's end without tokens. diff --git a/src/languages/ts/index.js b/src/languages/ts/index.js index efb0d1ff..1c60cc7a 100644 --- a/src/languages/ts/index.js +++ b/src/languages/ts/index.js @@ -3,6 +3,9 @@ /** @import { TSOptions, BaseComment } from '../types.js' */ import { Context } from 'esrap'; +/** @typedef {{ line: number, column: number }} Position */ +import { token_locator } from './tokens.js'; + // Keep the public type parser-independent while checking all expression kinds. /** * @type {Record} @@ -146,6 +149,45 @@ function write_comment(comment, context) { } } +/** + * Where a node's keywords start: after its decorators, if any + * @param {TSESTree.Node & { decorators?: TSESTree.Decorator[] }} node + */ +function after_decorators(node) { + return node.decorators?.at(-1)?.loc?.end ?? node.loc?.start; +} + +/** + * Writes a token at a known source position (its start, or its whole location + * when the end is known too), or unmapped without one + * @param {Context} context + * @param {string} text + * @param {Position | { start: Position, end: Position } | undefined} at + */ +function write_at(context, text, at) { + if (!at) { + context.write(text); + return; + } + + const start = 'start' in at ? at.start : at; + context.location(start.line, start.column); + context.write(text); + if ('start' in at) context.location(at.end.line, at.end.column); +} + +/** + * Writes a closing delimiter that ends at `end` — the last character of a node + * whose grammar ends with it + * @param {Context} context + * @param {string} text + * @param {{ line: number, column: number } | undefined} end + */ +function write_before(context, text, end) { + if (end) context.location(end.line, end.column - text.length); + context.write(text); +} + /** * @param {Context} context * @param {string} token @@ -329,13 +371,15 @@ export default (options = {}) => { /** * @param {Context} context - * @param {{ attributes?: TSESTree.ImportAttribute[], assertions?: TSESTree.ImportAttribute[] }} node + * @param {TSESTree.Node & { attributes?: TSESTree.ImportAttribute[], assertions?: TSESTree.ImportAttribute[] }} node */ function write_import_attributes(context, node) { const attributes = node.attributes ?? node.assertions; if (!attributes || attributes.length === 0) return; - context.write(node.attributes ? ' with { ' : ' assert { '); + context.write(node.attributes ? ' with ' : ' assert '); + write_at(context, '{', enclosing(node, attributes[0], '{')); + context.write(' '); for (let i = 0; i < attributes.length; i += 1) { const { key, value } = attributes[i]; @@ -345,7 +389,8 @@ export default (options = {}) => { if (i < attributes.length - 1) context.write(', '); } - context.write(' }'); + context.write(' '); + write_at(context, '}', enclosing(node, attributes[attributes.length - 1], '}')); } /** @@ -477,6 +522,39 @@ export default (options = {}) => { } } + const { locate, enclosing } = token_locator(options); + + /** + * A parenthesised parameter list. `(` is the first one after `prefix` (the + * type parameters, name or key before the list) or, without one, in the + * node; `)` is the last one before `suffix` (the return type or body after + * the list) or the node's end. Both are looked up in `tokens`. + * @param {Context} context + * @param {TSESTree.Node} node + * @param {TSESTree.Node[]} params + * @param {TSESTree.Node | null | undefined} prefix + * @param {TSESTree.Node | null | undefined} suffix + */ + function write_params(context, node, params, prefix, suffix) { + const until = suffix?.loc?.start ?? node.loc?.end; + write_at(context, '(', locate(node, '(', prefix?.loc?.end ?? node.loc?.start, 'after')); + sequence(context, params, until ?? null, false); + write_at(context, ')', locate(node, ')', until, 'before')); + } + + /** + * A keyword that is not the first token of `node`, so only the tokens locate + * it: the first `word` after `from` (the node's start, or the end of what + * precedes the keyword) within the node. + * @param {Context} context + * @param {TSESTree.Node} node + * @param {string} word + * @param {Position | undefined} [from] + */ + function write_keyword(context, node, word, from = node.loc?.start) { + write_at(context, word, locate(node, word, from, 'after')); + } + const shared = { /** * @param {TSESTree.ArrayExpression | TSESTree.ArrayPattern} node @@ -491,7 +569,7 @@ export default (options = {}) => { node.loc?.end ?? null, false ); - context.write(']'); + write_before(context, ']', node.loc?.end); if ('typeAnnotation' in node && node.typeAnnotation) context.visit(node.typeAnnotation); }, @@ -569,7 +647,11 @@ export default (options = {}) => { const open = context.new(); const join = context.new(); - context.write('('); + write_at( + context, + '(', + locate(node, '(', (node.typeArguments ?? node.callee).loc?.end, 'after') + ); context.append(open); // if the final argument is multiline, it doesn't need to force all the @@ -622,7 +704,9 @@ export default (options = {}) => { join.write(' '); } - context.write(')'); + // a `new` expression may have no parentheses in the source + if (node.type === 'CallExpression') write_before(context, ')', node.loc?.end); + else write_at(context, ')', locate(node, ')', node.loc?.end, 'before')); }, /** @@ -632,9 +716,17 @@ export default (options = {}) => { 'ClassDeclaration|ClassExpression': (node, context) => { block_decorators(context, node); - if (node.declare) context.write('declare '); - if (node.abstract) context.write('abstract '); - context.write('class '); + const from = after_decorators(node); + if (node.declare) { + write_keyword(context, node, 'declare', from); + context.write(' '); + } + if (node.abstract) { + write_keyword(context, node, 'abstract', from); + context.write(' '); + } + write_keyword(context, node, 'class', from); + context.write(' '); if (node.id) { context.visit(node.id); @@ -649,7 +741,8 @@ export default (options = {}) => { } if (node.superClass) { - context.write('extends '); + write_keyword(context, node, 'extends', (node.typeParameters ?? node.id)?.loc?.end); + context.write(' '); // the `extends` clause is a LeftHandSideExpression; anything lower (a // logical/binary/conditional/etc.) must be parenthesized const wrap_super = @@ -666,7 +759,12 @@ export default (options = {}) => { } if (node.implements && node.implements.length > 0) { - context.write('implements'); + write_keyword( + context, + node, + 'implements', + (node.superClass ?? node.typeParameters ?? node.id)?.loc?.end + ); sequence(context, node.implements, node.body.loc?.start ?? null, true); } @@ -680,18 +778,29 @@ export default (options = {}) => { 'ForInStatement|ForOfStatement': (node, context) => { token(context, 'for', node); context.write(' '); - if (node.type === 'ForOfStatement' && node.await) context.write('await '); - context.write('('); + if (node.type === 'ForOfStatement' && node.await) { + write_keyword(context, node, 'await'); + context.write(' '); + } + write_at(context, '(', locate(node, '(', node.loc?.start, 'after')); if (node.left.type === 'VariableDeclaration') { - write_for_head_declaration(node.left, context); + write_for_head_declaration(node.left, context, false, write_keyword); } else { context.visit(node.left); } - context.write(node.type === 'ForInStatement' ? ' in ' : ' of '); + context.write(' '); + write_keyword( + context, + node, + node.type === 'ForInStatement' ? 'in' : 'of', + node.left.loc?.end + ); + context.write(' '); context.visit(node.right); - context.write(') '); + write_at(context, ')', locate(node, ')', node.body.loc?.start, 'before')); + context.write(' '); context.visit(node.body); }, @@ -700,8 +809,12 @@ export default (options = {}) => { * @param {Context} context */ 'FunctionDeclaration|FunctionExpression': (node, context) => { - if (node.async) context.write('async '); - context.write(node.generator ? 'function* ' : 'function '); + if (node.async) { + write_keyword(context, node, 'async'); + context.write(' '); + } + write_keyword(context, node, 'function'); + context.write(node.generator ? '* ' : ' '); if (node.id) track_binding(node.id); @@ -712,9 +825,13 @@ export default (options = {}) => { } track_bindings(node.params); - context.write('('); - sequence(context, node.params, (node.returnType ?? node.body).loc?.start ?? null, false); - context.write(')'); + write_params( + context, + node, + node.params, + node.typeParameters ?? node.id, + node.returnType ?? node.body + ); if (node.returnType) context.visit(node.returnType); @@ -730,36 +847,44 @@ export default (options = {}) => { 'MethodDefinition|TSAbstractMethodDefinition': (node, context) => { block_decorators(context, node); + const from = after_decorators(node); + // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions if (node.abstract || node.type === 'TSAbstractMethodDefinition') { - context.write('abstract '); + write_keyword(context, node, 'abstract', from); + context.write(' '); } if (node.accessibility) { - context.write(node.accessibility + ' '); + write_keyword(context, node, node.accessibility, from); + context.write(' '); } if (node.override) { - context.write('override '); + write_keyword(context, node, 'override', from); + context.write(' '); } if (node.static) { - context.write('static '); + write_keyword(context, node, 'static', from); + context.write(' '); } if (node.kind === 'get' || node.kind === 'set') { - context.write(node.kind + ' '); + write_keyword(context, node, node.kind, from); + context.write(' '); } if (node.value.async) { - context.write('async '); + write_keyword(context, node, 'async', from); + context.write(' '); } if (node.value.generator) context.write('*'); - if (node.computed) context.write('['); + if (node.computed) write_at(context, '[', enclosing(node, node.key, '[')); context.visit(node.key); - if (node.computed) context.write(']'); + if (node.computed) write_at(context, ']', enclosing(node, node.key, ']')); // optional method (`m?()`) if (node.optional) context.write('?'); @@ -769,14 +894,13 @@ export default (options = {}) => { if (type_parameters) context.visit(type_parameters); track_bindings(node.value.params); - context.write('('); - sequence( + write_params( context, + node, node.value.params, - (node.value.returnType ?? node.value.body)?.loc?.start ?? node.loc?.end ?? null, - false + type_parameters ?? node.key, + node.value.returnType ?? node.value.body ); - context.write(')'); if (node.value.returnType) context.visit(node.value.returnType); @@ -799,10 +923,16 @@ export default (options = {}) => { ) => { block_decorators(context, node); - if (node.declare) context.write('declare '); + const from = after_decorators(node); + + if (node.declare) { + write_keyword(context, node, 'declare', from); + context.write(' '); + } if (node.accessibility) { - context.write(node.accessibility + ' '); + write_keyword(context, node, node.accessibility, from); + context.write(' '); } if ( @@ -811,16 +941,24 @@ export default (options = {}) => { node.type === 'TSAbstractPropertyDefinition' || node.type === 'TSAbstractAccessorProperty' ) { - context.write('abstract '); + write_keyword(context, node, 'abstract', from); + context.write(' '); } if (node.static) { - context.write('static '); + write_keyword(context, node, 'static', from); + context.write(' '); } - if (node.override) context.write('override '); + if (node.override) { + write_keyword(context, node, 'override', from); + context.write(' '); + } - if (node.readonly) context.write('readonly '); + if (node.readonly) { + write_keyword(context, node, 'readonly', from); + context.write(' '); + } if ( // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions @@ -828,13 +966,14 @@ export default (options = {}) => { node.type === 'AccessorProperty' || node.type === 'TSAbstractAccessorProperty' ) { - context.write('accessor '); + write_keyword(context, node, 'accessor', from); + context.write(' '); } if (node.computed) { - context.write('['); + write_at(context, '[', enclosing(node, node.key, '[')); context.visit(node.key); - context.write(']'); + write_at(context, ']', enclosing(node, node.key, ']')); } else { context.visit(node.key); } @@ -890,17 +1029,11 @@ export default (options = {}) => { } // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions - track_bindings(node.parameters ?? node.params); - context.write('('); - sequence( - context, - // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions - node.parameters ?? node.params, - // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions - (node.typeAnnotation ?? node.returnType)?.loc?.start ?? node.loc?.end ?? null, - false - ); - context.write(')'); + const parameters = node.parameters ?? node.params; + // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions + const return_type = node.typeAnnotation ?? node.returnType; + track_bindings(parameters); + write_params(context, node, parameters, node.typeParameters, return_type); // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions if (node.typeAnnotation || node.returnType) { @@ -915,23 +1048,21 @@ export default (options = {}) => { */ 'TSFunctionType|TSConstructorType': (node, context) => { if (node.type === 'TSConstructorType') { - if (node.abstract) context.write('abstract '); - context.write('new '); + if (node.abstract) { + write_keyword(context, node, 'abstract'); + context.write(' '); + } + write_keyword(context, node, 'new'); + context.write(' '); } if (node.typeParameters) context.visit(node.typeParameters); // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions - track_bindings(node.parameters ?? node.params); - context.write('('); - sequence( - context, - // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions - node.parameters ?? node.params, - // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions - (node.typeAnnotation ?? node.returnType)?.loc?.start ?? node.loc?.end ?? null, - false - ); - context.write(')'); + const parameters = node.parameters ?? node.params; + // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions + const return_type = node.typeAnnotation ?? node.returnType; + track_bindings(parameters); + write_params(context, node, parameters, node.typeParameters, return_type); context.write(' => '); @@ -956,7 +1087,11 @@ export default (options = {}) => { node.type in EXPRESSIONS_PRECEDENCE && !BINDINGS.has(node) ); - if (!has_preceding_decorator(node)) { + // the node starts here unless its decorators are printed later (they + // precede `loc.start`) or were printed already and `loc.start` is + // one of them (Acorn ranges a class from decorators written before + // its `export`; typescript-estree from `class`, which then starts here) + if (has_preceding_decorator(node) === printed_decorators.has(node)) { context.location(node.loc.start.line, node.loc.start.column); } } @@ -992,16 +1127,23 @@ export default (options = {}) => { ArrayPattern: shared['ArrayExpression|ArrayPattern'], ArrowFunctionExpression: (node, context) => { - if (node.async) context.write('async '); + if (node.async) { + write_keyword(context, node, 'async'); + context.write(' '); + } if (node.typeParameters) { context.visit(node.typeParameters); } track_bindings(node.params); - context.write('('); - sequence(context, node.params, (node.returnType ?? node.body).loc?.start ?? null, false); - context.write(')'); + write_params( + context, + node, + node.params, + node.typeParameters ?? node.id, + node.returnType ?? node.body + ); if (node.returnType) context.visit(node.returnType); @@ -1130,9 +1272,13 @@ export default (options = {}) => { token(context, 'do', node); context.write(' '); context.visit(node.body); - context.write(' while ('); + context.write(' '); + write_keyword(context, node, 'while', node.body.loc?.end); + context.write(' '); + write_at(context, '(', locate(node, '(', node.body.loc?.end, 'after')); context.visit(node.test); - context.write(');'); + write_at(context, ')', locate(node, ')', node.loc?.end, 'before')); + context.write(';'); }, EmptyStatement(node, context) { @@ -1142,10 +1288,16 @@ export default (options = {}) => { ExportAllDeclaration(node, context) { token(context, 'export', node); - context.write(node.exportKind === 'type' ? ' type * ' : ' * '); + context.write(' '); + if (node.exportKind === 'type') { + write_keyword(context, node, 'type'); + context.write(' '); + } + context.write('* '); if (node.exported) { - context.write('as '); + write_keyword(context, node, 'as'); + context.write(' '); context.visit(node.exported); } @@ -1167,8 +1319,12 @@ export default (options = {}) => { }); } + // the declaration's decorators came first, so the node's start is written here + if (node.loc) context.location(node.loc.start.line, node.loc.start.column); token(context, 'export', node); - context.write(' default '); + context.write(' '); + write_keyword(context, node, 'default'); + context.write(' '); if (d.loc) { flush_comments_until(context, null, d.loc.start, true, false); @@ -1194,6 +1350,8 @@ export default (options = {}) => { }); } + // the declaration's decorators came first, so the node's start is written here + if (node.loc) context.location(node.loc.start.line, node.loc.start.column); token(context, 'export', node); context.write(' '); @@ -1208,11 +1366,14 @@ export default (options = {}) => { token(context, 'export', node); context.write(' '); - if (node.exportKind === 'type') context.write('type '); + if (node.exportKind === 'type') { + write_keyword(context, node, 'type'); + context.write(' '); + } - context.write('{'); + write_at(context, '{', locate(node, '{', node.loc?.start, 'after')); sequence(context, node.specifiers, node.source?.loc?.start ?? node.loc?.end ?? null, true); - context.write('}'); + write_at(context, '}', locate(node, '}', node.source?.loc?.start ?? node.loc?.end, 'before')); if (node.source) { context.write(' from '); @@ -1225,13 +1386,16 @@ export default (options = {}) => { ExportSpecifier(node, context) { if (node.exportKind === 'type') { - context.write('type '); + write_keyword(context, node, 'type'); + context.write(' '); } context.visit(node.local); if (!same_module_name(node.local, node.exported)) { - context.write(' as '); + context.write(' '); + write_keyword(context, node, 'as', node.local.loc?.end); + context.write(' '); context.visit(node.exported); } }, @@ -1245,11 +1409,12 @@ export default (options = {}) => { ForStatement: (node, context) => { token(context, 'for', node); - context.write(' ('); + context.write(' '); + write_at(context, '(', locate(node, '(', node.loc?.start, 'after')); if (node.init) { if (node.init.type === 'VariableDeclaration') { - write_for_head_declaration(node.init, context, true); + write_for_head_declaration(node.init, context, true, write_keyword); } else { maybe_wrap(context, node.init, contains_in_operator(node.init)); } @@ -1260,7 +1425,8 @@ export default (options = {}) => { context.write('; '); if (node.update) context.visit(node.update); - context.write(') '); + write_at(context, ')', locate(node, ')', node.body.loc?.start, 'before')); + context.write(' '); context.visit(node.body); }, @@ -1287,9 +1453,11 @@ export default (options = {}) => { IfStatement(node, context) { token(context, 'if', node); - context.write(' ('); + context.write(' '); + write_at(context, '(', locate(node, '(', node.loc?.start, 'after')); context.visit(node.test); - context.write(') '); + write_at(context, ')', locate(node, ')', node.consequent.loc?.start, 'before')); + context.write(' '); if (node.alternate && statement_ends_with_unmatched_if(node.consequent)) { // braces the source doesn't have map to the statement they wrap @@ -1309,7 +1477,8 @@ export default (options = {}) => { if (node.alternate) { context.space(); - context.write('else '); + write_keyword(context, node, 'else', node.consequent.loc?.end); + context.write(' '); context.visit(node.alternate); } }, @@ -1319,7 +1488,13 @@ export default (options = {}) => { context.write(' '); if (node.specifiers.length === 0) { - if (node.importKind === 'type') context.write('type {} from '); + if (node.importKind === 'type') { + write_keyword(context, node, 'type'); + context.write(' '); + write_at(context, '{', locate(node, '{', node.loc?.start, 'after')); + write_at(context, '}', locate(node, '}', node.source.loc?.start, 'before')); + context.write(' from '); + } context.visit(node.source); write_import_attributes(context, node); context.write(';'); @@ -1345,7 +1520,10 @@ export default (options = {}) => { } } - if (node.importKind == 'type') context.write('type '); + if (node.importKind == 'type') { + write_keyword(context, node, 'type'); + context.write(' '); + } if (default_specifier) { context.write(default_specifier.local.name, default_specifier); @@ -1357,9 +1535,9 @@ export default (options = {}) => { } if (named_specifiers.length > 0) { - context.write('{'); + write_at(context, '{', locate(node, '{', node.loc?.start, 'after')); sequence(context, named_specifiers, node.source.loc?.start ?? null, true); - context.write('}'); + write_at(context, '}', locate(node, '}', node.source.loc?.start, 'before')); } context.write(' from '); @@ -1370,7 +1548,7 @@ export default (options = {}) => { ImportExpression(node, context) { token(context, 'import', node); - context.write('('); + write_at(context, '(', locate(node, '(', node.loc?.start, 'after')); context.visit(node.source); //@ts-expect-error for some reason the types haven't been updated if (node.arguments) { @@ -1385,15 +1563,20 @@ export default (options = {}) => { context.write(', '); context.visit(node.options); } - context.write(')'); + write_before(context, ')', node.loc?.end); }, ImportSpecifier(node, context) { - if (node.importKind == 'type') context.write('type '); + if (node.importKind == 'type') { + write_keyword(context, node, 'type'); + context.write(' '); + } if (!same_module_name(node.imported, node.local)) { context.visit(node.imported); - context.write(' as '); + context.write(' '); + write_keyword(context, node, 'as', node.imported.loc?.end); + context.write(' '); context.visit(node.local); } else { context.visit(node.local); @@ -1436,9 +1619,9 @@ export default (options = {}) => { if (node.optional) { context.write('?.'); } - context.write('['); + write_at(context, '[', enclosing(node, node.property, '[')); context.visit(node.property); - context.write(']'); + write_before(context, ']', node.loc?.end); } else { context.write(node.optional ? '?.' : '.'); context.visit(node.property); @@ -1458,14 +1641,14 @@ export default (options = {}) => { ObjectExpression(node, context) { context.write('{'); sequence(context, node.properties, node.loc?.end ?? null, true); - context.write('}'); + write_before(context, '}', node.loc?.end); }, ObjectPattern(node, context) { inline_decorators(context, node); context.write('{'); sequence(context, node.properties, node.loc?.end ?? null, true); - context.write('}'); + write_before(context, '}', node.loc?.end); if (node.typeAnnotation) context.visit(node.typeAnnotation); }, @@ -1519,35 +1702,41 @@ export default (options = {}) => { node.value.type === 'FunctionExpression' && (node.method || node.kind === 'get' || node.kind === 'set') ) { - if (node.kind !== 'init') context.write(node.kind + ' '); - if (node.value.async) context.write('async '); + if (node.kind !== 'init') { + write_keyword(context, node, node.kind); + context.write(' '); + } + if (node.value.async) { + write_keyword(context, node, 'async'); + context.write(' '); + } if (node.value.generator) context.write('*'); - if (node.computed) context.write('['); + if (node.computed) write_at(context, '[', enclosing(node, node.key, '[')); context.visit(node.key); - if (node.computed) context.write(']'); + if (node.computed) write_at(context, ']', enclosing(node, node.key, ']')); if (node.value.typeParameters) context.visit(node.value.typeParameters); track_bindings(node.value.params); - context.write('('); - sequence( + write_params( context, + node, node.value.params, - (node.value.returnType ?? node.value.body).loc?.start ?? null, - false + node.value.typeParameters ?? node.key, + node.value.returnType ?? node.value.body ); - context.write(')'); if (node.value.returnType) context.visit(node.value.returnType); context.write(' '); context.visit(node.value.body); } else { - if (node.computed) context.write('['); + if (node.computed) write_at(context, '[', enclosing(node, node.key, '[')); if (node.kind === 'get' || node.kind === 'set') { - context.write(node.kind + ' '); + write_keyword(context, node, node.kind); + context.write(' '); } context.visit(node.key); if (node.computed) { - context.write(']'); + write_at(context, ']', enclosing(node, node.key, ']')); context.write(': '); } else { context.write(': '); @@ -1591,7 +1780,8 @@ export default (options = {}) => { SpreadElement: shared['RestElement|SpreadElement'], StaticBlock(node, context) { - context.write('static {'); + context.write('static '); + write_at(context, '{', locate(node, '{', node.loc?.start, 'after')); context.indent(); context.newline(); @@ -1599,7 +1789,7 @@ export default (options = {}) => { context.dedent(); context.newline(); - context.write('}'); + write_before(context, '}', node.loc?.end); }, Super(node, context) { @@ -1630,9 +1820,16 @@ export default (options = {}) => { SwitchStatement(node, context) { token(context, 'switch', node); - context.write(' ('); + context.write(' '); + write_at(context, '(', locate(node, '(', node.loc?.start, 'after')); context.visit(node.discriminant); - context.write(') {'); + write_at( + context, + ')', + locate(node, ')', node.cases[0]?.loc?.start ?? node.loc?.end, 'before') + ); + context.write(' '); + write_at(context, '{', locate(node, '{', node.discriminant.loc?.end, 'after')); context.indent(); let first = true; @@ -1650,7 +1847,7 @@ export default (options = {}) => { context.dedent(); context.newline(); - context.write('}'); + write_before(context, '}', node.loc?.end); }, TaggedTemplateExpression(node, context) { @@ -1672,9 +1869,10 @@ export default (options = {}) => { for (let i = 0; i < expressions.length; i++) { const raw = quasis[i].value.raw; - context.write(raw + '${'); + context.write(raw); + write_at(context, '${', enclosing(node, expressions[i], '${')); context.visit(expressions[i]); - context.write('}'); + write_at(context, '}', enclosing(node, expressions[i], '}')); if (/\n/.test(raw)) context.multiline = true; } @@ -1700,10 +1898,10 @@ export default (options = {}) => { token(context, 'catch', node); if (node.param) { - context.write('('); + write_at(context, '(', locate(node, '(', node.loc?.start, 'after')); track_binding(node.param); context.visit(node.param); - context.write(')'); + write_at(context, ')', locate(node, ')', node.body.loc?.start, 'before')); } context.write(' '); @@ -1721,7 +1919,9 @@ export default (options = {}) => { } if (node.finalizer) { - context.write(' finally '); + context.write(' '); + write_keyword(context, node, 'finally', (node.handler ?? node.block).loc?.end); + context.write(' '); context.visit(node.finalizer); } }, @@ -1756,7 +1956,7 @@ export default (options = {}) => { }, VariableDeclaration(node, context) { - handle_var_declaration(node, context); + handle_var_declaration(node, context, false, write_keyword); context.write(';'); }, @@ -1766,17 +1966,21 @@ export default (options = {}) => { WhileStatement(node, context) { token(context, 'while', node); - context.write(' ('); + context.write(' '); + write_at(context, '(', locate(node, '(', node.loc?.start, 'after')); context.visit(node.test); - context.write(') '); + write_at(context, ')', locate(node, ')', node.body.loc?.start, 'before')); + context.write(' '); context.visit(node.body); }, WithStatement(node, context) { token(context, 'with', node); - context.write(' ('); + context.write(' '); + write_at(context, '(', locate(node, '(', node.loc?.start, 'after')); context.visit(node.object); - context.write(') '); + write_at(context, ')', locate(node, ')', node.body.loc?.start, 'before')); + context.write(' '); context.visit(node.body); }, @@ -1804,13 +2008,17 @@ export default (options = {}) => { TSDeclareFunction(node, context) { // bodyless functions are either ambient declarations or overload // signatures — only the former are written with `declare` - if (node.declare) context.write('declare '); + if (node.declare) { + write_keyword(context, node, 'declare'); + context.write(' '); + } if (node.async) { - context.write('async '); + write_keyword(context, node, 'async'); + context.write(' '); } - context.write('function'); + write_keyword(context, node, 'function'); if (node.generator) { context.write('*'); @@ -1827,9 +2035,7 @@ export default (options = {}) => { } track_bindings(node.params); - context.write('('); - sequence(context, node.params, node.returnType?.loc?.start ?? node.loc?.end ?? null, false); - context.write(')'); + write_params(context, node, node.params, node.typeParameters ?? node.id, node.returnType); if (node.returnType) { context.visit(node.returnType); @@ -1892,7 +2098,8 @@ export default (options = {}) => { TSArrayType(node, context) { context.visit(node.elementType); - context.write('[]'); + write_at(context, '[', locate(node, '[', node.elementType.loc?.end, 'after')); + write_before(context, ']', node.loc?.end); }, TSTypeAnnotation(node, context) { @@ -1903,14 +2110,15 @@ export default (options = {}) => { TSTypeLiteral(node, context) { context.write('{ '); sequence(context, node.members, node.loc?.end ?? null, false, ';'); - context.write(' }'); + context.write(' '); + write_before(context, '}', node.loc?.end); }, TSPropertySignature(node, context) { if (node.readonly) context.write('readonly '); - if (node.computed) context.write('['); + if (node.computed) write_at(context, '[', enclosing(node, node.key, '[')); context.visit(node.key); - if (node.computed) context.write(']'); + if (node.computed) write_at(context, ']', enclosing(node, node.key, ']')); if (node.optional) context.write('?'); if (node.typeAnnotation) context.visit(node.typeAnnotation); }, @@ -1936,9 +2144,10 @@ export default (options = {}) => { for (let i = 0; i < types.length; i++) { const raw = quasis[i].value.raw; - context.write(raw + '${'); + context.write(raw); + write_at(context, '${', enclosing(node, types[i], '${')); context.visit(types[i]); - context.write('}'); + write_at(context, '}', enclosing(node, types[i], '}')); if (/\n/.test(raw)) context.multiline = true; } @@ -1964,17 +2173,21 @@ export default (options = {}) => { context, parameter.decorators ? { ...node, decorators: parameter.decorators } : node ); + const from = (parameter.decorators ?? node.decorators)?.at(-1)?.loc?.end ?? node.loc?.start; if (node.accessibility) { - context.write(node.accessibility + ' '); + write_keyword(context, node, node.accessibility, from); + context.write(' '); } if (node.override) { - context.write('override '); + write_keyword(context, node, 'override', from); + context.write(' '); } if (node.readonly) { - context.write('readonly '); + write_keyword(context, node, 'readonly', from); + context.write(' '); } if (parameter_decorators?.length) { @@ -2102,12 +2315,14 @@ export default (options = {}) => { TSIndexSignature(node, context) { if (node.readonly) context.write('readonly '); - context.write('['); + const first_parameter = node.parameters[0]; + const last_parameter = node.parameters[node.parameters.length - 1]; + write_at(context, '[', enclosing(node, first_parameter, '[')); track_bindings(node.parameters); // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions sequence(context, node.parameters, node.typeAnnotation?.loc?.start ?? null, false); - context.write(']'); + write_at(context, ']', enclosing(node, last_parameter, ']')); // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions context.visit(node.typeAnnotation); @@ -2118,16 +2333,18 @@ export default (options = {}) => { // `readonly` / `+readonly` / `-readonly` modifier if (node.readonly) { - context.write( - node.readonly === '-' ? '-readonly ' : node.readonly === '+' ? '+readonly ' : 'readonly ' - ); + if (node.readonly === '-' || node.readonly === '+') context.write(node.readonly); + write_keyword(context, node, 'readonly'); + context.write(' '); } - context.write('['); - const legacy_type_parameter = node.typeParameter; const key = node.key ?? legacy_type_parameter?.name; const constraint = node.constraint ?? legacy_type_parameter?.constraint; + const first_bracket_child = key && typeof key === 'object' ? key : legacy_type_parameter; + const last_bracket_child = node.nameType ?? constraint ?? first_bracket_child; + + write_at(context, '[', enclosing(node, first_bracket_child, '[')); if (key && typeof key === 'object') { context.visit(key); @@ -2136,17 +2353,21 @@ export default (options = {}) => { } if (constraint) { - context.write(' in '); + context.write(' '); + write_keyword(context, node, 'in'); + context.write(' '); context.visit(constraint); } // `as` key remapping if (node.nameType) { - context.write(' as '); + context.write(' '); + write_keyword(context, node, 'as'); + context.write(' '); context.visit(node.nameType); } - context.write(']'); + write_at(context, ']', enclosing(node, last_bracket_child, ']')); // `?` / `+?` / `-?` optionality modifier if (node.optional) { @@ -2158,7 +2379,7 @@ export default (options = {}) => { context.visit(node.typeAnnotation); } - context.write('}'); + write_before(context, '}', node.loc?.end); }, TSMethodSignature(node, context) { @@ -2167,9 +2388,9 @@ export default (options = {}) => { context.write(node.kind + ' '); } - if (node.computed) context.write('['); + if (node.computed) write_at(context, '[', enclosing(node, node.key, '[')); context.visit(node.key); - if (node.computed) context.write(']'); + if (node.computed) write_at(context, ']', enclosing(node, node.key, ']')); if (node.optional) context.write('?'); if (node.typeParameters) { @@ -2177,17 +2398,11 @@ export default (options = {}) => { } // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions - track_bindings(node.parameters ?? node.params); - context.write('('); - sequence( - context, - // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions - node.parameters ?? node.params, - // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions - (node.typeAnnotation ?? node.returnType)?.loc?.start ?? node.loc?.end ?? null, - false - ); - context.write(')'); + const parameters = node.parameters ?? node.params; + // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions + const return_type = node.typeAnnotation ?? node.returnType; + track_bindings(parameters); + write_params(context, node, parameters, node.typeParameters ?? node.key, return_type); // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions if (node.typeAnnotation || node.returnType) { @@ -2199,7 +2414,7 @@ export default (options = {}) => { TSTupleType(node, context) { context.write('['); sequence(context, node.elementTypes, node.loc?.end ?? null, false); - context.write(']'); + write_before(context, ']', node.loc?.end); }, TSNamedTupleMember(node, context) { @@ -2248,33 +2463,40 @@ export default (options = {}) => { TSConstructorType: shared['TSFunctionType|TSConstructorType'], TSExternalModuleReference(node, context) { - context.write('require('); + context.write('require'); + write_at(context, '(', locate(node, '(', node.loc?.start, 'after')); context.visit(node.expression); - context.write(');'); + write_before(context, ')', node.loc?.end); + context.write(';'); }, TSIndexedAccessType(node, context) { context.visit(node.objectType); - context.write('['); + write_at(context, '[', enclosing(node, node.indexType, '[')); context.visit(node.indexType); - context.write(']'); + write_before(context, ']', node.loc?.end); }, TSImportEqualsDeclaration(node, context) { token(context, 'import', node); context.write(' '); - if (node.importKind === 'type') context.write('type '); + if (node.importKind === 'type') { + write_keyword(context, node, 'type'); + context.write(' '); + } context.visit(node.id); context.write(' = '); context.visit(node.moduleReference); }, TSImportType(node, context) { - token(context, 'import', node); - context.write('('); // @ts-expect-error Newer TS-ESTree versions use `source` instead of `argument` - context.visit(node.source ?? node.argument); - context.write(')'); + const source = node.source ?? node.argument; + + token(context, 'import', node); + write_at(context, '(', locate(node, '(', node.loc?.start, 'after')); + context.visit(source); + write_at(context, ')', locate(node, ')', source.loc?.end, 'after')); if (node.qualifier) { context.write('.'); @@ -2306,43 +2528,58 @@ export default (options = {}) => { EXPRESSIONS_PRECEDENCE[node.expression.type] < EXPRESSIONS_PRECEDENCE.TSAsExpression; maybe_wrap(context, node.expression, wrap); } - context.write(' as '); + context.write(' '); + write_keyword(context, node, 'as', node.expression.loc?.end); + context.write(' '); context.visit(node.typeAnnotation); }, TSEnumDeclaration(node, context) { - if (node.declare) context.write('declare '); - if (node.const) context.write('const '); - context.write('enum '); + if (node.declare) { + write_keyword(context, node, 'declare'); + context.write(' '); + } + if (node.const) { + write_keyword(context, node, 'const'); + context.write(' '); + } + write_keyword(context, node, 'enum'); + context.write(' '); context.visit(node.id); - context.write(' {'); + context.write(' '); + write_at(context, '{', locate(node, '{', node.id.loc?.end, 'after')); context.indent(); context.newline(); sequence(context, node.members ?? node.body.members, node.loc?.end ?? null, false); context.dedent(); context.newline(); - context.write('}'); + write_before(context, '}', node.loc?.end); }, TSModuleBlock(node, context) { - context.write(' {'); + context.write(' '); + write_at(context, '{', node.loc?.start); context.indent(); context.newline(); body(context, node); context.dedent(); context.newline(); - context.write('}'); + write_before(context, '}', node.loc?.end); }, TSModuleDeclaration(node, context) { - if (node.declare) context.write('declare '); + if (node.declare) { + write_keyword(context, node, 'declare'); + context.write(' '); + } if (node.global) { context.write('global', node.id); } else { // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions const kind = node.kind ?? (node.id.type === 'Literal' ? 'module' : 'namespace'); - context.write(kind + ' '); + write_keyword(context, node, kind); + context.write(' '); context.visit(node.id); } @@ -2373,17 +2610,24 @@ export default (options = {}) => { }, TSInterfaceDeclaration(node, context) { - if (node.declare) context.write('declare '); - context.write('interface '); + if (node.declare) { + write_keyword(context, node, 'declare'); + context.write(' '); + } + write_keyword(context, node, 'interface'); + context.write(' '); context.visit(node.id); if (node.typeParameters) context.visit(node.typeParameters); if (node.extends && node.extends.length > 0) { - context.write(' extends '); + context.write(' '); + write_keyword(context, node, 'extends', (node.typeParameters ?? node.id).loc?.end); + context.write(' '); sequence(context, node.extends, node.body.loc?.start ?? null, false); } - context.write(' {'); + context.write(' '); + write_at(context, '{', node.body.loc?.start); context.visit(node.body); - context.write('}'); + write_before(context, '}', node.body.loc?.end); }, TSInstantiationExpression(node, context) { @@ -2418,13 +2662,19 @@ export default (options = {}) => { EXPRESSIONS_PRECEDENCE.TSSatisfiesExpression; maybe_wrap(context, node.expression, wrap); } - context.write(' satisfies '); + context.write(' '); + write_keyword(context, node, 'satisfies', node.expression.loc?.end); + context.write(' '); context.visit(node.typeAnnotation); }, TSTypeAliasDeclaration(node, context) { - if (node.declare) context.write('declare '); - context.write('type '); + if (node.declare) { + write_keyword(context, node, 'declare'); + context.write(' '); + } + write_keyword(context, node, 'type'); + context.write(' '); context.visit(node.id); if (node.typeParameters) context.visit(node.typeParameters); context.write(' = '); @@ -2569,7 +2819,7 @@ function is_decorator_expression(node) { * @param {TSESTree.Node & { decorators: TSESTree.Decorator[] | undefined }} node */ function block_decorators(context, node) { - if (!node.decorators) return; + if (!node.decorators || printed_decorators.has(node)) return; for (const decorator of node.decorators) { context.visit(decorator); @@ -2598,6 +2848,14 @@ function inline_decorators(context, node) { } } +/** + * Declarations whose decorators an export visitor has already printed. Their + * `loc.start` is the first decorator, so the root visitor must not map it where + * the keywords are written; the keywords themselves are located from `tokens`. + * @type {WeakSet} + */ +const printed_decorators = new WeakSet(); + /** * Visit an exported declaration minus its decorators, which have already been printed * @param {Context} context @@ -2605,18 +2863,9 @@ function inline_decorators(context, node) { */ function visit_without_decorators(context, node) { if ('decorators' in node && node.decorators && node.decorators.length > 0) { - const { decorators, loc } = node; - - // Temporarily remove decorators so ClassDeclaration doesn't print them again - node.decorators = []; - // @ts-expect-error - node.loc = null; - + printed_decorators.add(node); context.visit(node); - node.decorators = decorators; - node.loc = loc; - - if (loc) context.location(loc.end.line, loc.end.column); + printed_decorators.delete(node); } else { context.visit(node); } @@ -2835,10 +3084,14 @@ function handle_var_declarator(node, context, no_in) { * @param {TSESTree.Node} node */ function has_preceding_decorator(node) { - let n = - ((node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration') && - node.declaration) || - node; + if (node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration') { + // the declaration's decorators are printed before `export`, whichever + // side of it they were written on + const d = node.declaration; + return !!(d && 'decorators' in d && d.decorators && d.decorators.length > 0); + } + + let n = node; if ('parameter' in n && 'decorators' in n.parameter) { n = n.parameter; @@ -2858,27 +3111,35 @@ function has_preceding_decorator(node) { * end are mapped here the way the root visitor would. * @param {TSESTree.VariableDeclaration} node * @param {Context} context - * @param {boolean} [no_in] + * @param {boolean} no_in + * @param {(context: Context, node: TSESTree.Node, word: string) => void} keyword */ -function write_for_head_declaration(node, context, no_in = false) { +function write_for_head_declaration(node, context, no_in, keyword) { if (node.loc) context.location(node.loc.start.line, node.loc.start.column); - handle_var_declaration(node, context, no_in); + handle_var_declaration(node, context, no_in, keyword); if (node.loc) context.location(node.loc.end.line, node.loc.end.column); } /** * @param {TSESTree.VariableDeclaration} node * @param {Context} context - * @param {boolean} [no_in] + * @param {boolean} no_in + * @param {(context: Context, node: TSESTree.Node, word: string) => void} keyword writes a keyword after the node's first token */ -function handle_var_declaration(node, context, no_in = false) { +function handle_var_declaration(node, context, no_in, keyword) { const open = context.new(); const join = context.new(); const child_context = context.new(); context.append(child_context); - token(child_context, node.declare ? `declare ${node.kind}` : node.kind, node); + if (node.declare) { + token(child_context, 'declare', node); + child_context.write(' '); + keyword(child_context, node, node.kind); + } else { + token(child_context, node.kind, node); + } child_context.write(' '); child_context.append(open); diff --git a/src/languages/ts/public.ts b/src/languages/ts/public.ts index 9aa98686..275ef96b 100644 --- a/src/languages/ts/public.ts +++ b/src/languages/ts/public.ts @@ -1,4 +1,4 @@ export type { BaseNode as Node } from '../../types.js'; -export type { BaseComment, Comment } from '../types.js'; +export type { BaseComment, Comment, SourceToken } from '../types.js'; export { default, EXPRESSIONS_PRECEDENCE } from './index.js'; diff --git a/src/languages/ts/tokens.js b/src/languages/ts/tokens.js new file mode 100644 index 00000000..3df8bfc2 --- /dev/null +++ b/src/languages/ts/tokens.js @@ -0,0 +1,175 @@ +/** @import { TSESTree } from '@typescript-eslint/types' */ +/** @import { SourceToken, TSOptions } from '../types.js' */ + +/** @typedef {{ line: number, column: number }} Position */ +/** @typedef {{ start: Position, end: Position }} Location */ + +/** + * The tokens that are looked up: delimiters, and the keywords a printer writes + * after a node's first token (which no node boundary locates) + */ +const WORDS = new Set([ + ...['(', ')', '[', ']', '{', '}', '${'], + ...['function', 'class', 'else', 'finally', 'while', 'default', 'type', 'async', 'await'], + ...['declare', 'abstract', 'static', 'readonly', 'override', 'accessor', 'get', 'set'], + ...['public', 'private', 'protected', 'const', 'enum', 'interface', 'namespace', 'module'], + ...['extends', 'implements', 'in', 'of', 'as', 'satisfies', 'new'] +]); + +/** + * Negative when `a` comes before `b`, positive when after, zero when equal + * @param {Position} a + * @param {Position} b + */ +export function compare_positions(a, b) { + return a.line - b.line || a.column - b.column; +} + +/** + * The punctuator or word a parser token stands for. Acorn and Babel put + * punctuators and reserved words on `type.label` and other words (`async`, + * `type`, `of`) in `value` with the label `name`; ESLint-style tokens (espree, + * typescript-eslint) use `type: 'Punctuator' | 'Keyword' | 'Identifier'` with + * the text in `value`. + * @param {SourceToken} token + */ +function word(token) { + const { type } = token; + if (typeof type === 'object' && type !== null) { + return type.label === 'name' ? token.value : type.label; + } + if (type === 'Punctuator' || type === 'Keyword' || type === 'Identifier') return token.value; + return undefined; +} + +/** + * Locates tokens that sit inside a node — the brackets of a computed key, the + * parentheses of a call or an `if`, the braces of an import list, `function` + * after `async`, `else`, `finally` — in the parser's tokens, since no node + * boundary records where they are. Without `tokens`, every lookup returns + * `undefined` and the token is left unmapped rather than guessed. + * + * @param {TSOptions} options + */ +export function token_locator(options) { + let instance = instances.get(options); + if (!instance) { + instance = create_token_locator(options); + instances.set(options, instance); + } + return instance; +} + +/** One instance per options object, so `tsx` shares the index built for `ts` */ +/** @type {WeakMap>} */ +const instances = new WeakMap(); + +/** @param {TSOptions} options */ +function create_token_locator(options) { + /** + * The tokens of interest from `options.tokens`, in source order, built on + * the first lookup + * @type {{ value: string, loc: Location }[] | undefined} + */ + let entries; + + function get_entries() { + if (entries === undefined) { + entries = []; + let sorted = true; + + for (const token of options.tokens ?? []) { + const value = word(token); + if (typeof value !== 'string' || !WORDS.has(value) || !token.loc) continue; + + const previous = entries[entries.length - 1]; + if (previous && compare_positions(previous.loc.start, token.loc.start) > 0) sorted = false; + entries.push({ value, loc: token.loc }); + } + + // a backtracking parser can re-emit tokens; the binary search needs monotone positions + if (!sorted) { + entries.sort((a, b) => compare_positions(a.loc.start, b.loc.start)); + } + } + + return entries; + } + + /** + * The nearest `value` token on `side` of `pos`, without leaving `node` + * @param {TSESTree.Node} node + * @param {string} value + * @param {Position} pos + * @param {'before' | 'after'} side + * @returns {Location | undefined} + */ + function find(node, value, pos, side) { + if (!node.loc) return undefined; + + const tokens = get_entries(); + let lo = 0; + let hi = tokens.length - 1; + + if (side === 'before') { + // rightmost token ending at or before `pos` + while (lo <= hi) { + const mid = (lo + hi) >> 1; + if (compare_positions(tokens[mid].loc.end, pos) > 0) hi = mid - 1; + else lo = mid + 1; + } + + for (let i = hi; i >= 0; i -= 1) { + const token = tokens[i]; + if (compare_positions(token.loc.start, node.loc.start) < 0) break; + if (token.value === value) return token.loc; + } + } else { + // leftmost token starting at or after `pos` + while (lo <= hi) { + const mid = (lo + hi) >> 1; + if (compare_positions(tokens[mid].loc.start, pos) < 0) lo = mid + 1; + else hi = mid - 1; + } + + for (let i = lo; i < tokens.length; i += 1) { + const token = tokens[i]; + if (compare_positions(token.loc.end, node.loc.end) > 0) break; + if (token.value === value) return token.loc; + } + } + } + + /** + * The location of the `value` token nearest to `pos` on `side`, or + * `undefined` when `tokens` were not supplied or the token is not there in + * the source. + * @param {TSESTree.Node} node + * @param {string} value + * @param {Position | undefined} pos + * @param {'before' | 'after'} side + */ + function locate(node, value, pos, side) { + if (!options.tokens || !pos) return undefined; + return find(node, value, pos, side); + } + + /** + * The location of the delimiter that opens (just before `inner`) or closes + * (just after `inner`) a bracketed part of `node`. + * @param {TSESTree.Node} node + * @param {TSESTree.Node | null | undefined} inner + * @param {'(' | ')' | '[' | ']' | '{' | '}' | '${'} value + */ + function enclosing(node, inner, value) { + const opening = value !== ')' && value !== ']' && value !== '}'; + return locate( + node, + value, + opening ? inner?.loc?.start : inner?.loc?.end, + opening ? 'before' : 'after' + ); + } + + return { locate, enclosing }; +} diff --git a/src/languages/tsx/public.ts b/src/languages/tsx/public.ts index 1181b7b7..02692535 100644 --- a/src/languages/tsx/public.ts +++ b/src/languages/tsx/public.ts @@ -1,4 +1,4 @@ export type { BaseNode as Node } from '../../types.js'; -export type { BaseComment, Comment } from '../types.js'; +export type { BaseComment, Comment, SourceToken } from '../types.js'; export { default } from './index.js'; diff --git a/src/languages/types.ts b/src/languages/types.ts index 70662510..1c62f796 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -3,6 +3,16 @@ import type { BaseNode } from '../types.js'; export type TSOptions = { quotes?: 'double' | 'single'; comments?: Comment[]; + /** + * The parser's tokens, with locations — Acorn's `onToken` array, Babel's + * `tokens`, or an ESLint-style `ast.tokens`. Used to map what sits inside + * a node and no node boundary locates: the brackets of a computed key, the + * parentheses of a call or an `if`, the braces of an import list, and the + * keywords after a node's first token (`function` after `async`, `else`, + * `finally`, a class member's second modifier). Without it those are left + * unmapped. + */ + tokens?: readonly SourceToken[]; getLeadingComments?: (node: BaseNode) => BaseComment[] | undefined; getTrailingComments?: (node: BaseNode) => BaseComment[] | undefined; }; @@ -12,6 +22,20 @@ interface Position { column: number; } +/** + * A parser token. The punctuator it stands for is read from `type.label` + * (Acorn, Babel) or, for `type: 'Punctuator'` tokens (espree, + * typescript-eslint), from `value`. + */ +export interface SourceToken { + type?: string | { label?: string }; + value?: unknown; + loc?: null | { + start: Position; + end: Position; + }; +} + // this exists in TSESTree but because of the inanity around enums // it's easier to do this ourselves export interface BaseComment { diff --git a/test/common.js b/test/common.js index 55483eac..33bb1425 100644 --- a/test/common.js +++ b/test/common.js @@ -10,7 +10,7 @@ export const acornTs = acorn.Parser.extend(tsPlugin()); export const acornTsx = acorn.Parser.extend(tsPlugin({ jsx: true })); /** @param {string} input - * @param {{ jsxMode?: boolean, sourceType?: 'module' | 'script', preserveParens?: boolean, fileExtension?: string }} opts + * @param {{ jsxMode?: boolean, sourceType?: 'module' | 'script', preserveParens?: boolean, fileExtension?: string, tokens?: any[] }} opts */ export function acornParse(input, opts = {}) { const jsx = opts.jsxMode ?? false; @@ -24,6 +24,7 @@ export function acornParse(input, opts = {}) { sourceType, locations: true, preserveParens: opts.preserveParens ?? false, + onToken: opts.tokens, onComment: (block, value, start, end, startLoc, endLoc) => { if (block && /\n/.test(value)) { let a = start; diff --git a/test/samples/array-expressions/expected.js.map b/test/samples/array-expressions/expected.js.map index 8df51fc5..3f53b249 100644 --- a/test/samples/array-expressions/expected.js.map +++ b/test/samples/array-expressions/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "a = [1, 2, 3];\n\nb = [\n\t'the quick brown fox jumps over the lazy dog',\n\t'the quick brown fox jumps over the lazy dog',\n\t'the quick brown fox jumps over the lazy dog',\n\t4\n];\n\nsparse = [,,,5];\nsparser = [,,,];\n" ], - "mappings": "AAAA,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;;AAEd,CAAC,GAAG;CACH,6CAA6C;CAC7C,6CAA6C;CAC7C,6CAA6C;CAC7C,CAAC;CACD,CAAC;;AAEF,MAAM,GAAG,KAAI,CAAC,CAAC,CAAC;AAChB,OAAO,GAAG,KAAK,CAAC,AAChB" + "mappings": "AAAA,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;;AAEd,CAAC,GAAG;CACH,6CAA6C;CAC7C,6CAA6C;CAC7C,6CAA6C;CAC7C,CAAC;AACF,CAAC,CAAC;;AAEF,MAAM,GAAG,KAAI,CAAC,CAAC,CAAC;AAChB,OAAO,GAAG,IAAI,CAAC,CAAC,AAChB" } \ No newline at end of file diff --git a/test/samples/arrow-function-needs-braces/expected.js.map b/test/samples/arrow-function-needs-braces/expected.js.map index 6e414919..042aefdf 100644 --- a/test/samples/arrow-function-needs-braces/expected.js.map +++ b/test/samples/arrow-function-needs-braces/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "let a = () => ({ x } = { x: 42 });\nlet b = () => ({} || bar);\nlet c = () => ({} ? foo : bar);" ], - "mappings": "AAAA,GAAG,CAAC,CAAC,GAAG,MAAO,CAAA,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAA,AAAC,CAAC;AAClC,GAAG,CAAC,CAAC,GAAG,MAAO,CAAA,EAAE,IAAI,GAAG,CAAA,AAAC,CAAC;AAC1B,GAAG,CAAC,CAAC,GAAG,MAAO,CAAA,EAAE,GAAG,GAAG,GAAG,GAAG,CAAA,AAAC,CAAC" + "mappings": "AAAA,GAAG,CAAC,CAAC,GAAG,MAAO,CAAA,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA,AAAC,CAAC;AAClC,GAAG,CAAC,CAAC,GAAG,MAAO,CAAA,CAAC,CAAC,IAAI,GAAG,CAAA,AAAC,CAAC;AAC1B,GAAG,CAAC,CAAC,GAAG,MAAO,CAAA,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAA,AAAC,CAAC" } \ No newline at end of file diff --git a/test/samples/basic/expected.js.map b/test/samples/basic/expected.js.map index ca876cb3..ccd5652e 100644 --- a/test/samples/basic/expected.js.map +++ b/test/samples/basic/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "foo({ a: 1 });\n" ], - "mappings": "AAAA,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,AACd" + "mappings": "AAAA,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,AACd" } \ No newline at end of file diff --git a/test/samples/call-expressions/expected.js.map b/test/samples/call-expressions/expected.js.map index b7f7b21d..8923b379 100644 --- a/test/samples/call-expressions/expected.js.map +++ b/test/samples/call-expressions/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "x(a, b, c);\n\nx(a, b, () => {\n\tconsole.log('c');\n});\n\nx(\n\ta,\n\t() => {\n\t\tconsole.log('b');\n\t},\n\t() => {\n\t\tconsole.log('c');\n\t}\n);" ], - "mappings": "AAAA,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;;AAEX,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACd,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;;AAEH,CAAC;CACA,CAAC;CACD,MAAM,CAAC;EACN,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAClB,CAAC;CACD,MAAM,CAAC;EACN,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAClB,CAAC;CACD,CAAC" + "mappings": "AAAA,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;;AAEX,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACd,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;;AAEH,CAAC;CACA,CAAC;CACD,MAAM,CAAC;EACN,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAClB,CAAC;CACD,MAAM,CAAC;EACN,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAClB,CAAC;AACF,CAAC,CAAC" } \ No newline at end of file diff --git a/test/samples/chain-expressions/expected.js.map b/test/samples/chain-expressions/expected.js.map index 6421c9c2..f1557b98 100644 --- a/test/samples/chain-expressions/expected.js.map +++ b/test/samples/chain-expressions/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "foo?.bar.baz;\nx?.(a, b, c);\nx()?.();\na?.b.c;\na?.b().c;\na?.b?.c;\n(a?.b)();\n(a?.b).c;\nnew (a?.b)();\ndelete (a?.b).c;\n(a?.b)`x`;\n(a?.())();\n" ], - "mappings": "AAAA,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;AACb,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACb,CAAC,EAAE,IAAI,CAAC;AACR,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACP,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACT,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACR,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,EAAG,CAAC;AACT,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,CAAE,CAAC,CAAC;AACT,GAAG,CAAE,CAAA,CAAC,EAAE,CAAC,CAAA,EAAG,CAAC;AACb,MAAM,CAAC,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,CAAE,CAAC,CAAC;AAChB,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,AAAC,GAAG,CAAC;AACV,AAAC,CAAA,CAAC,IAAI,CAAA,EAAG,CAAC,AACV" + "mappings": "AAAA,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC;AACb,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACb,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACR,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACP,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACT,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACR,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,CAAE,CAAC,CAAC;AACT,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,CAAE,CAAC,CAAC;AACT,GAAG,CAAE,CAAA,CAAC,EAAE,CAAC,CAAA,EAAG,CAAC;AACb,MAAM,CAAC,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,CAAE,CAAC,CAAC;AAChB,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,AAAC,GAAG,CAAC;AACV,AAAC,CAAA,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAC,AACV" } \ No newline at end of file diff --git a/test/samples/class-extends/expected.js.map b/test/samples/class-extends/expected.js.map index 7093640a..a19261aa 100644 --- a/test/samples/class-extends/expected.js.map +++ b/test/samples/class-extends/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "class A extends (B || C) {}\nclass B extends (cond ? B : D) {}\nconst C = class extends (a = b) {};\nclass D extends B.C {}\nclass E extends new B() {}\nclass F extends f() {}\n" ], - "mappings": "AAAA,MAAM,CAAC,SAAU,CAAA,CAAC,IAAI,CAAC,CAAA,CAAE,CAAC,CAAC;AAC3B,MAAM,CAAC,SAAU,CAAA,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAC;;AACjC,KAAK,CAAC,CAAC,GAAG,cAAe,CAAA,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAC,CAAC;;AACnC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,AACtB" + "mappings": "AAAA,MAAM,CAAC,SAAU,CAAA,CAAC,IAAI,CAAC,CAAA,CAAE,CAAC,CAAC;AAC3B,MAAM,CAAC,SAAU,CAAA,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAC;;AACjC,KAAK,CAAC,CAAC,GAAG,cAAe,CAAA,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAC,CAAC;;AACnC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,AACtB" } \ No newline at end of file diff --git a/test/samples/class-static-block/expected.js.map b/test/samples/class-static-block/expected.js.map index d19bd948..df68b202 100644 --- a/test/samples/class-static-block/expected.js.map +++ b/test/samples/class-static-block/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "class Foo {\n\tstatic {\n\t\tthis.abc = 1;\n\t}\n}" ], - "mappings": "AAAA,MAAM,GAAG,CAAC,CAAC;CACV;EACC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;EACb;AACF,CAAC" + "mappings": "AAAA,MAAM,GAAG,CAAC,CAAC;CACV;EACC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;CACd,CAAC;AACF,CAAC" } \ No newline at end of file diff --git a/test/samples/comment-after-function-argument/expected.js.map b/test/samples/comment-after-function-argument/expected.js.map index 776224e1..36b7fb1e 100644 --- a/test/samples/comment-after-function-argument/expected.js.map +++ b/test/samples/comment-after-function-argument/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "foo(function bar() {\n\t// logic goes here\n}, true); // trailing comment\n" ], - "mappings": "AAAA,GAAG;CAAC,SAAS,GAAG,GAAG,CAAC;;CAEpB,CAAC;CAAE,IAAI;CAAC,CAAC,oBACT" + "mappings": "AAAA,GAAG;CAAC,SAAS,GAAG,GAAG,CAAC;;CAEpB,CAAC;CAAE,IAAI;AAAA,CAAC,CAAC,oBACT" } \ No newline at end of file diff --git a/test/samples/comment-block/expected.js.map b/test/samples/comment-block/expected.js.map index f04d67da..4d3ef04b 100644 --- a/test/samples/comment-block/expected.js.map +++ b/test/samples/comment-block/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "/* comment before a node\n * second line */ console.log(1);\n\nconsole.log(2); /* comment on same line as node */\n\nconst obj = {\n\tfoo: 1, /* comment in middle of object */\n\tbar: 2\n};\n" ], - "mappings": "AAAA;;AACkB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;AAEjC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;AAEf,KAAK,CAAC,GAAG,GAAG,EACX,GAAG,EAAE,CAAC,oCACN,GAAG,EAAE,CAAC,EACN,CAAC,AACF" -} \ No newline at end of file + "mappings": "AAAA;;AACkB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;AAEjC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;AAEf,KAAK,CAAC,GAAG,GAAG,EACX,GAAG,EAAE,CAAC,oCACN,GAAG,EAAE,CAAC,CACP,CAAC,CAAC,AACF" +} diff --git a/test/samples/comment-inline/expected.js.map b/test/samples/comment-inline/expected.js.map index a8d59649..2bcd48ca 100644 --- a/test/samples/comment-inline/expected.js.map +++ b/test/samples/comment-inline/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "// comment before a node\n// second line\nconsole.log(1);\nconsole.log(2); // comment on same line as node\n\nconst obj = {\n\tfoo: 1, // comment in middle of object\n\tbar: 2 // comment in middle of object\n};\n\nfunction bar() {\n\treturn /*result*/ foo;\n}\n\nconsole.log(3); // eslint-disable-line\n" ], - "mappings": "AAAA;;AAEA,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;AACf,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;AAEf,KAAK,CAAC,GAAG,GAAG;CACX,GAAG,EAAE,CAAC;CACN,GAAG,EAAE,CAAC;CACN,CAAC;;AAEF,SAAS,GAAG,GAAG,CAAC;CACf,MAAM,aAAY,GAAG,EAAC;AACvB,CAAC;;AAED,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,uBACf" -} \ No newline at end of file + "mappings": "AAAA;;AAEA,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;AACf,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;AAEf,KAAK,CAAC,GAAG,GAAG;CACX,GAAG,EAAE,CAAC;CACN,GAAG,EAAE,CAAC;AACP,CAAC,CAAC;;AAEF,SAAS,GAAG,GAAG,CAAC;CACf,MAAM,aAAY,GAAG,EAAC;AACvB,CAAC;;AAED,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,uBACf" +} diff --git a/test/samples/comment-jsdoc-type-cast-param-default/expected.js.map b/test/samples/comment-jsdoc-type-cast-param-default/expected.js.map index c9833378..14348eb0 100644 --- a/test/samples/comment-jsdoc-type-cast-param-default/expected.js.map +++ b/test/samples/comment-jsdoc-type-cast-param-default/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "const row_template = ($$anchor, row = $.noop) => {\n\trow;\n};\n\nconst f = ({ a } = {}) => a;\n\nfunction g(x = 1) {\n\treturn x;\n}\n\nconst value = /** @type {number} */ (computed);\n" ], - "mappings": "AAAA,KAAK,CAAC,YAAY,GAAG,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC;CACjD,GAAG,CAAC;AACL,CAAC,CAAC;;AAEF,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;;AAE5B,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;CAClB,MAAM,CAAC,CAAC,CAAC;AACV,CAAC;;AAED,KAAK,CAAC,KAAK,0BAA0B,QAAQ,EAAE,AAC/C" + "mappings": "AAAA,KAAK,CAAC,YAAY,GAAG,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC;CACjD,GAAG,CAAC;AACL,CAAC,CAAC;;AAEF,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;;AAE5B,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;CAClB,MAAM,CAAC,CAAC,CAAC;AACV,CAAC;;AAED,KAAK,CAAC,KAAK,0BAA0B,QAAQ,EAAE,AAC/C" } \ No newline at end of file diff --git a/test/samples/comment-within-call-expression/expected.js.map b/test/samples/comment-within-call-expression/expected.js.map index 30c3ef64..813a0edf 100644 --- a/test/samples/comment-within-call-expression/expected.js.map +++ b/test/samples/comment-within-call-expression/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "console.log(null, /* xxx */ new Date(), /** zzz */ a.b.c()); // www\n\nconsole.log(\n\tnull, // foo\n\tnew Date()\n);\n\nconsole.log(\n\tnull, // foo\n\tnew Date()\n);\n\nconsole.log(null, /* xxx */ function (a, b) {\n\t// yyy\n\treturn a + b;\n});\n\nconsole.log(\"1\");\n" ], - "mappings": "AAAA,OAAO,CAAC,GAAG,CAAC,IAAI,YAAY,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;;AAE5D,OAAO,CAAC,GAAG;CACV,IAAI;CACJ,GAAG,CAAC,IAAI,EAAE;CACV,CAAC;;AAEF,OAAO,CAAC,GAAG;CACV,IAAI;CACJ,GAAG,CAAC,IAAI,EAAE;CACV,CAAC;;AAEF,OAAO,CAAC,GAAG,CAAC,IAAI,YAAY,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;;CAE5C,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC,CAAC;;AAEH,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,AACjB" + "mappings": "AAAA,OAAO,CAAC,GAAG,CAAC,IAAI,YAAY,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;AAE5D,OAAO,CAAC,GAAG;CACV,IAAI;CACJ,GAAG,CAAC,IAAI,EAAE;AACX,CAAC,CAAC;;AAEF,OAAO,CAAC,GAAG;CACV,IAAI;CACJ,GAAG,CAAC,IAAI,EAAE;AACX,CAAC,CAAC;;AAEF,OAAO,CAAC,GAAG,CAAC,IAAI,YAAY,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;;CAE5C,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC,CAAC;;AAEH,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,AACjB" } \ No newline at end of file diff --git a/test/samples/computed-getter/expected.js.map b/test/samples/computed-getter/expected.js.map index 434d194c..531ef05c 100644 --- a/test/samples/computed-getter/expected.js.map +++ b/test/samples/computed-getter/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "obj = {\n\tget [foo]() {\n\t\treturn bar;\n\t}\n}\n" ], - "mappings": "AAAA,GAAG,GAAG;CACL,KAAK,GAAG,IAAI,CAAC;EACZ,MAAM,CAAC,GAAG,CAAC;CACZ,CAAC;CACD,CAAA,AACD" + "mappings": "AAAA,GAAG,GAAG;CACL,KAAK,GAAG,IAAI,CAAC;EACZ,MAAM,CAAC,GAAG,CAAC;CACZ,CAAC;AACF,CAAC,CAAA,AACD" } \ No newline at end of file diff --git a/test/samples/deconflict-method/expected.js.map b/test/samples/deconflict-method/expected.js.map index 547716d5..9c0067a1 100644 --- a/test/samples/deconflict-method/expected.js.map +++ b/test/samples/deconflict-method/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "obj = {\n\ta(foo) {\n\n\t}\n};\n" ], - "mappings": "AAAA,GAAG,GAAG,EACL,CAAC,CAAC,GAAG,EAAE,CAAC,AAER,CAAC,EACD,CAAC,AACF" + "mappings": "AAAA,GAAG,GAAG,EACL,CAAC,CAAC,GAAG,EAAE,CAAC,AAER,CAAC,CACF,CAAC,CAAC,AACF" } \ No newline at end of file diff --git a/test/samples/destructured-assignment/expected.js.map b/test/samples/destructured-assignment/expected.js.map index 7587d770..001c25ab 100644 --- a/test/samples/destructured-assignment/expected.js.map +++ b/test/samples/destructured-assignment/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "({ answer = 42 } = life_the_universe_and_everything);\n" ], - "mappings": "AAAA,AAAC,CAAA,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,gCAAgC,CAAA,CAAE,AACrD" + "mappings": "AAAA,AAAC,CAAA,EAAE,MAAM,GAAG,EAAE,CAAC,CAAC,GAAG,gCAAgC,CAAA,CAAE,AACrD" } \ No newline at end of file diff --git a/test/samples/destructured-declaration/expected.js.map b/test/samples/destructured-declaration/expected.js.map index d3753848..9b54347b 100644 --- a/test/samples/destructured-declaration/expected.js.map +++ b/test/samples/destructured-declaration/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "const { answer = 42 } = life_the_universe_and_everything;" ], - "mappings": "AAAA,KAAK,CAAC,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,gCAAgC,CAAC" + "mappings": "AAAA,KAAK,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,CAAC,GAAG,gCAAgC,CAAC" } \ No newline at end of file diff --git a/test/samples/function-expression/expected.js.map b/test/samples/function-expression/expected.js.map index 23661db8..82ba3e02 100644 --- a/test/samples/function-expression/expected.js.map +++ b/test/samples/function-expression/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "(function(){\n\n})\nlet object = {\n foo() {\n \n }\n}" ], - "mappings": "AAAA,AAAC,CAAA,YAAU,CAAC,AAEZ,CAAC,CAAA,CAAC;;AACF,GAAG,CAAC,MAAM,GAAG,EACT,GAAG,GAAG,CAAC,AAEP,CAAC,EACJ,CAAA" + "mappings": "AAAA,AAAC,CAAA,YAAU,CAAC,AAEZ,CAAC,CAAA,CAAC;;AACF,GAAG,CAAC,MAAM,GAAG,EACT,GAAG,GAAG,CAAC,AAEP,CAAC,CACL,CAAC,CAAA" } \ No newline at end of file diff --git a/test/samples/import-attributes/expected.js.map b/test/samples/import-attributes/expected.js.map index faa2e254..e0076335 100644 --- a/test/samples/import-attributes/expected.js.map +++ b/test/samples/import-attributes/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "import { foo } from 'x' with {type: 'json'};\nimport { bar } from 'y' with { \"blah\": \"true\", baz: \"false\" };\nimport('baz', { with: { stuff: true }}).then(blah);" ], - "mappings": "AAAA,MAAM,GAAG,GAAG,QAAQ,GAAG,QAAO,IAAI,EAAE,MAAM,GAAE;AAC5C,MAAM,GAAG,GAAG,QAAQ,GAAG,QAAQ,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG;;AAC9D,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC" + "mappings": "AAAA,MAAM,GAAG,GAAG,QAAQ,GAAG,QAAO,IAAI,EAAE,MAAM,GAAE;AAC5C,MAAM,GAAG,GAAG,QAAQ,GAAG,QAAQ,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG;;AAC9D,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC" } \ No newline at end of file diff --git a/test/samples/jsx-basic/expected.jsx.map b/test/samples/jsx-basic/expected.jsx.map index 9075a710..43306105 100644 --- a/test/samples/jsx-basic/expected.jsx.map +++ b/test/samples/jsx-basic/expected.jsx.map @@ -7,5 +7,5 @@ "sourcesContent": [ "console.log(\n\t<>\n\t\t
\n\t\t\t{'An\n\t\t\tTime since last cat incident: {'5 days'}\n\t\t
\n\t\n);\n" ], - "mappings": "AAAA,OAAO,CAAC,GAAG,CACV,EAAE;EACD,CAAC,GAAG,CAAC;GACJ,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,0BAA0B,CAAC,GAAG;iCACxB,CAAC,QAAQ,CAAC;EACzC,EAAE,GAAG,CAAC;CACP,GAAG,CACH,CAAC,AACF" + "mappings": "AAAA,OAAO,CAAC,GAAG,CACV,EAAE;EACD,CAAC,GAAG,CAAC;GACJ,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,0BAA0B,CAAC,GAAG;iCACxB,CAAC,QAAQ,CAAC;EACzC,EAAE,GAAG,CAAC;CACP,GAAG,AACJ,CAAC,CAAC,AACF" } \ No newline at end of file diff --git a/test/samples/method/expected.js.map b/test/samples/method/expected.js.map index 3654d228..304dee68 100644 --- a/test/samples/method/expected.js.map +++ b/test/samples/method/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "obj = {\n\tfoo() {\n\t\tconsole.log('foo');\n\t},\n\tasync bar() {\n\t\tconsole.log('bar');\n\t},\n\t*baz() {\n\t\tconsole.log('baz');\n\t}\n};" ], - "mappings": "AAAA,GAAG,GAAG;CACL,GAAG,GAAG,CAAC;EACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACpB,CAAC;;CACD,MAAM,GAAG,GAAG,CAAC;EACZ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACpB,CAAC;;CACD,CAAC,GAAG,GAAG,CAAC;EACP,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACpB,CAAC;CACD,CAAC" + "mappings": "AAAA,GAAG,GAAG;CACL,GAAG,GAAG,CAAC;EACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACpB,CAAC;;CACD,MAAM,GAAG,GAAG,CAAC;EACZ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACpB,CAAC;;CACD,CAAC,GAAG,GAAG,CAAC;EACP,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACpB,CAAC;AACF,CAAC,CAAC" } \ No newline at end of file diff --git a/test/samples/object-expressions/expected.js.map b/test/samples/object-expressions/expected.js.map index 60e7e074..b3a721d3 100644 --- a/test/samples/object-expressions/expected.js.map +++ b/test/samples/object-expressions/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "obj = { foo, bar, baz: qux };\nobj = { \"1\": \"1\" };\nobj = { true: true };\nobj = { foo };\nobj = { [foo]: foo };\nobj = { [foo]: \"foo\" };\nlet blah;\nobj = { blah };\nobj = { blah };\nobj = { a: b };\n({ a: 1, b: 1 });\n\nobj = {\n\tmethod() {\n\t\tconsole.log('hello');\n\t}\n};\n\nempty = {};\nopts = opts || {};\n\nobj = {\n\tget foo() {\n\t\treturn _foo;\n\t},\n\tset foo(value) {\n\t\t_foo = value;\n\t},\n\tget [foo]() {\n\t\treturn _foo;\n\t},\n\tset [foo](value) {\n\t\t_foo = value;\n\t}\n};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AAG,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACnB,GAAG,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACrB,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACd,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;AACrB,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC;;AACvB,GAAG,CAAC,IAAI,CAAC;;AACT,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AACf,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AACf,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACf,AAAC,CAAA,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA,CAAE;;AAEjB,GAAG,GAAG;CACL,MAAM,GAAG,CAAC;EACT,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;CACtB,CAAC;AACF,CAAC,CAAC;;AAEF,KAAK,GAAG,CAAC,CAAC,CAAC;AACX,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC;;AAElB,GAAG,GAAG;CACL,IAAI,GAAG,GAAG,CAAC;EACV,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;CACD,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;EACf,IAAI,GAAG,KAAK,CAAC;CACd,CAAC;;CACD,KAAK,GAAG,IAAI,CAAC;EACZ,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;CACD,KAAK,GAAG,EAAE,KAAK,EAAE,CAAC;EACjB,IAAI,GAAG,KAAK,CAAC;CACd,CAAC;AACF,CAAC,CAAC" } \ No newline at end of file diff --git a/test/samples/object-format/expected.js.map b/test/samples/object-format/expected.js.map index 67643098..3a10975e 100644 --- a/test/samples/object-format/expected.js.map +++ b/test/samples/object-format/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "const obj1 = {\n\tfoo: 'bar',\n\tlevel11: { level12: { hello: 'world' } },\n\tlevel21: { level22: { world: 'hello' } },\n\thello: 'world',\n\tlevel31: { level32: { world: 'hello' } }\n};\n\nconst obj2 = {\n\tbefore: 1,\n\tobject: {\n\t\ta: 'lorem ipsum dolor sit amet',\n\t\tb: 'lorem ipsum dolor sit amet',\n\t\tc: 'lorem ipsum dolor sit amet',\n\t\td: 'lorem ipsum dolor sit amet'\n\t},\n\tarray: [\n\t\t'lorem ipsum dolor sit amet',\n\t\t'lorem ipsum dolor sit amet',\n\t\t'lorem ipsum dolor sit amet',\n\t\t'lorem ipsum dolor sit amet'\n\t],\n\tafter: 2\n};\n" ], - "mappings": "AAAA,KAAK,CAAC,IAAI,GAAG;CACZ,GAAG,EAAE,KAAK;CACV,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;CACxC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;CACxC,KAAK,EAAE,OAAO;CACd,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;CACxC,CAAC;;AAEF,KAAK,CAAC,IAAI,GAAG;CACZ,MAAM,EAAE,CAAC;CACT,MAAM,EAAE;EACP,CAAC,EAAE,4BAA4B;EAC/B,CAAC,EAAE,4BAA4B;EAC/B,CAAC,EAAE,4BAA4B;EAC/B,CAAC,EAAE,4BAA4B;EAC/B;CACD,KAAK,EAAE;EACN,4BAA4B;EAC5B,4BAA4B;EAC5B,4BAA4B;EAC5B,4BAA4B;EAC5B;CACD,KAAK,EAAE,CAAC;CACR,CAAC,AACF" + "mappings": "AAAA,KAAK,CAAC,IAAI,GAAG;CACZ,GAAG,EAAE,KAAK;CACV,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACxC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACxC,KAAK,EAAE,OAAO;CACd,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC;;AAEF,KAAK,CAAC,IAAI,GAAG;CACZ,MAAM,EAAE,CAAC;CACT,MAAM,EAAE;EACP,CAAC,EAAE,4BAA4B;EAC/B,CAAC,EAAE,4BAA4B;EAC/B,CAAC,EAAE,4BAA4B;EAC/B,CAAC,EAAE,4BAA4B;CAChC,CAAC;CACD,KAAK,EAAE;EACN,4BAA4B;EAC5B,4BAA4B;EAC5B,4BAA4B;EAC5B,4BAA4B;CAC7B,CAAC;CACD,KAAK,EAAE,CAAC;AACT,CAAC,CAAC,AACF" } \ No newline at end of file diff --git a/test/samples/parenthesized-expression/expected.js.map b/test/samples/parenthesized-expression/expected.js.map index f1cb383b..d186e616 100644 --- a/test/samples/parenthesized-expression/expected.js.map +++ b/test/samples/parenthesized-expression/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "a + b;\n({} + []);\n(class {});\n(class C {});\n({} ? a : b);\n({} && a);\n(function () {})`x`;\n({}).x;\n(function () {})();\nx = {};\n[a] = b;\n(a ? b : c) ? d : e;\n(a ? b : c) ? d : e ? f : g;\na ? b : c ? d : e;\n" ], - "mappings": "AAAA,CAAC,GAAG,CAAC,CAAC;AACN,AAAC,CAAA,EAAE,GAAG,EAAE,CAAA,CAAE;AACV,AAAC,CAAA,MAAM,CAAC,CAAC,CAAA,CAAE;AACX,AAAC,CAAA,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA,CAAE;AACb,AAAC,CAAA,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA,CAAE;AACb,AAAC,CAAA,EAAE,IAAI,CAAC,CAAA,CAAE;AACV,AAAC,CAAA,YAAY,CAAC,CAAC,CAAA,AAAC,GAAG,CAA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CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,AAClB" } \ No newline at end of file diff --git a/test/samples/switch/expected.js.map b/test/samples/switch/expected.js.map index ee9c5de6..41640bc2 100644 --- a/test/samples/switch/expected.js.map +++ b/test/samples/switch/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "switch (foo) {\n\tcase 1:\n\t\tblah();\n\t\tbreak;\n\tcase 2:\n\t\tblah();\n\tdefault:\n\t\tblah();\n}" ], - "mappings": "AAAA,MAAM,EAAE,GAAG;CACV,IAAI,CAAC,CAAC;EACL,IAAI,EAAE,CAAC;EACP,KAAK,CAAC;;CACP,IAAI,CAAC,CAAC;EACL,IAAI,EAAE,CAAC;;CACR,OAAO;EACN,IAAI,EAAE,CAAC;CACR" + "mappings": "AAAA,MAAM,EAAE,GAAG;CACV,IAAI,CAAC,CAAC;EACL,IAAI,CAAC,CAAC,CAAC;EACP,KAAK,CAAC;;CACP,IAAI,CAAC,CAAC;EACL,IAAI,CAAC,CAAC,CAAC;;CACR,OAAO;EACN,IAAI,CAAC,CAAC,CAAC;AACT,CAAC" } \ No newline at end of file diff --git a/test/samples/tagged-template/expected.js.map b/test/samples/tagged-template/expected.js.map index 43f15931..7d312a8d 100644 --- a/test/samples/tagged-template/expected.js.map +++ b/test/samples/tagged-template/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "foo`bar`;\nconst a = (x || y)`tpl`;\nconst b = a.b`t`;\nconst c = f()`t`;\n" ], - "mappings": "AAAA,GAAG,KAAK,CAAC;;AACT,KAAK,CAAC,CAAC,GAAG,AAAC,CAAA,CAAC,IAAI,CAAC,CAAA,AAAC,KAAK,CAAC;AACxB,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACjB,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,AACjB" + "mappings": "AAAA,GAAG,KAAK,CAAC;;AACT,KAAK,CAAC,CAAC,GAAG,AAAC,CAAA,CAAC,IAAI,CAAC,CAAA,AAAC,KAAK,CAAC;AACxB,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACjB,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,AACjB" } \ No newline at end of file diff --git a/test/samples/try-catch/expected.js.map b/test/samples/try-catch/expected.js.map index 2f29c9f2..e036b458 100644 --- a/test/samples/try-catch/expected.js.map +++ b/test/samples/try-catch/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "try {\n\tfoo();\n} catch {\n\tbar();\n}\n\ntry {\n\tfoo();\n} catch(e) {\n\tbar(e);\n} finally {\n\tbaz();\n}" ], - "mappings": "AAAA,GAAG,CAAC,CAAC;CACJ,GAAG,EAAE,CAAC;AACP,CAAC,CAAC,KAAK,CAAC,CAAC;CACR,GAAG,EAAE,CAAC;AACP,CAAC;;AAED,GAAG,CAAC,CAAC;CACJ,GAAG,EAAE,CAAC;AACP,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;CACX,GAAG,CAAC,CAAC,CAAC,CAAC;AACR,CAAC,SAAS,CAAC;CACV,GAAG,EAAE,CAAC;AACP,CAAC" + "mappings": "AAAA,GAAG,CAAC,CAAC;CACJ,GAAG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,KAAK,CAAC,CAAC;CACR,GAAG,CAAC,CAAC,CAAC;AACP,CAAC;;AAED,GAAG,CAAC,CAAC;CACJ,GAAG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;CACX,GAAG,CAAC,CAAC,CAAC,CAAC;AACR,CAAC,SAAS,CAAC;CACV,GAAG,CAAC,CAAC,CAAC;AACP,CAAC" } \ No newline at end of file diff --git a/test/samples/ts-array-patterns/expected.ts.map b/test/samples/ts-array-patterns/expected.ts.map index 14ead94f..7f165562 100644 --- a/test/samples/ts-array-patterns/expected.ts.map +++ b/test/samples/ts-array-patterns/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "const [a, b]: string[] = ['foo', 'bar'];\n\nfunction fn([first, second]: number[]) {\n\treturn first + second;\n}\n" ], - "mappings": "AAAA,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;;AAExC,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;CACvC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC;AACvB,CAAC,AACD" + "mappings": "AAAA,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,AAAU,CAAT,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;;AAExC,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,AAAU,CAAT,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;CACvC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC;AACvB,CAAC,AACD" } \ No newline at end of file diff --git a/test/samples/ts-arrow-as-const-object/expected.ts.map b/test/samples/ts-arrow-as-const-object/expected.ts.map index 5fe8f0d4..5d324991 100644 --- a/test/samples/ts-arrow-as-const-object/expected.ts.map +++ b/test/samples/ts-arrow-as-const-object/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "const as_const = [].map(() => ({ baz }) as const);\nconst non_null = [].map(() => ({ baz: 1 })!);\nconst satisfies = [].map(() => ({ x: 1 }) satisfies { x: number });\n" ], - "mappings": "AAAA,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAA,AAAC,EAAE,GAAG,EAAE,IAAK,KAAK,CAAA,CAAC,CAAC;AAClD,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAA,AAAC,CAAA,EAAE,GAAG,EAAE,CAAC,EAAE,CAAA,CAAE,CAAA,CAAC,CAAC;AAC7C,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAA,AAAC,EAAE,CAAC,EAAE,CAAC,EAAE,WAAY,EAAE,CAAC,EAAE,MAAM,EAAE,CAAA,CAAC,CAAC,AACnE" + "mappings": "AAAA,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAA,AAAC,EAAE,GAAG,CAAC,CAAC,IAAK,KAAK,CAAA,CAAC,CAAC;AAClD,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAA,AAAC,CAAA,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA,CAAE,CAAA,CAAC,CAAC;AAC7C,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAA,AAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,WAAY,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC,AACnE" } \ No newline at end of file diff --git a/test/samples/ts-arrow-function-long-return-type/expected.ts.map b/test/samples/ts-arrow-function-long-return-type/expected.ts.map index 9adca2f0..bb0e21db 100644 --- a/test/samples/ts-arrow-function-long-return-type/expected.ts.map +++ b/test/samples/ts-arrow-function-long-return-type/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "const toNode = (\n\tkind: string\n): { kind: 'logical'; value: string } | { kind: 'binary'; value: number } =>\n\tkind === 'and' ? { kind: 'logical', value: kind } : { kind: 'binary', value: 1 };\n" ], - "mappings": "AAAA,KAAK,CAAC,MAAM,GAAG,CACd,IAAI,EAAE,MAAM,CACZ,EAAE;CAAA,EAAE,IAAI,EAAE,SAAS,AAAC,EAAC,KAAK,EAAE,MAAM,EAAE;CAAG,EAAE,IAAI,EAAE,QAAQ,AAAC,EAAC,KAAK,EAAE,MAAM,EAAE,IACxE,IAAI,KAAK,KAAK;GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE;GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,AAClF" + "mappings": "AAAA,KAAK,CAAC,MAAM,GAAG,CACd,IAAI,EAAE,MAAM,CACZ,EAAE;CAAA,EAAE,IAAI,EAAE,SAAS,AAAC,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAAG,EAAE,IAAI,EAAE,QAAQ,AAAC,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC,IACxE,IAAI,KAAK,KAAK;GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,AAClF" } \ No newline at end of file diff --git a/test/samples/ts-as-expression/expected.ts.map b/test/samples/ts-as-expression/expected.ts.map index 7b0c8706..a4b1ae16 100644 --- a/test/samples/ts-as-expression/expected.ts.map +++ b/test/samples/ts-as-expression/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "const a: number = 42;\nconst b = a as unknown as string;\n\ntype C = {\n\tname: string;\n};\n\ntype D = {\n\tfirstName: string;\n};\n\nconst e: C = {\n\tname: 'foo'\n} as unknown as D;\n\nconst f = (Math.random() > 0.5 ? { firstName: 'name1' } : { firstName: 'name2' }) as unknown as D;\n\nconst g = h(e['name']) as (scope: ng.IScope) => b;\n" ], - "mappings": "AAAA,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC;AACrB,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,OAAO,IAAI,MAAM,CAAC;;AAEjC,KAAK,CAAC,GAAG,EACR,IAAI,EAAE,MAAM,AAAC,EACb,CAAC;AAEF,KAAK,CAAC,GAAG,EACR,SAAS,EAAE,MAAM,AAAC,EAClB,CAAC;;AAEF,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EACZ,IAAI,EAAE,KAAK,EACX,IAAI,OAAO,IAAI,CAAC,CAAC;AAElB,KAAK,CAAC,CAAC,GAAG,AAAC,CAAA,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,CAAA,IAAK,OAAO,IAAI,CAAC,CAAC;AAElG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,AAClD" + "mappings": "AAAA,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC;AACrB,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,OAAO,IAAI,MAAM,CAAC;;AAEjC,KAAK,CAAC,GAAG,EACR,IAAI,EAAE,MAAM,AAAC,CACd,CAAC,CAAC;AAEF,KAAK,CAAC,GAAG,EACR,SAAS,EAAE,MAAM,AAAC,CACnB,CAAC,CAAC;;AAEF,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EACZ,IAAI,EAAE,KAAK,CACZ,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC;AAElB,KAAK,CAAC,CAAC,GAAG,AAAC,CAAA,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAA,IAAK,OAAO,IAAI,CAAC,CAAC;AAElG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,AAClD" } \ No newline at end of file diff --git a/test/samples/ts-as-precedence/expected.ts.map b/test/samples/ts-as-precedence/expected.ts.map index 64ed7630..69b61a0d 100644 --- a/test/samples/ts-as-precedence/expected.ts.map +++ b/test/samples/ts-as-precedence/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "!(0 as number);\n-(0 as number);\n~(0 as number);\ntypeof (0 as any);\nvoid (0 as any);\n1 + (0 as number);\n2 * (0 as number);\n1 ** (0n as any);\n1 & (0 as number);\n(0 as number) ** 2;\n(0 as number) & 1;\n(0 as number) | 1;\n(0 as number) + 1;\n(0 as number)!;\na && (b as C);\n(a as C) && b;\n!(0 satisfies number);\n1 ** (0n satisfies any);\n1 + (0 satisfies number);\n(0 satisfies number)!;\n(w as any) = [1];\n(w satisfies any) += 1;\n(w) = 1;\n(Map as any)++;\n++(Map as any);\n(w satisfies any)--;\n--(w satisfies any);\n(w)++;\n++(w);\n((M.g as any))([1]);\n((fn?.method))();\nconst f1 = (M.g satisfies any);\nconst f2 = (M.g);\nconst f3 = (a ? b : c);\nconst f4 = (a || b);\n// prettier-ignore\nconst asserted = (x) ** y;\n\nconst tag = (x as T)`t`;\n\nasync function f() {\n\tawait (0 as any);\n\tawait (0 satisfies number);\n\t(await x)!;\n}\n" ], - "mappings": "AAAA,CAAC,AAAC,CAAA,CAAC,IAAI,MAAM,CAAA,AAAC,CAAC;AACf,CAAC,AAAC,CAAA,CAAC,IAAI,MAAM,CAAA,AAAC,CAAC;AACf,CAAC,AAAC,CAAA,CAAC,IAAI,MAAM,CAAA,AAAC,CAAC;AACf,MAAM,CAAE,CAAA,CAAC,IAAI,GAAG,CAAA,AAAC,CAAC;AAClB,IAAI,CAAE,CAAA,CAAC,IAAI,GAAG,CAAA,AAAC,CAAC;AAChB,CAAC,GAAI,CAAA,CAAC,IAAI,MAAM,CAAA,AAAC,CAAC;AAClB,CAAC,GAAI,CAAA,CAAC,IAAI,MAAM,CAAA,AAAC,CAAC;AAClB,CAAC,IAAK,CAAA,EAAE,IAAI,GAAG,CAAA,AAAC,CAAC;AACjB,CAAC,GAAI,CAAA,CAAC,IAAI,MAAM,CAAA,AAAC,CAAC;AAClB,AAAC,CAAA,CAAC,IAAI,MAAM,CAAA,IAAK,CAAC,CAAC;AACnB,AAAC,C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ts.map b/test/samples/ts-comment-signature/expected.ts.map index 9da1180c..3080551c 100644 --- a/test/samples/ts-comment-signature/expected.ts.map +++ b/test/samples/ts-comment-signature/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "type F = (a: A /* c1 */) /* c2 */ => /* c3 */ T;\n\ntype G = { (a /* c1 */) /* c2 */ };\n\ntype H = { m(a /* c1 */) /* c2 */ };\n\nfunction f(a /* c1 */) /* c2 */ {}\n\nconst g = (a /* c1 */) /* c2 */ => a;\n" ], - "mappings": "AAAA,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,gCAAgC,CAAC,CAAC;AAEhD,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,UAAU,WAAW,CAAC;AAEnC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,UAAU,WAAW,CAAC;;AAEpC,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC;;AAElC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,uBAAuB,CAAC,CAAC,AACrC" + "mappings": "AAAA,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,gCAAgC,CAAC,CAAC;AAEhD,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,UAAU,UAAU,CAAC,CAAC;AAEnC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,UAAU,UAAU,CAAC,CAAC;;AAEpC,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC;;AAElC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,uBAAuB,CAAC,CAAC,AACrC" } \ No newline at end of file diff --git a/test/samples/ts-declaration-modifiers/expected.ts.map b/test/samples/ts-declaration-modifiers/expected.ts.map index 42d0b546..d7b6c094 100644 --- a/test/samples/ts-declaration-modifiers/expected.ts.map +++ b/test/samples/ts-declaration-modifiers/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "const enum Constant {\n\tvalue\n}\n\ndeclare enum Ambient {\n\tvalue\n}\n\nimport type Imported = require('pkg');\n\ntype Constructor = abstract new (value: T) => T;\n" ], - "mappings": "AAAA,WAAW,QAAQ;CAClB,KAAK;CACL;;AAED,aAAa,OAAO;CACnB,KAAK;CACL;;AAED,MAAM,MAAM,QAAQ,GAAG,QAAQ,KAAK,EAAC,AAAC;;AAEtC,KAAK,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,AACnD" + "mappings": "AAAA,WAAW,QAAQ;CAClB,KAAK;AACN,CAAC;;AAED,aAAa,OAAO;CACnB,KAAK;AACN,CAAC;;AAED,MAAM,MAAM,QAAQ,GAAG,QAAQ,KAAK,EAAC,AAAC;;AAEtC,KAAK,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,AACnD" } \ No newline at end of file diff --git a/test/samples/ts-declare-interface-type/expected.ts.map b/test/samples/ts-declare-interface-type/expected.ts.map index ae9b870a..199968c6 100644 --- a/test/samples/ts-declare-interface-type/expected.ts.map +++ b/test/samples/ts-declare-interface-type/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "declare interface Ambient {\n\tvalue: string;\n}\n\ndeclare type Alias = string;\n\nexport declare interface Exported extends Ambient {\n\tother: T;\n}\n\ninterface Plain {\n\tvalue: string;\n}\n\ntype PlainAlias = number;\n" ], - "mappings": "AAAA,kBAAkB,OAAO,EAAC,CACzB,KAAK,EAAE,MAAM,AAAC,CACd,CAAA;;AAED,aAAa,KAAK,GAAG,MAAM,CAAC;;AAE5B,MAAM,CAAC,kBAAkB,QAAQ,CAAC,CAAC,CAAC,SAAS,OAAO,EAAC,CACpD,KAAK,EAAE,CAAC,AAAC,CACT,CAAA;;AAED,UAAU,KAAK,EAAC,CACf,KAAK,EAAE,MAAM,AAAC,CACd,CAAA;;AAED,KAAK,UAAU,GAAG,MAAM,CAAC,AACzB" + "mappings": "AAAA,kBAAkB,OAAO,CAAC,CAAA,CACzB,KAAK,EAAE,MAAM,AAAC,CACd,AAAD,CAAC;;AAED,aAAa,KAAK,GAAG,MAAM,CAAC;;AAE5B,MAAM,CAAC,kBAAkB,QAAQ,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,CAAA,CACpD,KAAK,EAAE,CAAC,AAAC,CACT,AAAD,CAAC;;AAED,UAAU,KAAK,CAAC,CAAA,CACf,KAAK,EAAE,MAAM,AAAC,CACd,AAAD,CAAC;;AAED,KAAK,UAAU,GAAG,MAAM,CAAC,AACzB" } \ No newline at end of file diff --git a/test/samples/ts-declare-module/expected.ts.map b/test/samples/ts-declare-module/expected.ts.map index d5f78cb7..9a5c33b4 100644 --- a/test/samples/ts-declare-module/expected.ts.map +++ b/test/samples/ts-declare-module/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "declare module 'svelte' {}\n" ], - "mappings": "AAAA,eAAe,QAAQ,AAAC;CAAE,AAC1B" + "mappings": "AAAA,eAAe,QAAQ,AAAC,CAAA;AAAC,CAAC,AAC1B" } \ No newline at end of file diff --git a/test/samples/ts-declare/expected.ts.map b/test/samples/ts-declare/expected.ts.map index 2104c512..b82ae0ce 100644 --- a/test/samples/ts-declare/expected.ts.map +++ b/test/samples/ts-declare/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "declare function a(): void;\ndeclare const b: number;\ndeclare class c {}\n\nexport {};\n" ], - "mappings": "AAAA,iBAAiB,CAAC,EAAE,EAAE,IAAI,CAAC;;AAC3B,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;;AACxB,cAAc,CAAC,CAAC,CAAC,CAAC;;AAElB,MAAM,IAAI,AACV" + "mappings": "AAAA,iBAAiB,CAAC,EAAE,EAAE,IAAI,CAAC;;AAC3B,OAAO,OAAO,CAAC,EAAE,MAAM,CAAC;;AACxB,cAAc,CAAC,CAAC,CAAC,CAAC;;AAElB,MAAM,IAAI,AACV" } \ No newline at end of file diff --git a/test/samples/ts-decorator-export-comment/expected.ts.map b/test/samples/ts-decorator-export-comment/expected.ts.map index 91ed8ecb..e0e5d3cf 100644 --- a/test/samples/ts-decorator-export-comment/expected.ts.map +++ b/test/samples/ts-decorator-export-comment/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "@dec\nexport /* c */ declare class X {}\n" ], - "mappings": "AAAA,CAAC,GAAG;MACE,uBAAuB,CAAC,CAAC,CAAC,CAAC,AACjC" + "mappings": "AAAA,CAAC,GAAG;AACJ,MAAM,SAAS,cAAc,CAAC,CAAC,CAAC,CAAC,AACjC" } \ No newline at end of file diff --git a/test/samples/ts-decorators-class/expected.ts.map b/test/samples/ts-decorators-class/expected.ts.map index 49a621ae..896cce9a 100644 --- a/test/samples/ts-decorators-class/expected.ts.map +++ b/test/samples/ts-decorators-class/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "export class Entity {\n\tconstructor(\n\t\tprivate readonly name: string,\n\t\tprivate readonly info: boolean\n\t) {}\n}\n\n@Entity('users', { info: true })\nexport class User {}\n\n@Entity('categories', { info: false })\nclass Category {}\n\n@Entity('tasks', { info: true })\nexport class Task {}\n\n@Entity('default', { info: true })\nexport default class Default {}\n\nconst u = new User();\nconst c = new Category();\nconst t = new Task();\n" ], - "mappings": "AAAA,MAAM,CAAC,MAAM,MAAM,CAAC,CAAC;CACpB,WAAW;EACV,iBAAiB,IAAI,EAAE,MAAM;EAC7B,iBAAiB,IAAI,EAAE,OAAO;GAC7B,CAAC,CAAC;AACL,CAAC;;AAED,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;MAC1B,OAAO,IAAI,CAAC,CAAC,CAAC;;AAEpB,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;MAChC,QAAQ,CAAC,CAAC,CAAC;;AAEjB,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;MAC1B,OAAO,IAAI,CAAC,CAAC,CAAC;;AAEpB,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;MAC5B,eAAe,OAAO,CAAC,CAAC,CAAC,CAAA;;AAE/B,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;AACrB,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;AACzB,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,AACrB" + "mappings": "AAAA,MAAM,CAAC,MAAM,MAAM,CAAC,CAAC;CACpB,WAAW;EACV,iBAAiB,IAAI,EAAE,MAAM;EAC7B,iBAAiB,IAAI,EAAE,OAAO;GAC7B,CAAC,CAAC;AACL,CAAC;;AAED,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAChC,MAAM,OAAO,IAAI,CAAC,CAAC,CAAC;;AAEpB,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;MAChC,QAAQ,CAAC,CAAC,CAAC;;AAEjB,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAChC,MAAM,OAAO,IAAI,CAAC,CAAC,CAAC;;AAEpB,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAClC,MAAM,eAAe,OAAO,CAAC,CAAC,CAAC,CAAA;;AAE/B,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;AACrB,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;AACzB,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,AACrB" } \ No newline at end of file diff --git a/test/samples/ts-decorators-expression/expected.ts.map b/test/samples/ts-decorators-expression/expected.ts.map index 545507c7..47fb683a 100644 --- a/test/samples/ts-decorators-expression/expected.ts.map +++ b/test/samples/ts-decorators-expression/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "class Fields {\n\tstatic uuid() {\n\t\treturn function (target: any, propertyKey: string | symbol) {\n\t\t\tObject.defineProperty(target, propertyKey, { value: 'random uuid...', writable: true });\n\t\t};\n\t}\n}\n\nclass User {\n\t@Fields.uuid()\n\tid: string;\n}\n\n@(a ? b : c)\nclass Conditional {}\n\n@(a || b)\nclass Logical {}\n\n@dec\nclass Identifier {}\n\n@a.b.c\nclass Member {}\n\n@a()\nclass Call {}\n\n@(a[0])\nclass Computed {}\n\n@(a().b)\nclass MemberOfCall {}\n\n@(this.x)\nclass This {}\n\nconst u = new User();\nconsole.log(u.id); // will print \"random uuid...\"\n" ], - "mappings": "AAAA,MAAM,MAAM,CAAC,CAAC;CACb,OAAO,IAAI,GAAG,CAAC;EACd,MAAM,CAAC,UAAU,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;GAC5D,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;EACzF,CAAC,CAAC;CACH,CAAC;AACF,CAAC;;AAED,MAAM,IAAI,CAAC,CAAC;CACX,CAAC,MAAM,CAAC,IAAI,EAAE;CACd,EAAE,EAAE,MAAM,CAAC;AACZ,CAAC;;AAED,CAAE,CAAA,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA,AAAC;MACN,WAAW,CAAC,CAAC,CAAC;;AAEpB,CAAE,CAAA,CAAC,IAAI,CAAC,CAAA,AAAC;MACH,OAAO,CAAC,CAAC,CAAC;;AAEhB,CAAC,GAAG;MACE,UAAU,CAAC,CAAC,CAAC;;AAEnB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;MACA,MAAM,CAAC,CAAC,CAAC;;AAEf,CAAC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AAC,CAAC,CAAC,CAAC,CAAA,AAAC;MACD,QAAQ,CAAC,CAAC,CAAC;;AAEjB,CAAE,CAAA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,AAAC;MACF,YAAY,CAAC,CAAC,CAAC;;AAErB,CAAE,CAAA,IAAI,CAAC,CAAC,CAAA,AAAC;MACH,IAAI,CAAC,CAAC,CAAC;;AAEb,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;;AACrB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,+BAClB" } \ No newline at end of file diff --git a/test/samples/ts-decorators/expected.ts.map b/test/samples/ts-decorators/expected.ts.map index 05aded94..6475bafd 100644 --- a/test/samples/ts-decorators/expected.ts.map +++ b/test/samples/ts-decorators/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "function loggedMethod(headMessage = 'LOG:') {\n\treturn function actualDecorator(originalMethod: any, context: ClassMethodDecoratorContext) {\n\t\tconst methodName = String(context.name);\n\n\t\tfunction replacementMethod(this: any, ...args: any[]) {\n\t\t\tconsole.log(`${headMessage} Entering method '${methodName}'.`);\n\t\t\tconst result = originalMethod.call(this, ...args);\n\t\t\tconsole.log(`${headMessage} Exiting method '${methodName}'.`);\n\t\t\treturn result;\n\t\t}\n\n\t\treturn replacementMethod;\n\t};\n}\n\nclass Person {\n\tname: string;\n\tconstructor(name: string) {\n\t\tthis.name = name;\n\t}\n\n\t@loggedMethod('⚠️')\n\tgreet() {\n\t\tconsole.log(`Hello, my name is ${this.name}.`);\n\t}\n}\n\nconst p = new Person('Ron');\np.greet();\n" ], - "mappings": "AAAA,SAAS,YAAY,CAAC,WAAW,GAAG,MAAM,EAAE,CAAC;CAC5C,MAAM,CAAC,SAAS,eAAe,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;EAC3F,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAA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,GAAG,CAAC,GAAG,WAAW,qBAAqB,UAAU,IAAI,CAAC,CAAC;;GAC/D,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;;GAClD,OAAO,CAAC,GAAG,CAAC,GAAG,WAAW,oBAAoB,UAAU,IAAI,CAAC,CAAC;;GAC9D,MAAM,CAAC,MAAM,CAAC;EACf,CAAC;;EAED,MAAM,CAAC,iBAAiB,CAAC;CAC1B,CAAC,CAAC;AACH,CAAC;;AAED,MAAM,MAAM,CAAC,CAAC;CACb,IAAI,EAAE,MAAM,CAAC;;CACb,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;EAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;CAClB,CAAC;;CAED,CAAC,YAAY,CAAC,IAAI,CAAC;CACnB,KAAK,GAAG,CAAC;EACR,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;CAChD,CAAC;AACF,CAAC;;AAED,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;;AAC5B,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,AACV" } \ No newline at end of file diff --git a/test/samples/ts-enums/expected.ts.map b/test/samples/ts-enums/expected.ts.map index 920214e1..8bd4a3a1 100644 --- a/test/samples/ts-enums/expected.ts.map +++ b/test/samples/ts-enums/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "enum UserResponse {\n\tNo = 0,\n\tYes = 1\n}\n\nfunction respond(recipient: string, message: UserResponse): void {\n\t// ...\n}\n\nrespond('Princess Caroline', UserResponse.Yes);\n" ], - "mappings": "AAAA,KAAK,YAAY;CAChB,EAAE,GAAG,CAAC,EACN,GAAG,GAAG,CAAC;CACP;;AAED,SAAS,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,CAAC;;AAElE,CAAC;;AAED,OAAO,CAAC,mBAAmB,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,AAC/C" + "mappings": "AAAA,KAAK,YAAY;CAChB,EAAE,GAAG,CAAC,EACN,GAAG,GAAG,CAAC;AACR,CAAC;;AAED,SAAS,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,CAAC;;AAElE,CAAC;;AAED,OAAO,CAAC,mBAAmB,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,AAC/C" } \ No newline at end of file diff --git a/test/samples/ts-generic-references/expected.ts.map b/test/samples/ts-generic-references/expected.ts.map index df3ef2f8..977d580c 100644 --- a/test/samples/ts-generic-references/expected.ts.map +++ b/test/samples/ts-generic-references/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "type Imported = import('pkg').Value;\n\ninterface Derived extends Base {}\n\nclass Implementation implements Contract {}\n" ], - "mappings": "AAAA,KAAK,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;;AAE5C,UAAU,OAAO,SAAS,IAAI,CAAC,MAAM,CAAC,EAAC,AAAE,CAAA;;AAEzC,MAAM,cAAc,YAAY,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,AACnD" + "mappings": "AAAA,KAAK,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;;AAE5C,UAAU,OAAO,SAAS,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA,AAAE,AAAD,CAAC;;AAEzC,MAAM,cAAc,YAAY,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,AACnD" } \ No newline at end of file diff --git a/test/samples/ts-generic-types/expected.ts.map b/test/samples/ts-generic-types/expected.ts.map index e796f639..a43cdc63 100644 --- a/test/samples/ts-generic-types/expected.ts.map +++ b/test/samples/ts-generic-types/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "type Generic = {\n\tdata: T;\n};\n\nconst n: Generic = { data: 1 };\nconst s: Generic = { data: 'foo' };\nconst b: Generic = { data: true };\n\nfunction foo(np: Generic) {\n\tconsole.log(np.data);\n}\n\nfunction bar(np: Generic): Generic {\n\treturn { data: true };\n}\n\nfunction barTypeof(np: Generic): Generic {\n\treturn { data: true };\n}\n\ntype DoubleGeneric = {\n\tkey: K;\n\tvalue: V;\n};\n\nfunction foobar(np: DoubleGeneric): DoubleGeneric {\n\treturn { key: true, value: 'foo' };\n}\n" ], - "mappings": "AAAA,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,EACjB,IAAI,EAAE,CAAC,AAAC,EACR,CAAC;;AAEF,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACvC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC3C,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;AAE3C,SAAS,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;CAClC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC;;AAED,SAAS,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;CACpD,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACvB,CAAC;;AAED,SAAS,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;CAC5D,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACvB,CAA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AI,EAAE,IAAI,CAAC,CAAC,CAAC;AACvB,CAAC;;AAED,KAAK,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,EAC1B,GAAG,EAAE,CAAC,AAAC,EACP,KAAK,EAAE,CAAC,AAAC,CACV,CAAC,CAAC;;AAEF,SAAS,MAAM,CAAC,EAAE,EAAE,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;CACnF,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AACpC,CAAC,AACD" } \ No newline at end of file diff --git a/test/samples/ts-implements/expected.ts.map b/test/samples/ts-implements/expected.ts.map index ea12ad08..40322c5b 100644 --- a/test/samples/ts-implements/expected.ts.map +++ b/test/samples/ts-implements/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "interface SelectableControl {\n\tselect(): void;\n}\n\ninterface Scrollable {\n\tscroll(): void;\n}\n\nclass Button implements SelectableControl, Scrollable {\n\tselect() {}\n}\n" ], - "mappings": "AAAA,UAAU,iBAAiB,EAAC,CAC3B,MAAM,EAAE,EAAE,IAAI,AAAC,CACf,CAAA;AAED,UAAU,UAAU,EAAC,CACpB,MAAM,EAAE,EAAE,IAAI,AAAC,CACf,CAAA;;AAED,MAAM,MAAM,YAAY,iBAAiB,EAAE,UAAU,CAAC,CAAC;CACtD,MAAM,GAAG,CAAC,CAAC;AACZ,CAAC,AACD" + "mappings": "AAAA,UAAU,iBAAiB,CAAC,CAAA,CAC3B,MAAM,EAAE,EAAE,IAAI,AAAC,CACf,AAAD,CAAC;AAED,UAAU,UAAU,CAAC,CAAA,CACpB,MAAM,EAAE,EAAE,IAAI,AAAC,CACf,AAAD,CAAC;;AAED,MAAM,MAAM,YAAY,iBAAiB,EAAE,UAAU,CAAC,CAAC;CACtD,MAAM,GAAG,CAAC,CAAC;AACZ,CAAC,AACD" } \ No newline at end of file diff --git a/test/samples/ts-index-access-type/expected.ts.map b/test/samples/ts-index-access-type/expected.ts.map index 4c5f4ccd..2e81cbdc 100644 --- a/test/samples/ts-index-access-type/expected.ts.map +++ b/test/samples/ts-index-access-type/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "type A = { a: string; b: number };\ntype B = A['b'];\n\nconst c: A['b'] = 1;\n" ], - "mappings": "AAAA,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,AAAC,EAAC,CAAC,EAAE,MAAM,EAAE,CAAC;AAClC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;;AAEhB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,AACpB" + "mappings": "AAAA,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,AAAC,EAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAClC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;;AAEhB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,AACpB" } \ No newline at end of file diff --git a/test/samples/ts-infer-extends/expected.ts.map b/test/samples/ts-infer-extends/expected.ts.map index 5811f2cf..4a15915e 100644 --- a/test/samples/ts-infer-extends/expected.ts.map +++ b/test/samples/ts-infer-extends/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "type X3 = T extends [infer U extends number] ? MustBeNumber : never;\ntype X4 = T extends [infer U extends number, infer U extends number] ? MustBeNumber : never;\ntype X5 = T extends [infer U extends number, infer U] ? MustBeNumber : never;\ntype X6 = T extends [infer U, infer U extends number] ? MustBeNumber : never;\ntype X7 = T extends [infer U extends string, infer U extends number] ? U : never;\ntype X8 = T extends infer U extends number ? U : T;\ntype X9 = T extends (infer U extends number ? U : T) ? U : T;\ntype X10 = T extends (infer U extends number) | { a: infer U extends number } ? U : never;\ntype X11 = T extends (infer U extends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AAS,AAAC,CAAA,MAAM,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,CAAC,CAAA,AAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnE,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,AAAC,CAAA,MAAM,CAAgB,SAAN,MAAM,CAAA,AAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAgB,SAAN,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC7F,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,AAAC,CAAA,MAAM,CAAgB,SAAN,MAAM,CAAA,AAAC,GAAG,EAAE,CAAC,EAAE,MAAM,CAAgB,SAAN,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,AAC7F" } \ No newline at end of file diff --git a/test/samples/ts-interfaces/expected.ts.map b/test/samples/ts-interfaces/expected.ts.map index 0c82dbc9..e8a9af52 100644 --- a/test/samples/ts-interfaces/expected.ts.map +++ b/test/samples/ts-interfaces/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "interface Test {\n\tfunc: (a: string) => Promise;\n\tfunc2: () => Promise;\n\ta: number;\n\tb: boolean;\n}\n\ninterface IndexSignature {\n\t[key: string]: string;\n}\n\nclass Control {\n\tprivate state: any;\n}\n\ninterface SelectableControl extends Control {\n\tselect(): void;\n\tbar();\n}\n\nclass Button extends Control implements SelectableControl {\n\tselect() {}\n}\n\nclass TextBox extends Control {\n\tselect() {}\n}\n" ], - "mappings": "AAAA,UAAU,IAAI,EAAC;CACd,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,AAAC;CACnC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,AAAC;CAC3B,CAAC,EAAE,MAAM,AAAC;CACV,CAAC,EAAE,OAAO,AAAC;AACX,CAAA;;AAED,UAAU,cAAc,EAAC,CACxB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,AAAC,CACtB,CAAA;;AAED,MAAM,OAAO,CAAC,CAAC;CACd,QAAQ,KAAK,EAAE,GAAG,CAAC;AACpB,CAAC;;AAED,UAAU,iBAAiB,SAAS,OAAO,EAAC,CAC3C,MAAM,EAAE,EAAE,IAAI,AAAC,EACf,GAAG,EAAG,CACN,CAAA;;AAED,MAAM,MAAM,SAAS,OAAO,YAAY,iBAAiB,CAAC,CAAC;CAC1D,MAAM,GAAG,CAAC,CAAC;AACZ,CAAC;;AAED,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC;CAC9B,MAAM,GAAG,CAAC,CAAC;AACZ,CAAC,AACD" + "mappings": "AAAA,UAAU,IAAI,CAAC,CAAA;CACd,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,AAAC;CACnC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,AAAC;CAC3B,CAAC,EAAE,MAAM,AAAC;CACV,CAAC,EAAE,OAAO,AAAC;AACX,AAAD,CAAC;;AAED,UAAU,cAAc,CAAC,CAAA,CACxB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,AAAC,CACtB,AAAD,CAAC;;AAED,MAAM,OAAO,CAAC,CAAC;CACd,QAAQ,KAAK,EAAE,GAAG,CAAC;AACpB,CAAC;;AAED,UAAU,iBAAiB,SAAS,OAAO,CAAC,CAAA,CAC3C,MAAM,EAAE,EAAE,IAAI,AAAC,EACf,GAAG,EAAG,CACN,AAAD,CAAC;;AAED,MAAM,MAAM,SAAS,OAAO,YAAY,iBAAiB,CAAC,CAAC;CAC1D,MAAM,GAAG,CAAC,CAAC;AACZ,CAAC;;AAED,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC;CAC9B,MAAM,GAAG,CAAC,CAAC;AACZ,CAAC,AACD" } \ No newline at end of file diff --git a/test/samples/ts-keywords/expected.ts.map b/test/samples/ts-keywords/expected.ts.map index 094ca84b..dbe2fee2 100644 --- a/test/samples/ts-keywords/expected.ts.map +++ b/test/samples/ts-keywords/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "let n: number = 42;\nlet s: string = 'Hello, TypeScript!';\nlet b: boolean = true;\nlet u: unknown = 'whatever';\nlet un: undefined = undefined;\nlet o: object = { name: 'Object' };\nlet bi: bigint = 1234567890123456789012345678901234567890n;\nlet ne: never;\nlet sy: symbol = Symbol('unique');\nlet a: any = { key: 'value' };\nlet v: () => void = () => {};\nlet arr: number[] = [1, 2, 3];\nlet snu: string | null = null;\nlet nun: number | undefined = undefined;\n\n// TODO: commented because acorn doesn't support type assertions but oxc does\n// let ta = true;\n" ], - "mappings": "AAAA,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC;AACnB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAAC;AACrC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;AACtB,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;AAC5B,GAAG,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,CAAC;AAC9B,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACnC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,yCAAyC,CAAC;AAC3D,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC;AACd,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAClC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAC9B,GAAG,CAAC,CAAC,EAAE,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;AAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;;;0BAIxC" + "mappings": "AAAA,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC;AACnB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAAC;AACrC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;AACtB,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;AAC5B,GAAG,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,CAAC;AAC9B,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;AACnC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,yCAAyC,CAAC;AAC3D,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC;AACd,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAClC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAC9B,GAAG,CAAC,CAAC,EAAE,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;AAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;;;0BAIxC" } \ No newline at end of file diff --git a/test/samples/ts-mapped-type/expected.ts.map b/test/samples/ts-mapped-type/expected.ts.map index 796a1d96..0be6eca7 100644 --- a/test/samples/ts-mapped-type/expected.ts.map +++ b/test/samples/ts-mapped-type/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "type M = { [K in keyof JSON]: K };\ntype R = { readonly [K in T]: V };\ntype O = { [K in T]?: V };\ntype Neg = { -readonly [K in T]-?: V };\ntype Pos = { +readonly [K in T]+?: V };\ntype As = { [K in T as `g${K & string}`]: V };\n" ], - "mappings": "AAAA,KAAK,CAAC,GAAG,EAAA,CAAwB,IAAhB,MAAM,IAAI,GAAG,CAAC,CAAE,CAAC;AAClC,KAAK,CAAC,GAAG,WAAA,CAAwB,IAAP,CAAC,GAAG,CAAC,CAAE,CAAC;AAClC,KAAK,CAAC,GAAG,EAAA,CAAgB,IAAR,CAAC,IAAI,CAAC,CAAE,CAAC;AAC1B,KAAK,GAAG,GAAG,YAAA,CAA2B,IAAT,CAAC,KAAK,CAAC,CAAE,CAAC;AACvC,KAAK,GAAG,GAAG,YAAA,CAA2B,IAAT,CAAC,KAAK,CAAC,CAAE,CAAC;AACvC,KAAK,EAAE,GAAG,EAAA,CAAmC,IAA3B,CAAC,IAAI,IAAI,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,CAAE,CAAC,AAC9C" + "mappings": "AAAA,KAAK,CAAC,GAAG,EAAA,CAAwB,IAAhB,MAAM,IAAI,GAAG,CAAC,AAAC,CAAC,CAAC;AAClC,KAAK,CAAC,GAAG,WAAA,CAAwB,IAAP,CAAC,GAAG,CAAC,AAAC,CAAC,CAAC;AAClC,KAAK,CAAC,GAAG,EAAA,CAAgB,IAAR,CAAC,IAAI,CAAC,AAAC,CAAC,CAAC;AAC1B,KAAK,GAAG,GAAG,YAAA,CAA2B,IAAT,CAAC,KAAK,CAAC,AAAC,CAAC,CAAC;AACvC,KAAK,GAAG,GAAG,YAAA,CAA2B,IAAT,CAAC,KAAK,CAAC,AAAC,CAAC,CAAC;AACvC,KAAK,EAAE,GAAG,EAAA,CAAmC,IAA3B,CAAC,IAAI,IAAI,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,AAAC,CAAC,CAAC,AAC9C" } \ No newline at end of file diff --git a/test/samples/ts-method-signature-markers/expected.ts.map b/test/samples/ts-method-signature-markers/expected.ts.map index 557fde25..e8a5ec62 100644 --- a/test/samples/ts-method-signature-markers/expected.ts.map +++ b/test/samples/ts-method-signature-markers/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "interface Example {\n\toptional?(value: T): T;\n}\n" ], - "mappings": "AAAA,UAAU,OAAO,EAAC,CACjB,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,AAAC,CAC1B,CAAA,AACD" + "mappings": "AAAA,UAAU,OAAO,CAAC,CAAA,CACjB,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,AAAC,CAC1B,AAAD,CAAC,AACD" } \ No newline at end of file diff --git a/test/samples/ts-module-declaration/expected.ts.map b/test/samples/ts-module-declaration/expected.ts.map index 71ffd49c..0cb2628a 100644 --- a/test/samples/ts-module-declaration/expected.ts.map +++ b/test/samples/ts-module-declaration/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "declare global {\n\tnamespace App {\n\t\tinterface Error {\n\t\t\tfoo: string;\n\t\t}\n\t}\n}\n\nnamespace A.B.C {\n\texport const x = 1;\n}\n\nnamespace D {\n\texport const x = 1;\n}\n\nexport {};\n" ], - "mappings": "AAAA,QAAQ,MAAM,AAAC;CACd,UAAU,GAAG,AAAC;EACb,UAAU,KAAK,EAAC,CACf,GAAG,EAAE,MAAM,AAAC,CACZ,CAAA;EACD;CACD;;AAED,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,AAAC;CACf,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;CACnB;;AAED,UAAU,CAAC,AAAC;CACX,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;CACnB;;AAED,MAAM,IAAI,AACV" + "mappings": "AAAA,QAAQ,MAAM,AAAC,CAAA;CACd,UAAU,GAAG,AAAC,CAAA;EACb,UAAU,KAAK,CAAC,CAAA,CACf,GAAG,EAAE,MAAM,AAAC,CACZ,AAAD,CAAC;CACF,CAAC;AACF,CAAC;;AAED,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,AAAC,CAAA;CACf,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC;;AAED,UAAU,CAAC,AAAC,CAAA;CACX,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC;;AAED,MAAM,IAAI,AACV" } \ No newline at end of file diff --git a/test/samples/ts-non-null-chain-expressions/expected.ts.map b/test/samples/ts-non-null-chain-expressions/expected.ts.map index 961eea47..c595cddf 100644 --- a/test/samples/ts-non-null-chain-expressions/expected.ts.map +++ b/test/samples/ts-non-null-chain-expressions/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "x?.a!.b;\n(x?.a)!.b;\nx?.a!();\n(x?.a)!();\nx?.a![key];\n(x?.a)![key];\nx?.a!!.b;\n" ], - "mappings": "AAAA,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACR,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,CAAE,CAAC,CAAC,CAAC;AACV,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AACR,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,CAAE,EAAE,CAAC;AACV,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACX,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,CAAE,CAAC,GAAG,CAAC,CAAC;AACb,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,AACT" + "mappings": "AAAA,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACR,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,CAAE,CAAC,CAAC,CAAC;AACV,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACR,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,CAAE,CAAC,CAAC,CAAC;AACV,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACX,AAAC,CAAA,CAAC,EAAE,CAAC,CAAA,CAAE,CAAC,GAAG,CAAC,CAAC;AACb,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,AACT" } \ No newline at end of file diff --git a/test/samples/ts-object-patterns/expected.ts.map b/test/samples/ts-object-patterns/expected.ts.map index a23486c6..f8d79320 100644 --- a/test/samples/ts-object-patterns/expected.ts.map +++ b/test/samples/ts-object-patterns/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "type User = {\n\tfirstName: string;\n\tlastName: string;\n};\n\nfunction a({ firstName, lastName }: User) {\n\tconsole.log(firstName, lastName);\n}\n" ], - "mappings": "AAAA,KAAK,IAAI,GAAG,EACX,SAAS,EAAE,MAAM,AAAC,EAClB,QAAQ,EAAE,MAAM,AAAC,EACjB,CAAC;;AAEF,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC;CAC1C,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC,AACD" + "mappings": "AAAA,KAAK,IAAI,GAAG,EACX,SAAS,EAAE,MAAM,AAAC,EAClB,QAAQ,EAAE,MAAM,AAAC,CAClB,CAAC,CAAC;;AAEF,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAO,CAAL,EAAE,IAAI,EAAE,CAAC;CAC1C,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC,AACD" } \ No newline at end of file diff --git a/test/samples/ts-optional-parameter/expected.ts.map b/test/samples/ts-optional-parameter/expected.ts.map index 7d740aa4..04020781 100644 --- a/test/samples/ts-optional-parameter/expected.ts.map +++ b/test/samples/ts-optional-parameter/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "export const atproto = (o?: { A?: string }) => {};\nfunction f(a?: number) {}\nconst g = (a?: number) => a;\nclass C {\n\tm(a?: number) {}\n}\ninterface I {\n\tm(a?: number): void;\n}\ntype F = (a?: number) => void;\n" ], - "mappings": "AAAA,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;;AAClD,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;;AACzB,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC;;AAC5B,MAAM,CAAC,CAAC,CAAC;CACR,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AACjB,CAAC;;AACD,UAAU,CAAC,EAAC,CACX,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,IAAI,AAAC,CACpB,CAAA;;AACD,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC,AAC9B" + "mappings": "AAAA,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;;AAClD,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;;AACzB,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC;;AAC5B,MAAM,CAAC,CAAC,CAAC;CACR,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AACjB,CAAC;;AACD,UAAU,CAAC,CAAC,CAAA,CACX,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,IAAI,AAAC,CACpB,AAAD,CAAC;;AACD,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC,AAC9B" } \ No newline at end of file diff --git a/test/samples/ts-parameter-decorators/expected.ts.map b/test/samples/ts-parameter-decorators/expected.ts.map index a536e1de..e284dd40 100644 --- a/test/samples/ts-parameter-decorators/expected.ts.map +++ b/test/samples/ts-parameter-decorators/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "class Controller {\n\tconstructor(\n\t\t@Inject(CONFIG) private readonly config: Config,\n\t\t@Optional() @Inject(LOGGER) protected logger?: Logger,\n\t\t@Inject(CACHE) public cache = new Map(),\n\t\t@Self() service: Service\n\t) {}\n\n\tfind(@Param('id') id: string, @Query() { limit, offset }: Paging, @Body() [first]: Item[]) {}\n\n\tupdate(\n\t\t@Param('id') id: string,\n\t\t@Body(validation.pipe) body: Item,\n\t\t@(flags ?? defaults) force = false\n\t) {}\n}\n" ], - "mappings": "AAAA,MAAM,UAAU,CAAC,CAAC;CACjB,WAAW;EACV,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,iBAAiB,MAAM,EAAE,MAAM;EAC/C,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,MAAM,CAAC,EAAE,MAAM;EACrD,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAA,AAAO,KAAK,GAAG,GAAG,CAAC,GAAG,EAAE;EACvC,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO;GACvB,CAAC,CAAC;;CAEJ,IAAI;EAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,MAAM;EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM;EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE;GAAE,CAAC,CAAC;;CAE7F,MAAM;EACL,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,MAAM;EACvB,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI;EACjC,CAAE,CAAA,KAAK,IAAI,QAAQ,CAAA,AAAC,CAAC,KAAK,GAAG,KAAK;GACjC,CAAC,CAAC;AACL,CAAC,AACD" + "mappings": "AAAA,MAAM,UAAU,CAAC,CAAC;CACjB,WAAW;EACV,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,iBAAiB,MAAM,EAAE,MAAM;EAC/C,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,MAAM,CAAC,EAAE,MAAM;EACrD,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAA,AAAO,KAAK,GAAG,GAAG,CAAC,GAAG,EAAE;EACvC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO;GACvB,CAAC,CAAC;;CAEJ,IAAI;EAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,MAAM;EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAS,CAAP,EAAE,MAAM;EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,AAAQ,CAAP,EAAE,IAAI,CAAC,CAAC;GAAE,CAAC,CAAC;;CAE7F,MAAM;EACL,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,MAAM;EACvB,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI;EACjC,CAAE,CAAA,KAAK,IAAI,QAAQ,CAAA,AAAC,CAAC,KAAK,GAAG,KAAK;GACjC,CAAC,CAAC;AACL,CAAC,AACD" } \ No newline at end of file diff --git a/test/samples/ts-readonly-signatures/expected.ts.map b/test/samples/ts-readonly-signatures/expected.ts.map index a04ee8da..0ce74c70 100644 --- a/test/samples/ts-readonly-signatures/expected.ts.map +++ b/test/samples/ts-readonly-signatures/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "interface Example {\n\treadonly property?: string;\n\treadonly [key: string]: number;\n}\n" ], - "mappings": "AAAA,UAAU,OAAO,EAAC,CACjB,SAAS,QAAQ,CAAC,EAAE,MAAM,AAAC,EAC3B,UAAU,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,AAAC,CAC/B,CAAA,AACD" + "mappings": "AAAA,UAAU,OAAO,CAAC,CAAA,CACjB,SAAS,QAAQ,CAAC,EAAE,MAAM,AAAC,EAC3B,UAAU,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,AAAC,CAC/B,AAAD,CAAC,AACD" } \ No newline at end of file diff --git a/test/samples/ts-satisfies-expression/expected.ts.map b/test/samples/ts-satisfies-expression/expected.ts.map index 790c0f79..db6c6269 100644 --- a/test/samples/ts-satisfies-expression/expected.ts.map +++ b/test/samples/ts-satisfies-expression/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "type A = string;\nconst b: number = 42 satisfies A;\n\ntype C = {\n\tname: string;\n};\n\ntype D = {\n\tname: string;\n\tdescription: string;\n};\n\nconst e: D = {\n\tname: 'foo',\n\tdesciption: 'bar'\n};\n\nconst f = e satisfies D;\n\nconst g = (\n\tMath.random() > 0.5\n\t\t? { name: 'name1', description: 'desc1' }\n\t\t: { name: 'name2', description: 'desc2' }\n) satisfies D;\n" ], - "mappings": "AAAA,KAAK,CAAC,GAAG,MAAM,CAAC;;AAChB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,EAAE,WAAW,CAAC,CAAC;;AAEjC,KAAK,CAAC,GAAG,EACR,IAAI,EAAE,MAAM,AAAC,EACb,CAAC;AAEF,KAAK,CAAC,GAAG,EACR,IAAI,EAAE,MAAM,AAAC,EACb,WAAW,EAAE,MAAM,AAAC,EACpB,CAAC;;AAEF,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EACZ,IAAI,EAAE,KAAK,EACX,UAAU,EAAE,KAAK,EACjB,CAAC;AAEF,KAAK,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;;AAExB,KAAK,CAAC,CAAC,GAAG,AACT,CAAA,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG;GAChB,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE;GACvC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAA,WAC/B,CAAC,CAAC,AACd" + "mappings": "AAAA,KAAK,CAAC,GAAG,MAAM,CAAC;;AAChB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,EAAE,WAAW,CAAC,CAAC;;AAEjC,KAAK,CAAC,GAAG,EACR,IAAI,EAAE,MAAM,AAAC,CACd,CAAC,CAAC;AAEF,KAAK,CAAC,GAAG,EACR,IAAI,EAAE,MAAM,AAAC,EACb,WAAW,EAAE,MAAM,AAAC,CACrB,CAAC,CAAC;;AAEF,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EACZ,IAAI,EAAE,KAAK,EACX,UAAU,EAAE,KAAK,CAClB,CAAC,CAAC;AAEF,KAAK,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;;AAExB,KAAK,CAAC,CAAC,GAAG,AACT,CAAA,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG;GAChB,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;GACvC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAA,WAC/B,CAAC,CAAC,AACd" } \ No newline at end of file diff --git a/test/samples/ts-signatures/expected.ts.map b/test/samples/ts-signatures/expected.ts.map index 5e500f92..807c9209 100644 --- a/test/samples/ts-signatures/expected.ts.map +++ b/test/samples/ts-signatures/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "interface Constructable {\n\tnew (): any;\n\tnew (value: string): MyClass;\n\tnew (value: T): GenericClass;\n\t(name: string): string;\n}\n\ninterface Signatures {\n\t[Symbol.iterator](): number;\n\tx(): void;\n\t[k: string]: number;\n}\n\ntype Constructor = {\n\tnew (): object;\n\tnew (name: string, age: number): Person;\n};\n\ntype Computed = {\n\t[Symbol.iterator](): number;\n};\n" ], - "mappings": "AAAA,UAAU,aAAa,EAAC;CACvB,KAAM,EAAE,GAAG,AAAC;CACZ,IAAK,KAAK,EAAE,MAAM,CAAC,EAAE,OAAO,AAAC;CAC7B,GAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,AAAC;CACnC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,AAAC;AACvB,CAAA;;AAED,UAAU,UAAU,EAAC,CACpB,CAAC,MAAM,CAAC,QAAQ,GAAG,EAAE,MAAM,AAAC,EAC5B,CAAC,EAAE,EAAE,IAAI,AAAC,EACV,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,AAAC,CACpB,CAAA;;AAED,KAAK,WAAW,GAAG,EAClB,KAAM,EAAE,MAAM,AAAC,EACf,IAAK,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,AAAC,EACxC,CAAC;AAEF,KAAK,QAAQ,GAAG,EACf,CAAC,MAAM,CAAC,QAAQ,GAAG,EAAE,MAAM,AAAC,EAC5B,CAAC,AACF" + "mappings": "AAAA,UAAU,aAAa,CAAC,CAAA;CACvB,KAAM,EAAE,GAAG,AAAC;CACZ,IAAK,KAAK,EAAE,MAAM,CAAC,EAAE,OAAO,AAAC;CAC7B,GAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,AAAC;CACnC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,AAAC;AACvB,AAAD,CAAC;;AAED,UAAU,UAAU,CAAC,CAAA,CACpB,CAAC,MAAM,CAAC,QAAQ,GAAG,EAAE,MAAM,AAAC,EAC5B,CAAC,EAAE,EAAE,IAAI,AAAC,EACV,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,AAAC,CACpB,AAAD,CAAC;;AAED,KAAK,WAAW,GAAG,EAClB,KAAM,EAAE,MAAM,AAAC,EACf,IAAK,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,AAAC,CACzC,CAAC,CAAC;AAEF,KAAK,QAAQ,GAAG,EACf,CAAC,MAAM,CAAC,QAAQ,GAAG,EAAE,MAAM,AAAC,CAC7B,CAAC,CAAC,AACF" } \ No newline at end of file diff --git a/test/samples/ts-simple-identifier-types/expected.ts.map b/test/samples/ts-simple-identifier-types/expected.ts.map index 6409789f..5a0d11d4 100644 --- a/test/samples/ts-simple-identifier-types/expected.ts.map +++ b/test/samples/ts-simple-identifier-types/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "const n: number = 1;\nconst s: string = 'foo';\nconst b: boolean = true;\nconst a: any = {};\nconst na: number[] = [];\nconst sa: string[] = [];\nconst ba: boolean[] = [];\nconst aa: any[] = [];\n" ], - "mappings": "AAAA,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;AACpB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;AACxB,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;AACxB,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC;AAClB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACxB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACxB,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AACzB,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,AACrB" + "mappings": "AAAA,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;AACpB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;AACxB,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;AACxB,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;AAClB,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACxB,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACxB,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACzB,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,AACrB" } \ No newline at end of file diff --git a/test/samples/ts-tagged-template/expected.ts.map b/test/samples/ts-tagged-template/expected.ts.map index 0acfc82a..5f4bb7d2 100644 --- a/test/samples/ts-tagged-template/expected.ts.map +++ b/test/samples/ts-tagged-template/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "sql`SELECT * FROM table`;\nconst res = tag`hello ${world}`;\n" ], - "mappings": "AAAA,GAAG,CAAC,MAAM,EAAE,CAAC,qBAAqB,CAAC;;AACnC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,AACtC" + "mappings": "AAAA,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC;;AACnC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,AACtC" } \ No newline at end of file diff --git a/test/samples/ts-type-level-syntax/expected.ts.map b/test/samples/ts-type-level-syntax/expected.ts.map index e83038d8..71ec884d 100644 --- a/test/samples/ts-type-level-syntax/expected.ts.map +++ b/test/samples/ts-type-level-syntax/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "type Tuple = [required: string, optional?: number, ...rest: boolean[]];\n\ninterface Accessors {\n\tget value(): string;\n\tset value(next: string);\n\tmethod(): void;\n}\n\ntype Instantiated = typeof identity;\n" ], - "mappings": "AAAA,KAAK,KAAK,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;;AAEvE,UAAU,SAAS,EAAC,CACnB,IAAI,KAAK,EAAE,EAAE,MAAM,AAAC,EACpB,IAAI,KAAK,CAAC,IAAI,EAAE,MAAM,CAAE,EACxB,MAAM,EAAE,EAAE,IAAI,AAAC,CACf,CAAA;;AAED,KAAK,YAAY,GAAG,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,AAC5C" + "mappings": "AAAA,KAAK,KAAK,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;;AAEvE,UAAU,SAAS,CAAC,CAAA,CACnB,IAAI,KAAK,EAAE,EAAE,MAAM,AAAC,EACpB,IAAI,KAAK,CAAC,IAAI,EAAE,MAAM,CAAE,EACxB,MAAM,EAAE,EAAE,IAAI,AAAC,CACf,AAAD,CAAC;;AAED,KAAK,YAAY,GAAG,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,AAC5C" } \ No newline at end of file diff --git a/test/samples/ts-types/expected.ts.map b/test/samples/ts-types/expected.ts.map index 068a862b..16418f05 100644 --- a/test/samples/ts-types/expected.ts.map +++ b/test/samples/ts-types/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "type A = [x: number, y: string];\ntype B = { a: string; b: number };\n\ntype C = 'foo' | 'bar';\ntype D = C | A | B | 'foobar';\n\ntype E = A & B;\ntype F = C & 'foobar';\n\n// TODO: commented because acorn doesn't support intrinsic but oxc does\n// type G = { [a in C]: string };\n\ntype H = this;\ntype I = `Hello, ${keyof C}`;\ntype J = () => this is string;\ntype P = (x: unknown) => asserts x is string;\n\nfunction assertsString(x): asserts x is string {}\nfunction assertsValue(x): asserts x {}\nfunction assertsThis(x): asserts this is Foo {}\nfunction isString(x): x is string {}\n\ntype Bird = { legs: 2 };\ntype Dog = { legs: 4 };\ntype Wolf = { legs: 4 };\ntype Animals = Bird | Dog | Wolf;\ntype HasFourLegs = Animal extends { legs: 4 } ? Animal : never;\ntype FourLegs = HasFourLegs;\n\ntype T = [('a' | 'b')?];\n\ntype CT = new (tpl: TemplateStringsArray, ...args: Array) => (replacements: B) => A;\n\ntype X = [...number[]];\ntype TupleWithRest = [number, ...(1 extends 2 ? string[] : number[])];\n\n// TODO: commented because acorn doesn't support intrinsic but oxc does\n// type Uppercase = intrinsic;\n" ], - "mappings": "AAAA,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAChC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,AAAC,EAAC,CAAC,EAAE,MAAM,EAAE,CAAC;AAElC,KAAK,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC;AACvB,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;AAE9B,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACf,KAAK,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;;;;AAKtB,KAAK,CAAC,GAAG,IAAI,CAAC;;AACd,KAAK,CAAC,GAAG,UAAU,MAAM,CAAC,EAAE,CAAC;AAC7B,KAAK,CAAC,GAAG,MAAM,IAAI,IAAI,MAAM,CAAC;AAC9B,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC,IAAI,MAAM,CAAC;;AAE7C,SAAS,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC;AACjD,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC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AC,CAAA,GAAG,GAAG,GAAG,CAAA,AAAC,CAAC,CAAC,CAAC;AAExB,KAAK,EAAE,GAAG,KAAK,GAAG,EAAE,oBAAoB,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC;AAE7F,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACvB,KAAK,aAAa,GAAG,CAAC,MAAM,EAAE,GAAG,AAAC,CAAA,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAA,AAAC,CAAC,CAAC;;;gDAItE" } \ No newline at end of file diff --git a/test/samples/ts-utility-types/expected.ts.map b/test/samples/ts-utility-types/expected.ts.map index bb2244fb..4648d01a 100644 --- a/test/samples/ts-utility-types/expected.ts.map +++ b/test/samples/ts-utility-types/expected.ts.map @@ -7,5 +7,5 @@ "sourcesContent": [ "type A = Awaited>;\n\ntype Todo = {\n\ttitle: string;\n\tdescription: string;\n};\n\nfunction updateTodo(todo: Todo, fieldsToUpdate: Partial) {\n\treturn { ...todo, ...fieldsToUpdate };\n}\n\nconst todo2: Readonly = {\n\ttitle: 'Delete inactive users',\n\tdescription: 'foo'\n};\n\ntype CatInfo = {\n\tage: number;\n\tbreed: string;\n};\n\nconst cats: Record = {\n\tmiffy: { age: 10, breed: 'Persian' },\n\tboris: { age: 5, breed: 'Maine Coon' },\n\tmordred: { age: 16, breed: 'British Shorthair' }\n};\n" ], - "mappings": "AAAA,KAAK,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAElC,KAAK,IAAI,GAAG,EACX,KAAK,EAAE,MAAM,AAAC,EACd,WAAW,EAAE,MAAM,AAAC,EACpB,CAAC;;AAEF,SAAS,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;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EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;CACrC,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;CACpC,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;CACtC,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC;AACjD,CAAC,CAAC,AACF" } \ No newline at end of file diff --git a/test/samples/tsx-type-parameters/expected.tsx.map b/test/samples/tsx-type-parameters/expected.tsx.map index a4e1ed33..718f14b7 100644 --- a/test/samples/tsx-type-parameters/expected.tsx.map +++ b/test/samples/tsx-type-parameters/expected.tsx.map @@ -7,5 +7,5 @@ "sourcesContent": [ "const identity = (value: T): T => value;\nconst pair = (a: T, b: U): [T, U] => [a, b];\nconst constant = (value: T) => value;\nconst nested =\n\t(value: T) =>\n\t(other: U) => [value, other];\nconst apply = (fn: (value: U) => U, value: T) => fn(value);\n\nfunction declared(value: T): T {\n\treturn value;\n}\n\nclass Box {}\ninterface Result {\n\tvalue: T;\n}\ntype Identity = (value: T) => T;\n\nconst element =
{identity('x')}
;\nconst component = value={identity('x')} />;\n" ], - "mappings": "AAAA,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC;AAC5C,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClD,KAAK,CAAC,QAAQ,GAAG,CAAC,MAAA,CAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,KAAK,CAAC;AAC/C,KAAK,CAAC,MAAM,GACX,CAAC,CAAC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C,QAAQ,GAAG,CAAC,MAAA,CAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,KAAK,CAAC;AAC/C,KAAK,CAAC,MAAM,GACX,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KACb,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAClC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAC,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;;AAElE,SAAS,QAAQ,CAAC,CAAC,EAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAClC,MAAM,CAAC,KAAK,CAAC;AACd,CAAC;;AAED,MAAM,GAAG,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;;AACf,UAAU,MAAM,CAAC,CAAC,EAAC,CAAC,CAAA,CACnB,KAAK,EAAE,CAAC,AAAC,CACT,AAAD,CAAC;;AACD,KAAK,QAAQ,GAAG,CAAC,CAAC,EAAC,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;;AAEnC,KAAK,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3C,KAAK,CAAC,SAAS,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,AAC9D" } \ No newline at end of file diff --git a/test/samples/var-declaration/expected.js.map b/test/samples/var-declaration/expected.js.map index 07a6592d..e8b4d298 100644 --- a/test/samples/var-declaration/expected.js.map +++ b/test/samples/var-declaration/expected.js.map @@ -7,5 +7,5 @@ "sourcesContent": [ "const obj = {\n\ta,\n\tb,\n\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,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;CACD,CAAC;AACF,CAAC,CAAC;;AAEF,KAAK,CAAC,IAAI,GAAG;EACX,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;CACF,CAAC;CACD,CAAC,GAAG,CAAC;CACL,CAAC,GAAG,CAAC,CAAC" } \ No newline at end of file diff --git a/test/sourcemap-keywords.test.js b/test/sourcemap-keywords.test.js index 8fe28f87..eb1a8971 100644 --- a/test/sourcemap-keywords.test.js +++ b/test/sourcemap-keywords.test.js @@ -103,6 +103,17 @@ test.each([ expect(segment.slice(2)).toEqual([gen_line, gen_col]); }); +/** + * @param {string} code + * @param {number} index + * @param {[number, number, number, number][][]} mappings + */ +function mappingsAtIndex(code, index, mappings) { + const { gen_line, gen_col } = generatedLineColumn(code, index); + const line = mappings[gen_line] ?? []; + return line.filter((segment) => segment[0] === gen_col); +} + /** * @param {string} code * @param {string} needle @@ -128,3 +139,396 @@ test.each([ expect(sourcePositionsAt(code, needle, mappings)).toContainEqual([gen_line, gen_col]); } ); + +/** + * @param {string} code + * @param {string} needle + * @param {[number, number, number, number][][]} mappings + */ +function mappingsAtSubstring(code, needle, mappings) { + const index = code.indexOf(needle); + expect(index >= 0, `needle not in output: ${JSON.stringify(needle)}`).toBe(true); + return mappingsAtIndex(code, index, mappings); +} + +/** + * Prints `source` with the parser's tokens passed to the printer (or `opts.tokens`) + * @param {string} source + * @param {{ tokens?: boolean | any[], sourceType?: 'module' | 'script' }} [opts] + */ +function mappedWithTokens(source, opts = {}) { + /** @type {any[]} */ + const tokens = []; + const { ast, comments } = acornParse(source, { + sourceType: opts.sourceType ?? 'module', + jsxMode: false, + fileExtension: 'ts', + tokens + }); + const { code, map } = print( + ast, + ts({ comments, tokens: opts.tokens === true ? tokens : opts.tokens || undefined }), + { sourceMapSource: 'input.ts', sourceMapContent: source, sourceMapEncodeMappings: false } + ); + const mappings = /** @type {[number, number, number, number][][]} */ ( + /** @type {unknown} */ (map.mappings) + ); + return { code, mappings, tokens }; +} + +/** + * Every `delimiters` character in the output maps to the matching token in the + * source, and the output is the same as without tokens. + * @param {string} source + * @param {string[]} delimiters + * @param {{ sourceType?: 'module' | 'script' }} [opts] + */ +function expectExactDelimiterMappings(source, delimiters, opts = {}) { + const without = mappedWithTokens(source, { sourceType: opts.sourceType }); + const { code, mappings, tokens } = mappedWithTokens(source, { + tokens: true, + sourceType: opts.sourceType + }); + expect(code).toBe(without.code); + + // a backtracking parser can emit a token twice + const seen = new Set(); + /** @type {{ value: string, start: { line: number, column: number } }[]} */ + const source_delimiters = []; + for (const token of tokens) { + const value = token.type.label; + if (!token.loc || !delimiters.includes(value === '${' ? '{' : value)) continue; + const key = `${value}:${token.loc.start.line}:${token.loc.start.column}`; + if (seen.has(key)) continue; + seen.add(key); + source_delimiters.push({ value, start: token.loc.start }); + } + + /** @type {{ value: string, index: number }[]} */ + const generated_delimiters = []; + for (let i = 0; i < code.length; i += 1) { + if (code[i] === '$' && code[i + 1] === '{' && delimiters.includes('{')) { + generated_delimiters.push({ value: '${', index: i }); + i += 1; + } else if (delimiters.includes(code[i])) { + generated_delimiters.push({ value: code[i], index: i }); + } + } + + expect(generated_delimiters.map((d) => d.value)).toEqual(source_delimiters.map((d) => d.value)); + for (let i = 0; i < generated_delimiters.length; i += 1) { + const { start } = source_delimiters[i]; + expect( + mappingsAtIndex(code, generated_delimiters[i].index, mappings).map((s) => s.slice(2)), + `${generated_delimiters[i].value} at ${start.line}:${start.column}` + ).toContainEqual([start.line - 1, start.column]); + } +} + +test.each([ + ['object property', `const object = { [\nkey\n]: value };`], + ['object method', `const object = { async *[\nmethod\n]() {} };`], + ['object getter', `const object = { get [\nkey\n]() { return 1; } };`], + ['object setter', `const object = { set [\nkey\n](value) {} };`], + ['class method', `class Example { [\nmethod\n]() {} }`], + ['class field', `class Example { [\nfield\n] = 1; }`], + ['type property signature', `type Example = { [\nkey\n]: string }`], + ['type method signature', `type Example = { [\nmethod\n](): void }`], + ['comments inside the brackets', `const object = { [ /* before */\nkey\n/* after */ ]: value };`], + ['array expression', `const values = [ /* before */\nvalue\n/* after */ ];`], + ['array pattern', `const [ /* before */\nvalue\n/* after */ ] = values;`], + ['computed member access', `const value = object[ /* before */\nkey\n/* after */ ];`], + ['array type', `type Values = Item /* before */ [ /* after */ ];`], + ['index signature', `type Dictionary = { [ /* before */ key: string /* after */ ]: number };`], + ['readonly index signature', `type Dictionary = { readonly [ key: string ]: number };`], + [ + 'mapped type', + `type Selected = { [ /* before */ K in Keys as Rename /* after */ ]: string };` + ], + ['tuple type', `type Pair = [ /* before */ First, Second /* after */ ];`], + ['indexed access type', `type Value = Object[ /* before */ Key /* after */ ];`] +])('tokens map square brackets for %s', (_name, source) => { + expectExactDelimiterMappings(source, ['[', ']']); +}); + +test.each([ + ['call', `const result = fn /* before */ ( /* inside */ value /* after */ );`, {}], + [ + 'new expression', + `const result = new Thing /* before */ ( /* inside */ value /* after */ );`, + {} + ], + [ + 'function declaration', + `function example /* before */ ( /* inside */ value /* after */ ) {}`, + {} + ], + ['async arrow function', `const fn = async /* before */ ( value ) => value;`, {}], + ['arrow function', `const callback = ( /* before */ value /* after */ ) => value;`, {}], + ['empty arrow function', `const callback = /* before */ () => value;`, {}], + ['class method', `class Example { method /* before */ ( value /* after */ ) {} }`, {}], + ['object method', `const object = { method /* before */ ( value /* after */ ) {} };`, {}], + ['nested method delimiters', `class Example { [getKey()] /* before */ (value = make()) {} }`, {}], + ['nested parameter delimiters', `function example(value = make(1)) {}`, {}], + [ + 'trailing comma on its own line', + `function example(\n\tfirst: number,\n\tsecond: string,\n) {}`, + {} + ], + ['call signature', `type Example = { ( /* before */ value: string /* after */ ): void };`, {}], + [ + 'construct signature', + `type Example = { new ( /* before */ value: string /* after */ ): object };`, + {} + ], + ['function type', `type Example = ( /* before */ value: string /* after */ ) => void;`, {}], + [ + 'constructor type', + `type Example = new ( /* before */ value: string /* after */ ) => object;`, + {} + ], + [ + 'method signature', + `type Example = { method( /* before */ value: string /* after */ ): void };`, + {} + ], + [ + 'declare function', + `declare function example( /* before */ value: string /* after */ ): void;`, + {} + ], + ['for statement', `for /* before */ (let i = 0; i < 1; i += 1) {}`, {}], + ['for-of statement', `for /* before */ (const value of values) {}`, {}], + ['if statement', `if /* before */ (condition /* after */) {}`, {}], + ['while statement', `while /* before */ (condition /* after */) {}`, {}], + ['do-while statement', `do {} while /* before */ (condition /* after */);`, {}], + ['with statement', `with /* before */ (object /* after */) {}`, { sourceType: 'script' }], + ['switch statement', `switch /* before */ (value /* after */) { default: break; }`, {}], + ['catch clause', `try {} catch /* before */ (error /* after */) {}`, {}], + ['import expression', `const module = import( /* before */ 'module' /* after */ );`, {}], + ['external module reference', `import Alias = require( /* before */ 'module' /* after */ );`, {}], + ['import type', `type Value = import( /* before */ 'module' /* after */ ).Value;`, {}] +])('tokens map parentheses for %s', (_name, source, opts) => { + expectExactDelimiterMappings(source, ['(', ')'], { + sourceType: 'sourceType' in opts && opts.sourceType === 'script' ? 'script' : undefined + }); +}); + +test.each([ + ['named import', `import { /* before */ value /* after */ } from 'module';`], + ['empty type-only import', `import type /* before */ { /* inside */ } from 'module';`], + ['named export', `const value = 1;\nexport { /* before */ value /* after */ };`], + ['empty named export', `export { /* inside */ };`], + ['import attributes', `import value from 'module' with { type: 'json' };`], + ['static block', `class Example { static /* before */ { value; } }`], + ['switch body', `switch (value) /* before */ { default: break; }`], + ['enum body', `enum Example /* before */ { Value }`], + ['interface body', `interface Example /* before */ { value: string }`], + ['namespace body', `namespace Example /* before */ { export const value = 1; }`], + ['template interpolation', 'const result = `before ${ /* before */ value /* after */ } after`;'], + ['template-literal type interpolation', 'type Result = `before ${Value} after`;'] +])('tokens map curly braces for %s', (_name, source) => { + expectExactDelimiterMappings(source, ['{', '}']); +}); + +test('control-flow parentheses are the outer authored ones', () => { + const source = `if /* before */ ((condition)) {}`; + const { code, mappings, tokens } = mappedWithTokens(source, { tokens: true }); + const opens = tokens.filter((token) => token.type.label === '('); + const closes = tokens.filter((token) => token.type.label === ')'); + + expect(mappingsAtSubstring(code, '(', mappings).map((s) => s.slice(2))).toContainEqual([ + opens[0].loc.start.line - 1, + opens[0].loc.start.column + ]); + expect(mappingsAtSubstring(code, ')', mappings).map((s) => s.slice(2))).toContainEqual([ + closes[closes.length - 1].loc.start.line - 1, + closes[closes.length - 1].loc.start.column + ]); +}); + +test('delimiters inside a node are left unmapped without tokens', () => { + const source = `const object = { [ key ]: value };`; + const { code, mappings } = mappedWithTokens(source); + expect(mappingsAtSubstring(code, ']', mappings).map((s) => s.slice(2))).not.toContainEqual([ + 0, + source.indexOf(']') + ]); +}); + +test('closing delimiters at a node end are mapped without tokens', () => { + const source = `const value = object[key];`; + const { code, mappings } = mappedWithTokens(source); + expect(mappingsAtSubstring(code, ']', mappings).map((s) => s.slice(2))).toContainEqual([ + 0, + source.indexOf(']') + ]); +}); + +test('tokens without locations leave mappings unchanged', () => { + const source = `const object = { [key]: fn(value) };`; + const { mappings, tokens } = mappedWithTokens(source); + const bare = tokens.map(({ type, value }) => ({ type, value })); + expect(mappedWithTokens(source, { tokens: bare }).mappings).toEqual(mappings); + expect(mappedWithTokens(source, { tokens: [] }).mappings).toEqual(mappings); +}); + +test('tokens out of source order still locate delimiters', () => { + // acorn-typescript backtracks and re-emits tokens, so its stream is not monotone + const source = `const object = { [ key ]: fn( value ) };`; + const { mappings, tokens } = mappedWithTokens(source, { tokens: true }); + const reversed = [...tokens].reverse(); + expect(mappedWithTokens(source, { tokens: reversed }).mappings).toEqual(mappings); +}); + +test('ESLint-style tokens locate delimiters and keywords', () => { + const source = `const object = { [ key ]: fn( value ) };\nasync /* c */ function f() {}`; + const { mappings, tokens } = mappedWithTokens(source, { tokens: true }); + const eslint_style = tokens.map((token) => ({ + type: token.type.keyword + ? 'Keyword' + : token.type.label === 'name' + ? 'Identifier' + : 'Punctuator', + value: token.type.label === 'name' || token.type.keyword ? token.value : token.type.label, + loc: token.loc + })); + expect(mappedWithTokens(source, { tokens: eslint_style }).mappings).toEqual(mappings); +}); + +/** + * Every `words` keyword in the output maps to the matching token in the source, + * and the output is the same as without tokens. + * @param {string} source + * @param {string[]} words + */ +function expectExactKeywordMappings(source, words) { + const without = mappedWithTokens(source); + const { code, mappings, tokens } = mappedWithTokens(source, { tokens: true }); + expect(code).toBe(without.code); + + const seen = new Set(); + /** @type {{ value: string, start: { line: number, column: number } }[]} */ + const source_words = []; + for (const token of tokens) { + const value = token.type.label === 'name' ? token.value : token.type.label; + if (!token.loc || !words.includes(value)) continue; + const key = `${token.loc.start.line}:${token.loc.start.column}`; + if (seen.has(key)) continue; + seen.add(key); + source_words.push({ value, start: token.loc.start }); + } + + const pattern = new RegExp(`\\b(${words.join('|')})\\b`, 'g'); + const generated_words = [...code.matchAll(pattern)].map((m) => ({ + value: m[0], + index: /** @type {number} */ (m.index) + })); + + expect(generated_words.map((w) => w.value)).toEqual(source_words.map((w) => w.value)); + for (let i = 0; i < generated_words.length; i += 1) { + const { start } = source_words[i]; + expect( + mappingsAtIndex(code, generated_words[i].index, mappings).map((s) => s.slice(2)), + `${generated_words[i].value} at ${start.line}:${start.column}` + ).toContainEqual([start.line - 1, start.column]); + } +} + +test.each([ + ['async function', `async /* c */ function f() {}`, ['async', 'function']], + ['async generator', `async /* c */ function* f() {}`, ['async', 'function']], + ['function expression', `const f = async /* c */ function () {};`, ['async', 'function']], + ['async arrow', `const f = async /* c */ ( x ) => x;`, ['async']], + ['declare function', `declare /* c */ function f(): void;`, ['declare', 'function']], + [ + 'class modifiers', + `declare /* c */ abstract /* c */ class K {}`, + ['declare', 'abstract', 'class'] + ], + ['decorated class', `@dec /* c */ class K {}`, ['class']], + ['export default class', `export /* c */ default /* c */ class {}`, ['default', 'class']], + [ + 'class heritage', + `class K extends /* c */ B implements /* c */ I {}`, + ['extends', 'implements'] + ], + [ + 'member modifiers', + `class K extends B {\n\tstatic /* c */ async /* c */ *m() {}\n\tprivate /* c */ readonly p = 1;\n\tget /* c */ g() { return 1; }\n\t@dec /* c */ override /* c */ n() {}\n}`, + ['static', 'async', 'private', 'readonly', 'get', 'override'] + ], + [ + 'object accessors', + `const o = { get /* c */ p() { return 1; }, async /* c */ m() {} };`, + ['get', 'async'] + ], + ['else', `if (a) {} /* c */ else /* c */ {}`, ['else']], + ['finally', `try {} finally /* c */ {}`, ['finally']], + ['finally after catch', `try {} catch {} /* c */ finally {}`, ['finally']], + ['do-while', `do {} /* c */ while /* c */ (a);`, ['while']], + [ + 'for await of', + `async function f() { for /* c */ await /* c */ (const x of /* c */ y) {} }`, + ['async', 'function', 'await', 'of'] + ], + ['for in', `for (const k /* c */ in o) {}`, ['in']], + ['import type', `import /* c */ type { T } from 'm';`, ['type']], + ['empty import type', `import /* c */ type {} from 'm';`, ['type']], + ['import type specifier', `import { type /* c */ T, a as /* c */ b } from 'm';`, ['type', 'as']], + ['export type', `type T = 1;\nexport /* c */ type { T };`, ['type']], + ['export star as', `export * as /* c */ ns from 'm';`, ['as']], + ['export specifier as', `const b = 1;\nexport { b as /* c */ c };`, ['as']], + ['enum', `declare /* c */ const /* c */ enum E {}`, ['declare', 'const', 'enum']], + ['namespace', `declare /* c */ namespace N {}`, ['declare', 'namespace']], + ['module', `declare /* c */ module 'm' {}`, ['declare', 'module']], + [ + 'interface', + `declare /* c */ interface I extends /* c */ J {}`, + ['declare', 'interface', 'extends'] + ], + ['type alias', `declare /* c */ type T = string;`, ['declare', 'type']], + [ + 'mapped type', + `type M = { -readonly /* c */ [K in /* c */ keyof T as /* c */ R]: T[K] };`, + ['readonly', 'in', 'as'] + ], + ['as expression', `const v = x /* c */ as /* c */ T;`, ['as']], + ['satisfies expression', `const v = x /* c */ satisfies /* c */ T;`, ['satisfies']], + [ + 'parameter properties', + `class P { constructor(private /* c */ readonly x: number) {} }`, + ['private', 'readonly'] + ], + ['constructor type', `type F = abstract /* c */ new () => object;`, ['abstract', 'new']] +])('tokens map keywords after a node start for %s', (_name, source, words) => { + expectExactKeywordMappings(source, words); +}); + +test.each([ + ['decorator before export', `@dec export class K {}`], + ['decorator after export', `export @dec class K {}`], + ['decorator before export default', `@dec export default class {}`], + ['decorator after export default', `export default @dec class {}`] +])('`export` of a decorated class maps to its source position: %s', (_name, statement) => { + // a leading statement keeps the Program's own start mapping off the tested line + const source = `let a;\n${statement}`; + const { code, mappings } = mapped(source); + const segment = mappingAtSubstring(code, 'export', mappings); + expect(segment.slice(2)).toEqual([1, statement.indexOf('export')]); + // the printed decorator maps to itself, not to `export` + expect(sourcePositionsAt(code, '@dec', mappings)).toEqual([[1, statement.indexOf('@dec')]]); +}); + +test.each([ + ['decorator before export', `@dec /* c */ export /* c */ class K {}`, ['class']], + ['decorator after export', `export /* c */ @dec /* c */ class K {}`, ['class']], + [ + 'decorator before export default', + `@dec export /* c */ default /* c */ class {}`, + ['default', 'class'] + ], + ['decorated member', `class K { @dec /* c */ static /* c */ m() {} }`, ['static']] +])('tokens map the keywords of a decorated declaration: %s', (_name, source, words) => { + expectExactKeywordMappings(source, words); +});