Skip to content

Commit

Permalink
add es6-collections.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas committed Feb 21, 2024
1 parent 0a5d06e commit 6ce6deb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Expand Up @@ -7,3 +7,4 @@ type-definitions/flow-tests/
!type-definitions/ts-tests/covariance.ts
!type-definitions/ts-tests/deepCopy.ts
!type-definitions/ts-tests/empty.ts
!type-definitions/ts-tests/es6-collections.ts
3 changes: 2 additions & 1 deletion tstyche.config.json
Expand Up @@ -3,6 +3,7 @@
"testFileMatch": [
"**/type-definitions/ts-tests/covariance.ts",
"**/type-definitions/ts-tests/deepCopy.ts",
"**/type-definitions/ts-tests/empty.ts"
"**/type-definitions/ts-tests/empty.ts",
"**/type-definitions/ts-tests/es6-collections.ts"
]
}
33 changes: 19 additions & 14 deletions type-definitions/ts-tests/es6-collections.ts
@@ -1,18 +1,23 @@
import {
Map as ImmutableMap,
Set as ImmutableSet,
} from 'immutable';
import { expect, test } from 'tstyche';
import { Map as ImmutableMap, Set as ImmutableSet } from 'immutable';

// Immutable.js collections
const mapImmutable: ImmutableMap<string, number> = ImmutableMap<string, number>();
const setImmutable: ImmutableSet<string> = ImmutableSet<string>();
test('immutable.js collections', () => {
const mapImmutable: ImmutableMap<string, number> = ImmutableMap<
string,
number
>();
const setImmutable: ImmutableSet<string> = ImmutableSet<string>();

// $ExpectType Map<string, number>
mapImmutable.delete('foo');
expect(mapImmutable.delete('foo')).type.toEqual<
ImmutableMap<string, number>
>();
expect(setImmutable.delete('bar')).type.toEqual<ImmutableSet<string>>();
});

// ES6 collections
const mapES6: Map<string, number> = new Map<string, number>();
const setES6: Set<string> = new Set<string>();
test('ES6 collections', () => {
const mapES6: Map<string, number> = new Map<string, number>();
const setES6: Set<string> = new Set<string>();

// $ExpectType boolean
mapES6.delete('foo');
expect(mapES6.delete('foo')).type.toEqual<boolean>();
expect(setES6.delete('bar')).type.toEqual<boolean>();
});
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", "empty.ts"]
"exclude": ["covariance.ts", "deepCopy.ts", "empty.ts", "es6-collections.ts"]
},
"rules": {
"no-var": false,
Expand Down

0 comments on commit 6ce6deb

Please sign in to comment.