/
ts-compiler.spec.ts.snap
107 lines (94 loc) · 3.66 KB
/
ts-compiler.spec.ts.snap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`TsCompiler isolatedModule false allowJs option should compile js file for allowJs true with outDir 1`] = `
"\\"use strict\\";
Object.defineProperty(exports, \\"__esModule\\", { value: true });
exports.default = 42;
//# "
`;
exports[`TsCompiler isolatedModule false allowJs option should compile js file for allowJs true without outDir 1`] = `
"\\"use strict\\";
Object.defineProperty(exports, \\"__esModule\\", { value: true });
exports.default = 42;
//# "
`;
exports[`TsCompiler isolatedModule false diagnostics should throw error when cannot compile 1`] = `
"Unable to require \`.d.ts\` file for file: test-cannot-compile.d.ts.
This is usually the result of a faulty configuration or import. Make sure there is a \`.js\`, \`.json\` or another executable extension available alongside \`test-cannot-compile.d.ts\`."
`;
exports[`TsCompiler isolatedModule false jsx option should compile tsx file for jsx preserve 1`] = `
"\\"use strict\\";
const App = () => {
return <>Test</>;
};
//# "
`;
exports[`TsCompiler isolatedModule false jsx option should compile tsx file for other jsx options 1`] = `
"\\"use strict\\";
const App = () => {
return React.createElement(React.Fragment, null, \\"Test\\");
};
//# "
`;
exports[`TsCompiler isolatedModule false should compile codes with useESM true 1`] = `
"// @ts-expect-error testing purpose
import babelFooCfg from './babel-foo.config';
import { getFoo } from './thing1';
import { getFooBar } from './thing1';
import { getBar } from './thing2';
getFoo('foo');
getBar('bar');
getFooBar('foobar');
getFoo(JSON.stringify(babelFooCfg.presets));
//# "
`;
exports[`TsCompiler isolatedModule false should compile ts file which has an existing js file 1`] = `
"\\"use strict\\";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { \\"default\\": mod };
};
Object.defineProperty(exports, \\"__esModule\\", { value: true });
// @ts-expect-error testing purpose
const babel_foo_config_1 = __importDefault(require(\\"./babel-foo.config\\"));
const thing1_1 = require(\\"./thing1\\");
const thing1_2 = require(\\"./thing1\\");
const thing2_1 = require(\\"./thing2\\");
thing1_1.getFoo('foo');
thing2_1.getBar('bar');
thing1_2.getFooBar('foobar');
thing1_1.getFoo(JSON.stringify(babel_foo_config_1.default.presets));
//# "
`;
exports[`TsCompiler isolatedModule true diagnostics should report diagnostics related to codes with exclude config is undefined 1`] = `"foo.ts(2,23): error TS1005: '=>' expected."`;
exports[`TsCompiler isolatedModule true diagnostics should report diagnostics related to codes with exclude config matches file name 1`] = `"foo.ts(2,23): error TS1005: '=>' expected."`;
exports[`TsCompiler isolatedModule true jsx option should compile tsx file for jsx preserve 1`] = `
"\\"use strict\\";
const App = () => {
return <>Test</>;
};
//# "
`;
exports[`TsCompiler isolatedModule true jsx option should compile tsx file for other jsx options 1`] = `
"\\"use strict\\";
const App = () => {
return React.createElement(React.Fragment, null, \\"Test\\");
};
//# "
`;
exports[`TsCompiler isolatedModule true should compile js file for allowJs true 1`] = `
"\\"use strict\\";
Object.defineProperty(exports, \\"__esModule\\", { value: true });
exports.default = 42;
//# "
`;
exports[`TsCompiler isolatedModule true should transpile code with useESM true 1`] = `
"// @ts-expect-error testing purpose
import babelFooCfg from './babel-foo.config';
import { getFoo } from './thing1';
import { getFooBar } from './thing1';
import { getBar } from './thing2';
getFoo('foo');
getBar('bar');
getFooBar('foobar');
getFoo(JSON.stringify(babelFooCfg.presets));
//# "
`;