Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
162 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { List, Map, Record, Set, Seq, DeepCopy, Collection } from 'immutable'; | ||
|
||
{ | ||
// Basic types | ||
|
||
// $ExpectType { a: number; b: number; } | ||
type Test = DeepCopy<{ a: number; b: number }>; | ||
// ^? | ||
|
||
// $ExpectType number | ||
type TestA = Test['a']; | ||
// ^? | ||
} | ||
|
||
{ | ||
// Iterables | ||
|
||
// $ExpectType string[] | ||
type Test = DeepCopy<string[]>; | ||
// ^? | ||
|
||
// $ExpectType number[] | ||
type Keyed = DeepCopy<Collection.Indexed<number>>; | ||
// ^? | ||
} | ||
|
||
{ | ||
// Immutable first-level types | ||
|
||
// $ExpectType { [x: string]: string; } | ||
type StringKey = DeepCopy<Map<string, string>>; | ||
|
||
// $ExpectType { [x: string]: object; } | ||
type ObjectKey = DeepCopy<Map<object, object>>; | ||
|
||
// $ExpectType { [x: string]: object; [x: number]: object; } | ||
type MixedKey = DeepCopy<Map<object | number, object>>; | ||
|
||
// $ExpectType string[] | ||
type ListDeepCopy = DeepCopy<List<string>>; | ||
|
||
// $ExpectType string[] | ||
type SetDeepCopy = DeepCopy<Set<string>>; | ||
} | ||
|
||
{ | ||
// Keyed | ||
|
||
// $ExpectType { [x: string]: number; } | ||
type Keyed = DeepCopy<Collection.Keyed<string, number>>; | ||
|
||
// $ExpectType { [x: string]: number; [x: number]: number; } | ||
type KeyedMixed = DeepCopy<Collection.Keyed<string | number, number>>; | ||
|
||
// $ExpectType { [x: string]: number; [x: number]: number; } | ||
type KeyedSeqMixed = DeepCopy<Seq.Keyed<string | number, number>>; | ||
|
||
// $ExpectType { [x: string]: number; [x: number]: number; } | ||
type MapMixed = DeepCopy<Map<string | number, number>>; | ||
} | ||
|
||
{ | ||
// Nested | ||
|
||
// $ExpectType { map: { [x: string]: string; }; list: string[]; set: string[]; } | ||
type NestedObject = DeepCopy<{ map: Map<string, string>; list: List<string>; set: Set<string>; }>; | ||
|
||
// $ExpectType { map: { [x: string]: string; }; } | ||
type NestedMap = DeepCopy<Map<'map', Map<string, string>>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// TypeScript Version: 2.2 | ||
// Minimum TypeScript Version: 4.5 | ||
/* tslint:disable:no-useless-files */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters