Skip to content

Commit

Permalink
test(ts-interface): extend test models with previously unhandled cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Brainshaker95 committed May 4, 2023
1 parent 87924e8 commit 62736a1
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 1 deletion.
22 changes: 22 additions & 0 deletions tests/Fixture/Input/IterableTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,26 @@ final class IterableTypes
* }
*/
public array $testProperty7;

/**
* @var list{}
*/
public array $testProperty8;

/**
* @var array{
* string,
* ...,
* }
*/
public array $testProperty9;

/**
* @var array{
* 0: 1.0|string,
* 'foo': string,
* ...,
* }
*/
public array $testProperty10;
}
16 changes: 15 additions & 1 deletion tests/Fixture/Input/NativeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,24 @@ final class NativeTypes

public stdClass $testProperty17;

/**
* @phpstan-ignore-next-line
*
* @var Foo&Bar
*/
public object $testProperty18;

public string|false $testProperty19;

/**
* @var true
*/
public bool $testProperty20;

/**
* @phpstan-ignore-next-line
*/
private $testProperty18;
private $testProperty21;

/**
* This is the constructor description.
Expand Down
10 changes: 10 additions & 0 deletions tests/Fixture/Output/IterableTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
*/
export interface IterableTypes {
testProperty1: string[];
testProperty10: {
[key: string]: unknown;
'0': (1.0 | string);
foo: string;
};
testProperty2: string[][];
testProperty3: Array<number>;
testProperty4: Record<string, boolean>;
Expand All @@ -24,4 +29,9 @@ export interface IterableTypes {
foo: (boolean | 'foo');
} | null);
};
testProperty8: unknown[];
testProperty9: [
string,
...unknown[],
];
}
6 changes: 6 additions & 0 deletions tests/Fixture/Output/NativeTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Do not modify directly!
*/

import type { Bar } from './Bar';
import type { Foo } from './Foo';

export interface NativeTypes {
/**
* @deprecated
Expand Down Expand Up @@ -48,6 +51,9 @@ export interface NativeTypes {
testProperty15: unknown;
testProperty16: unknown;
testProperty17: unknown;
testProperty18: (Foo & Bar);
testProperty19: (string | false);
testProperty20: true;
testProperty5: number;
testProperty6: number;
testProperty7: string;
Expand Down
10 changes: 10 additions & 0 deletions tests/Fixture/Output/iterable-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
*/
export interface IterableTypes {
testProperty1: string[];
testProperty10: {
[key: string]: unknown;
'0': (1.0 | string);
foo: string;
};
testProperty2: string[][];
testProperty3: Array<number>;
testProperty4: Record<string, boolean>;
Expand All @@ -24,4 +29,9 @@ export interface IterableTypes {
foo: (boolean | 'foo');
} | null);
};
testProperty8: unknown[];
testProperty9: [
string,
...unknown[],
];
}
10 changes: 10 additions & 0 deletions tests/Fixture/Output/iterable_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
* This is a class description
*/
declare type IterableTypes = {
testProperty9: [
string,
...unknown[],
];
testProperty8: unknown[];
testProperty7: {
foo: string;
bar: {
Expand All @@ -23,5 +28,10 @@ declare type IterableTypes = {
testProperty4: Record<string, boolean>;
testProperty3: Array<number>;
testProperty2: string[][];
testProperty10: {
[key: string]: unknown;
"0": (1.0 | string);
foo: string;
};
testProperty1: string[];
}
6 changes: 6 additions & 0 deletions tests/Fixture/Output/native-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Do not modify directly!
*/

import type { Bar } from './bar';
import type { Foo } from './foo';

export interface NativeTypes {
/**
* @deprecated
Expand Down Expand Up @@ -48,6 +51,9 @@ export interface NativeTypes {
testProperty15: unknown;
testProperty16: unknown;
testProperty17: unknown;
testProperty18: (Foo & Bar);
testProperty19: (string | false);
testProperty20: true;
testProperty5: number;
testProperty6: number;
testProperty7: string;
Expand Down
3 changes: 3 additions & 0 deletions tests/Fixture/Output/native_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ declare type NativeTypes = {
* @deprecated
*/
testProperty3: string;
testProperty20: true;
/**
* @deprecated
*/
readonly testProperty2: string;
testProperty19: (string | false);
testProperty18: (Foo & Bar);
testProperty17: unknown;
testProperty16: unknown;
testProperty15: unknown;
Expand Down

0 comments on commit 62736a1

Please sign in to comment.