@ 261027.7 · fetching
current
exports[`should handle short-circuit assignments (&&=, ||=, ??=) 1`] = `
"const a = {};\\na.foo &&= \`\${a.foo}1\`;\\nconsole.log(a.foo);\\nconst b = {};\\nb.foo ||= \`\${b.foo}1\`;\\nconsole.log(b.foo);\\nconst c = {};\\nc.foo ??= \`\${c.foo}1\`;\\nconsole.log(c.foo);\\n"
`;

exports[`should have proper error code 1`] = `
{
  "code": "UnsupportedSyntax",
  "message": "\`module\` keyword is not supported. Use \`namespace\` instead.",
  "snippet": "module F { export type x = number }\\n^^^^^^^^\\n",
  "filename": "<anon>",
  "startLine": 1,
  "startColumn": 0,
  "endLine": 1,
  "endColumn": 8
}
`;

exports[`should have proper error code 2`] = `
{
  "code": "InvalidSyntax",
  "message": "'const' declarations must be initialized",
  "snippet": "const foo;\\n      ^^^\\n",
  "filename": "<anon>",
  "startLine": 1,
  "startColumn": 6,
  "endLine": 1,
  "endColumn": 9
}
`;

exports[`should not polyfill using Symbol.Dispose 1`] = `
"using r = 0;\\n"
`;

exports[`should not polyfill using Symbol.asyncDispose 1`] = `
"await using r = 0;\\n"
`;

exports[`should not transform TypeScript class decorators with multiple decorators 1`] = `
"@sealed\\n@log\\nclass BugReport {\\n    type = \\"report\\";\\n    title;\\n    constructor(t){\\n        this.title = t;\\n    }\\n}\\nfunction sealed(constructor) {\\n    Object.seal(constructor);\\n    Object.seal(constructor.prototype);\\n}\\nfunction log(constructor) {\\n    console.log(\\"Creating instance of\\", constructor.name);\\n}\\noutput = new BugReport(\\"Test\\");\\n"
`;

exports[`should perform transformation with error 1`] = `
"var Foo = /*#__PURE__*/ function(Foo) {\\n    Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n    Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n    return Foo;\\n}(Foo || {});\\noutput = 7;\\nthrow new Error(\\"foo\\");\\n"
`;

exports[`should perform transformation with error 2`] = `
"{\\"version\\":3,\\"sources\\":[\\"foo.ts\\"],\\"names\\":[],\\"mappings\\":\\"AACI,IAAA,AAAK,6BAAA;qBACK;qBACA;WAFL;EAAA;AAIL,SAHU;AAIV,MAAM,IAAI,MAAM\\"}"
`;

exports[`should perform transformation with source maps 1`] = `
"var Foo = /*#__PURE__*/ function(Foo) {\\n    Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n    Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n    return Foo;\\n}(Foo || {});\\noutput = 7;\\n"
`;

exports[`should perform transformation with source maps 2`] = `
"{\\"version\\":3,\\"sources\\":[\\"foo.ts\\"],\\"names\\":[],\\"mappings\\":\\"AACI,IAAA,AAAK,6BAAA;qBACK;qBACA;WAFL;EAAA;AAKL,SAJU\\"}"
`;

exports[`should perform transformation with source maps no filename 1`] = `
"var Foo = /*#__PURE__*/ function(Foo) {\\n    Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n    Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n    return Foo;\\n}(Foo || {});\\noutput = 7;\\n"
`;

exports[`should perform transformation with source maps no filename 2`] = `
"{\\"version\\":3,\\"sources\\":[\\"<anon>\\"],\\"sourcesContent\\":[\\"\\\\n    enum Foo {\\\\n        Bar = 7,\\\\n        Baz = 2,\\\\n    }\\\\n    output = Foo.Bar\\"],\\"names\\":[],\\"mappings\\":\\"AACI,IAAA,AAAK,6BAAA;qBACK;qBACA;WAFL;EAAA;AAIL,SAHU\\",\\"ignoreList\\":[0]}"
`;

exports[`should perform transformation with source maps with uncommon chars 1`] = `
"var Foo = /*#__PURE__*/ function(Foo) {\\n    Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n    Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n    return Foo;\\n}(Foo || {});\\noutput = 7;\\n"
`;

exports[`should perform transformation with source maps with uncommon chars 2`] = `
"{\\"version\\":3,\\"sources\\":[\\"dir%20with $unusual\\\\\\"chars?'åß∂ƒ©∆¬…\`.cts\\"],\\"names\\":[],\\"mappings\\":\\"AACI,IAAA,AAAK,6BAAA;qBACK;qBACA;WAFL;EAAA;AAKL,SAJU\\"}"
`;

exports[`should perform transformation without source maps 1`] = `
"var Foo = /*#__PURE__*/ function(Foo) {\\n    Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n    Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n    return Foo;\\n}(Foo || {});\\noutput = 7;\\n"
`;

exports[`should perform transformation without source maps and filename 1`] = `
"var Foo = /*#__PURE__*/ function(Foo) {\\n    Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n    Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n    return Foo;\\n}(Foo || {});\\noutput = 7;\\n"
`;

exports[`should transform TypeScript class fields 1`] = `
"class Counter {\\n    count = 0;\\n    increment() {\\n        this.count++;\\n    }\\n}\\nconst counter = new Counter();\\ncounter.increment();\\noutput = counter.count;\\n"
`;

exports[`should transform TypeScript namespaces with additional functionality 1`] = `
"(function(Validation) {\\n    const lettersRegexp = /^[A-Za-z]+$/;\\n    class LettersOnlyValidator {\\n        isAcceptable(s) {\\n            return lettersRegexp.test(s);\\n        }\\n        static createValidator() {\\n            return new LettersOnlyValidator();\\n        }\\n    }\\n    Validation.LettersOnlyValidator = LettersOnlyValidator;\\n})(Validation || (Validation = {}));\\nconst validator = Validation.LettersOnlyValidator.createValidator();\\nconst isValid = validator.isAcceptable(\\"test\\");\\noutput = {\\n    validator,\\n    isValid\\n};\\nvar Validation;\\n"
`;

exports[`should transform TypeScript private class fields 1`] = `
"class Counter {\\n    #count = 0;\\n    increment() {\\n        this.#count++;\\n    }\\n    getCount() {\\n        return this.#count;\\n    }\\n}\\nconst counter = new Counter();\\ncounter.increment();\\noutput = counter.getCount();\\n"
`;

exports[`should transform TypeScript type annotations and type guards 1`] = `
"function isString(value) {\\n    return typeof value === 'string';\\n}\\nconst check = isString(\\"hello\\");\\noutput = check;\\n"
`;

exports[`test native class properties 1`] = `
"class Foo {\\n    y;\\n    x = console.log(1);\\n    constructor(y = console.log(2)){\\n        this.y = y;\\n        console.log(3);\\n    }\\n}\\n"
`;

exports[`test noEmptyExport 1`] = `
"const fs = require(\\"fs\\");\\n"
`;