Skip to content

Commit

Permalink
chore: Add "converter2" tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Mar 29, 2021
1 parent 53126c6 commit a11a929
Show file tree
Hide file tree
Showing 46 changed files with 1,141 additions and 3,596 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
},
"overrides": [
{
"files": ["src/test/converter/**", "src/test/renderer/**"],
"files": [
"src/test/converter/**",
"src/test/converter2/**",
"src/test/renderer/**"
],
"rules": {
"prefer-rest-params": 0,
"no-inner-declarations": 0,
Expand Down
1 change: 1 addition & 0 deletions scripts/copy_test_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { join } = require("path");

const copy = [
"test/converter",
"test/converter2",
"test/renderer",
"test/module",
"test/utils/options/readers/data",
Expand Down
84 changes: 0 additions & 84 deletions src/test/converter/alias/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,87 +17,3 @@ export type IsString<T> = T extends string ? "string" : "not string";
* Extracts the type of a promise.
*/
export type PromiseType<T> = T extends PromiseLike<infer U> ? U : T;

/**
* Conditional type with infer
*/
export type PopFront<T extends any[]> = ((...args: T) => any) extends (
a: any,
...r: infer R
) => any
? R
: never;

/**
* See GH#1150. Calling typeChecker.typeToString on this type will send TS into an infinite
* loop, which is undesirable.
*/
export type HorribleRecursiveTypeThatShouldNotBeUsedByAnyone<
T extends any[],
R = {}
> = {
0: R;
1: HorribleRecursiveTypeThatShouldNotBeUsedByAnyone<
PopFront<T>,
{
[K in keyof R | keyof T[0]]: K extends keyof R ? R[K] : T[0][K];
}
>;
}[T["length"] extends 0 ? 0 : 1];

export namespace GH1330 {
export type ExampleParam = Example;
export interface Example<T extends ExampleParam = ExampleParam> {}

declare const makeExample: () => Example;
declare const makeExample2: () => ExampleParam;

// Recursive type when we don't have a type node.
export const testValue = makeExample();
export const testValue2 = makeExample2();

export type HasProp<T> = { key: T };

declare const makeProp: <T>(x: T) => HasProp<T>;
export const testValue3 = makeProp(1);
}

export namespace GH1408 {
export declare function foo<T extends unknown[]>(): T;
}

export namespace GH1454 {
export type Foo = string | number;
export type Bar = string | number;

export declare function bar(x: Bar): Bar;
export declare function foo(x: Foo): Foo;
}

export namespace GH1547 {
export interface ThingA {
type: "ThingA";
}

export interface ThingB {
type: "ThingB";
}

type Things = ThingA | ThingB;

type ValueOrArray<T> = T | Array<ValueOrArray<T>>;

/**
* Test.
*/
export class Test {
/**
* Log a thing.
*
* @param things - Array of things or a thing.
*/
log_thing(things: ValueOrArray<Things>): void {
console.log(things);
}
}
}
Loading

0 comments on commit a11a929

Please sign in to comment.