mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
4d723caaff
Quoted module names are only valid in ambient contexts in TypeScript, but we were accepting them in regular TypeScript files. This reports TS1035 when a quoted module name appears outside a declaration file or ambient declaration. The conformance snapshots now cover both TypeScript cases, and the old invalid codegen fixture has been replaced with a valid internal module declaration.
251 lines
7.3 KiB
Plaintext
251 lines
7.3 KiB
Plaintext
---
|
|
source: crates/oxc_codegen/tests/integration/tester.rs
|
|
---
|
|
########## 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 {protected abstract m()}
|
|
----------
|
|
abstract class A{protected abstract m();}
|
|
########## 23
|
|
class A {private static readonly prop: string}
|
|
----------
|
|
class A{private static readonly prop:string}
|
|
########## 24
|
|
interface A { a: string, 'b': number, 'c'(): void }
|
|
----------
|
|
interface A{a:string;"b":number;"c"():void;}
|
|
########## 25
|
|
enum A { a, 'b' }
|
|
----------
|
|
enum A{a,"b"}
|
|
########## 26
|
|
module a {}
|
|
----------
|
|
module a{}
|
|
########## 27
|
|
declare module 'a'
|
|
----------
|
|
declare module "a";
|
|
########## 28
|
|
a = x!;
|
|
----------
|
|
a=x!;
|
|
########## 29
|
|
b = (x as y);
|
|
----------
|
|
b=x as y;
|
|
########## 30
|
|
c = foo<string>;
|
|
----------
|
|
c=foo<string> ;
|
|
########## 31
|
|
new Map<string, number>();
|
|
----------
|
|
new Map<string,number>;
|
|
########## 32
|
|
d = x satisfies y;
|
|
----------
|
|
d=x satisfies y;
|
|
########## 33
|
|
export @x declare abstract class C {}
|
|
----------
|
|
export@x declare abstract class C{}
|
|
########## 34
|
|
div<T>``
|
|
----------
|
|
div<T>``;
|
|
########## 35
|
|
export type Component<Props = any> = Foo;
|
|
----------
|
|
export type Component<Props=any>=Foo;
|
|
########## 36
|
|
|
|
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>;
|
|
########## 37
|
|
(a || b) as any
|
|
----------
|
|
(a||b)as any;
|
|
########## 38
|
|
(a ** b) as any
|
|
----------
|
|
(a**b)as any;
|
|
########## 39
|
|
(function g() {}) as any
|
|
----------
|
|
(function g(){})as any;
|
|
########## 40
|
|
|
|
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";
|
|
########## 41
|
|
|
|
import a = require("a");
|
|
export import b = require("b");
|
|
|
|
----------
|
|
import a=require("a");export import b=require("b");
|
|
########## 42
|
|
class C {
|
|
static
|
|
static
|
|
static
|
|
bar() {}
|
|
}
|
|
----------
|
|
class C{static static;static bar(){}}
|
|
########## 43
|
|
type T = typeof import('react');
|
|
----------
|
|
type T=typeof import("react");
|
|
########## 44
|
|
type U = typeof import("vue");
|
|
----------
|
|
type U=typeof import("vue");
|
|
########## 45
|
|
type V = typeof import('some-module').SomeType;
|
|
----------
|
|
type V=typeof import("some-module").SomeType;
|
|
########## 46
|
|
type W = typeof import('pkg').default<string>;
|
|
----------
|
|
type W=typeof import("pkg").default<string>;
|