Skip to content

Commit

Permalink
add empty.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas committed Feb 21, 2024
1 parent 395ad40 commit 0a5d06e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 42 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Expand Up @@ -6,3 +6,4 @@ type-definitions/flow-tests/

!type-definitions/ts-tests/covariance.ts
!type-definitions/ts-tests/deepCopy.ts
!type-definitions/ts-tests/empty.ts
3 changes: 2 additions & 1 deletion tstyche.config.json
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://tstyche.org/schemas/config.json",
"testFileMatch": [
"**/type-definitions/ts-tests/covariance.ts",
"**/type-definitions/ts-tests/deepCopy.ts"
"**/type-definitions/ts-tests/deepCopy.ts",
"**/type-definitions/ts-tests/empty.ts"
]
}
67 changes: 27 additions & 40 deletions type-definitions/ts-tests/empty.ts
@@ -1,57 +1,44 @@
import { expect, test } from 'tstyche';
import { Seq, Collection } from 'immutable';

{
// Typed empty seqs
test('typed empty Seq', () => {
expect(Seq()).type.toEqual<Seq<unknown, unknown>>();

// $ExpectType Seq<unknown, unknown>
Seq();
expect(Seq<number, string>()).type.toEqual<Seq<number, string>>();

// $ExpectType Seq<number, string>
Seq<number, string>();
expect(Seq.Indexed()).type.toEqual<Seq.Indexed<unknown>>();

// $ExpectType Indexed<unknown>
Seq.Indexed();
expect(Seq.Indexed<string>()).type.toEqual<Seq.Indexed<string>>();

// $ExpectType Indexed<string>
Seq.Indexed<string>();
expect(Seq.Keyed()).type.toEqual<Seq.Keyed<unknown, unknown>>();

// $ExpectType Keyed<unknown, unknown>
Seq.Keyed();
expect(Seq.Keyed<number, string>()).type.toEqual<Seq.Keyed<number, string>>();

// $ExpectType Keyed<number, string>
Seq.Keyed<number, string>();
expect(Seq.Set()).type.toEqual<Seq.Set<unknown>>();

// $ExpectType Set<unknown>
Seq.Set();
expect(Seq.Set<string>()).type.toEqual<Seq.Set<string>>();
});

// $ExpectType Set<string>
Seq.Set<string>();
}
test('typed empty Collection', () => {
expect(Collection()).type.toEqual<Collection<unknown, unknown>>();

{
// Typed empty collection
expect(Collection<number, string>()).type.toEqual<
Collection<number, string>
>();

// $ExpectType Collection<unknown, unknown>
Collection();
expect(Collection.Indexed()).type.toEqual<Collection.Indexed<unknown>>();

// $ExpectType Collection<number, string>
Collection<number, string>();
expect(Collection.Indexed<string>()).type.toEqual<
Collection.Indexed<string>
>();

// $ExpectType Indexed<unknown>
Collection.Indexed();
expect(Collection.Keyed()).type.toEqual<Collection.Keyed<unknown, unknown>>();

// $ExpectType Indexed<string>
Collection.Indexed<string>();
expect(Collection.Keyed<number, string>()).type.toEqual<
Collection.Keyed<number, string>
>();

// $ExpectType Keyed<unknown, unknown>
Collection.Keyed();
expect(Collection.Set()).type.toEqual<Collection.Set<unknown>>();

// $ExpectType Keyed<number, string>
Collection.Keyed<number, string>();

// $ExpectType Set<unknown>
Collection.Set();

// $ExpectType Set<string>
Collection.Set<string>();
}
expect(Collection.Set<string>()).type.toEqual<Collection.Set<string>>();
});
2 changes: 1 addition & 1 deletion type-definitions/ts-tests/tslint.json
@@ -1,7 +1,7 @@
{
"extends": "dtslint/dtslint.json",
"linterOptions": {
"exclude": ["covariance.ts", "deepCopy.ts"]
"exclude": ["covariance.ts", "deepCopy.ts", "empty.ts"]
},
"rules": {
"no-var": false,
Expand Down

0 comments on commit 0a5d06e

Please sign in to comment.