mirror of
https://github.com/swc-project/swc.git
synced 2024-12-29 00:23:10 +03:00
test(es/transforms): Add tests for fixed issues (#5655)
This commit is contained in:
parent
51335ebc35
commit
2cddb240c9
16
crates/swc/tests/exec/issues-1xxx/.1304/exec.js
Normal file
16
crates/swc/tests/exec/issues-1xxx/.1304/exec.js
Normal file
@ -0,0 +1,16 @@
|
||||
function cache(target, key, value) {
|
||||
return {
|
||||
get() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Life {
|
||||
#friends = true;
|
||||
|
||||
@cache // remove this and see private class field transpile without errors
|
||||
get happy() {
|
||||
return this.#friends;
|
||||
}
|
||||
}
|
25
crates/swc/tests/exec/issues-1xxx/1592/.swcrc
Normal file
25
crates/swc/tests/exec/issues-1xxx/1592/.swcrc
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"test": ".*.ts$",
|
||||
"sourceMaps": true,
|
||||
"jsc": {
|
||||
"loose": true,
|
||||
"target": "es2020",
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"tsx": false,
|
||||
"decorators": true,
|
||||
"dynamicImport": true
|
||||
},
|
||||
"transform": {
|
||||
"legacyDecorator": true,
|
||||
"decoratorMetadata": true
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "commonjs",
|
||||
"strict": true,
|
||||
"strictMode": false,
|
||||
"lazy": false,
|
||||
"noInterop": false
|
||||
}
|
||||
}
|
43
crates/swc/tests/exec/issues-1xxx/1592/exec.ts
Normal file
43
crates/swc/tests/exec/issues-1xxx/1592/exec.ts
Normal file
@ -0,0 +1,43 @@
|
||||
class LoggerService {
|
||||
debug(message: string): void {
|
||||
console.log({ message });
|
||||
}
|
||||
}
|
||||
|
||||
export function Logger(): any {
|
||||
return (target: Record<string, any>, key: string | symbol): void => {
|
||||
const loggerService: LoggerService = new LoggerService();
|
||||
const updated: boolean = Reflect.defineProperty(target, key, {
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
value: loggerService,
|
||||
writable: false,
|
||||
});
|
||||
|
||||
if (!updated) {
|
||||
throw new Error(`Unable to define ${String(key)} property for ${JSON.stringify(target)}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class TestClass1 {
|
||||
@Logger() private readonly logger: LoggerService;
|
||||
|
||||
test(): void {
|
||||
this.logger.debug('test1');
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass2 {
|
||||
@Logger() private readonly logger: LoggerService;
|
||||
|
||||
test(): void {
|
||||
this.logger.debug('test2');
|
||||
}
|
||||
}
|
||||
|
||||
(async (): Promise<void> => {
|
||||
new TestClass1().test();
|
||||
new TestClass2().test();
|
||||
console.log('OK');
|
||||
})();
|
7
crates/swc/tests/exec/issues-4xxx/.4148/exec.ts
Normal file
7
crates/swc/tests/exec/issues-4xxx/.4148/exec.ts
Normal file
@ -0,0 +1,7 @@
|
||||
//a.ts
|
||||
import { Foo } from "./b";
|
||||
// import type { Foo } from "./b"; has the same behavior
|
||||
const Foo = "hey";
|
||||
|
||||
// b.ts
|
||||
export type Foo = string;
|
2
crates/swc/tests/exec/issues-4xxx/.4176/exec.ts
Normal file
2
crates/swc/tests/exec/issues-4xxx/.4176/exec.ts
Normal file
@ -0,0 +1,2 @@
|
||||
const module = 'left-pad'
|
||||
module
|
10
crates/swc/tests/exec/issues-4xxx/.4286/exec.js
Normal file
10
crates/swc/tests/exec/issues-4xxx/.4286/exec.js
Normal file
@ -0,0 +1,10 @@
|
||||
console.log([
|
||||
...(function* () {
|
||||
for (const i of [1, 2, 3]) {
|
||||
Promise.resolve().then(() => {
|
||||
console.log(`async: ${i}`);
|
||||
});
|
||||
yield i;
|
||||
}
|
||||
})(),
|
||||
]);
|
26
crates/swc/tests/exec/issues-4xxx/.4486/exec.js
Normal file
26
crates/swc/tests/exec/issues-4xxx/.4486/exec.js
Normal file
@ -0,0 +1,26 @@
|
||||
const obj = {
|
||||
a: 'a',
|
||||
b: 'b',
|
||||
c: 'c',
|
||||
d: 'd',
|
||||
}
|
||||
|
||||
const wait = n => new Promise(r => setTimeout(r, n))
|
||||
|
||||
const action = async () => {
|
||||
|
||||
for (let i in obj) {
|
||||
|
||||
// halt for a second
|
||||
await wait(1000)
|
||||
|
||||
// this one is trouble
|
||||
wait(1000).then(() => console.log(i))
|
||||
|
||||
}
|
||||
|
||||
console.log('done')
|
||||
}
|
||||
|
||||
|
||||
await action()
|
1
crates/swc/tests/exec/issues-4xxx/.4911/exec.ts
Normal file
1
crates/swc/tests/exec/issues-4xxx/.4911/exec.ts
Normal file
@ -0,0 +1 @@
|
||||
const r = n => { return true ? (true) : t => { } }
|
12
crates/swc/tests/exec/issues-4xxx/4483/exec.ts
Normal file
12
crates/swc/tests/exec/issues-4xxx/4483/exec.ts
Normal file
@ -0,0 +1,12 @@
|
||||
export enum THEME_SETTINGS_MODE {
|
||||
default = "default",
|
||||
dark = "dark"
|
||||
}
|
||||
|
||||
export enum THEME_SETTINGS_MAP {
|
||||
normal = THEME_SETTINGS_MODE.default,
|
||||
fancy = THEME_SETTINGS_MODE.dark
|
||||
}
|
||||
|
||||
console.log(THEME_SETTINGS_MAP.normal)
|
||||
expect(THEME_SETTINGS_MAP.normal).toEqual('default')
|
1
crates/swc/tests/exec/issues-5xxx/.5077/exec.ts
Normal file
1
crates/swc/tests/exec/issues-5xxx/.5077/exec.ts
Normal file
@ -0,0 +1 @@
|
||||
Promise.all<<T>() => void>([]);
|
9
crates/swc/tests/exec/issues-5xxx/.5276/.swcrc
Normal file
9
crates/swc/tests/exec/issues-5xxx/.5276/.swcrc
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/swcrc",
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "ecmascript",
|
||||
"decorators": true
|
||||
}
|
||||
}
|
||||
}
|
4
crates/swc/tests/exec/issues-5xxx/.5276/exec.js
Normal file
4
crates/swc/tests/exec/issues-5xxx/.5276/exec.js
Normal file
@ -0,0 +1,4 @@
|
||||
export class MyClass {
|
||||
@MyDecorator()
|
||||
export = true;
|
||||
}
|
18
crates/swc/tests/exec/issues-5xxx/.5474/.swcrc
Normal file
18
crates/swc/tests/exec/issues-5xxx/.5474/.swcrc
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es5",
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"decorators": true,
|
||||
"dynamicImport": true
|
||||
},
|
||||
"transform": {
|
||||
"legacyDecorator": false,
|
||||
"decoratorMetadata": true
|
||||
}
|
||||
},
|
||||
"sourceMaps": true,
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
}
|
12
crates/swc/tests/exec/issues-5xxx/.5645/exec.js
Normal file
12
crates/swc/tests/exec/issues-5xxx/.5645/exec.js
Normal file
@ -0,0 +1,12 @@
|
||||
const t = {
|
||||
1: 'a',
|
||||
2: 'b'
|
||||
}
|
||||
function g(arg) {
|
||||
if (t[arg] === undefined) {
|
||||
var arg = 2
|
||||
}
|
||||
return t[arg]
|
||||
}
|
||||
|
||||
console.log(g(1))
|
10
crates/swc/tests/exec/issues-5xxx/5474/exec.ts
Normal file
10
crates/swc/tests/exec/issues-5xxx/5474/exec.ts
Normal file
@ -0,0 +1,10 @@
|
||||
function Decorator() { }
|
||||
|
||||
class User {
|
||||
@Decorator()
|
||||
property: import("./Test").Test
|
||||
}
|
||||
|
||||
// Test.ts
|
||||
|
||||
export class Test { }
|
Loading…
Reference in New Issue
Block a user