oxc/crates/oxc_codegen/tests/integration/snapshots/ts.snap

294 lines
6.7 KiB
Text

---
source: crates/oxc_codegen/tests/integration/main.rs
snapshot_kind: text
---
########## 0
let x: string = `\x01`;
----------
let x: string = `\x01`;
########## 1
function foo<T extends string>(x: T, y: string, ...restOfParams: Omit<T, 'x'>): T {
return x;
}
----------
function foo<T extends string>(x: T, y: string, ...restOfParams: Omit<T, 'x'>): T {
return x;
}
########## 2
let x: string[] = ['abc', 'def', 'ghi'];
----------
let x: string[] = [
'abc',
'def',
'ghi'
];
########## 3
let x: Array<string> = ['abc', 'def', 'ghi',];
----------
let x: Array<string> = [
'abc',
'def',
'ghi'
];
########## 4
let x: [string, number] = ['abc', 123];
----------
let x: [string, number] = ['abc', 123];
########## 5
let x: string | number = 'abc';
----------
let x: string | number = 'abc';
########## 6
let x: string & number = 'abc';
----------
let x: string & number = 'abc';
########## 7
let x: typeof String = 'string';
----------
let x: typeof String = 'string';
########## 8
let x: keyof string = 'length';
----------
let x: keyof string = 'length';
########## 9
let x: keyof typeof String = 'length';
----------
let x: keyof typeof String = 'length';
########## 10
let x: string['length'] = 123;
----------
let x: string['length'] = 123;
########## 11
function isString(value: unknown): asserts value is string {
if (typeof value !== 'string') {
throw new Error('Not a string');
}
}
----------
function isString(value: unknown): asserts value is string {
if (typeof value !== 'string') {
throw new Error('Not a string');
}
}
########## 12
import type { Foo } from 'foo';
----------
import type { Foo } from 'foo';
########## 13
import { Foo, type Bar } from 'foo';
----------
import { Foo, type Bar } from 'foo';
########## 14
export { Foo, type Bar } from 'foo';
----------
export { Foo, type Bar } from 'foo';
########## 15
type A<T> = { [K in keyof T as K extends string ? B<K> : K ]: T[K] }
----------
type A<T> = { [K in keyof T as K extends string ? B<K> : K] : T[K] };
########## 16
class A {readonly type = 'frame'}
----------
class A {
readonly type = 'frame';
}
########## 17
let foo: { <T>(t: T): void }
----------
let foo: { <T>(t: T): void };
########## 18
let foo: { new <T>(t: T): void }
----------
let foo: { new <T>(t: T): void };
########## 19
function <const T>(){}
----------
function<const T>() {}
########## 20
class A {m?(): void}
----------
class A {
m?(): void;
}
########## 21
class A {constructor(public readonly a: number) {}}
----------
class A {
constructor(public readonly a: number) {}
}
########## 22
abstract class A {private abstract static m() {}}
----------
abstract class A {
private abstract static m() {}
}
########## 23
abstract class A {private abstract static readonly prop: string}
----------
abstract class A {
private abstract static readonly prop: string;
}
########## 24
a = x!;
----------
a = x!;
########## 25
b = (x as y);
----------
b = x as y;
########## 26
c = foo<string>;
----------
c = foo<string>;
########## 27
d = x satisfies y;
----------
d = ((x) satisfies y);
########## 28
export @x declare abstract class C {}
----------
export @x declare abstract class C {}
########## 29
div<T>``
----------
div<T>``;
########## 30
export type Component<Props = any> = Foo;
----------
export type Component<Props = any> = Foo;
########## 31
export type Component<
Props = any,
RawBindings = any,
D = any,
C extends ComputedOptions = ComputedOptions,
M extends MethodOptions = MethodOptions,
E extends EmitsOptions | Record<string, any[]> = {},
S extends Record<string, any> = any,
> =
| ConcreteComponent<Props, RawBindings, D, C, M, E, S>
| ComponentPublicInstanceConstructor<Props>
----------
export type Component<
Props = any,
RawBindings = any,
D = any,
C extends ComputedOptions = ComputedOptions,
M extends MethodOptions = MethodOptions,
E extends EmitsOptions | Record<string, any[]> = {},
S extends Record<string, any> = any
> = ConcreteComponent<Props, RawBindings, D, C, M, E, S> | ComponentPublicInstanceConstructor<Props>;
########## 32
(a || b) as any
----------
(a || b) as any;
########## 33
(a ** b) as any
----------
(a ** b) as any;
########## 34
(function g() {}) as any
----------
(function g() {}) as any;
########## 35
import defaultExport from "module-name";
import * as name from "module-name";
import { export1 } from "module-name";
import { export1 as alias1 } from "module-name";
import { default as alias } from "module-name";
import { export1, export2 } from "module-name";
import { export1, export2 as alias2, /* … */ } from "module-name";
import { "string name" as alias } from "module-name";
import defaultExport, { export1, /* … */ } from "module-name";
import defaultExport, * as name from "module-name";
import "module-name";
import {} from 'mod';
export let name1, name2/*, … */; // also var
export const name3 = 1, name4 = 2/*, … */; // also var, let
export function functionName() { /* … */ }
export class ClassName { /* … */ }
export function* generatorFunctionName() { /* … */ }
export const { name5, name2: bar } = o;
export const [ name6, name7 ] = array;
export { name8, /* …, */ name81 };
export { variable1 as name9, variable2 as name10, /* …, */ name82 };
export { variable1 as "string name" };
export { name1 as default1 /*, … */ };
export * from "module-name";
export * as name11 from "module-name";
export { name12, /* …, */ nameN } from "module-name";
export { import1 as name13, import2 as name14, /* …, */ name15 } from "module-name";
export { default, /* …, */ } from "module-name";
export { default as name16 } from "module-name";
----------
import defaultExport from 'module-name';
import * as name from 'module-name';
import { export1 } from 'module-name';
import { export1 as alias1 } from 'module-name';
import { default as alias } from 'module-name';
import { export1, export2 } from 'module-name';
import { export1, export2 as alias2 } from 'module-name';
import { 'string name' as alias } from 'module-name';
import defaultExport, { export1 } from 'module-name';
import defaultExport, * as name from 'module-name';
import 'module-name';
import {} from "mod";
export let name1, name2;
export const name3 = 1, name4 = 2;
export function functionName() {}
export class ClassName {}
export function* generatorFunctionName() {}
export const { name5, name2: bar } = o;
export const [name6, name7] = array;
export { name8, name81 };
export { variable1 as name9, variable2 as name10, name82 };
export { variable1 as 'string name' };
export { name1 as default1 };
export * from 'module-name';
export * as name11 from 'module-name';
export { name12, nameN } from 'module-name';
export { import1 as name13, import2 as name14, name15 } from 'module-name';
export { default } from 'module-name';
export { default as name16 } from 'module-name';