File: constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.types

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (36 lines) | stat: -rw-r--r-- 1,256 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
=== tests/cases/compiler/constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts ===
// https://github.com/Microsoft/TypeScript/issues/25379

interface Map<K, V> {
    // ...
}

export type ImmutableTypes = IImmutableMap<any>;
>ImmutableTypes : IImmutableMap<any>

export type ImmutableModel<T> = { [K in keyof T]: T[K] extends ImmutableTypes ? T[K] : never };
>ImmutableModel : ImmutableModel<T>

export interface IImmutableMap<T extends ImmutableModel<T>> extends Map<string, any> {
    set<K extends keyof T>(key: K, value: T[K]): IImmutableMap<T>;
>set : <K extends keyof T>(key: K, value: T[K]) => IImmutableMap<T>
>key : K
>value : T[K]
}

export type ImmutableTypes2 = IImmutableMap2<any>;
>ImmutableTypes2 : IImmutableMap2<any>

type isImmutableType<T> = [T] extends [ImmutableTypes2] ? T : never;
>isImmutableType : isImmutableType<T>

export type ImmutableModel2<T> = { [K in keyof T]: isImmutableType<T[K]> };
>ImmutableModel2 : ImmutableModel2<T>

export interface IImmutableMap2<T extends ImmutableModel2<T>> extends Map<string, any> {
    set<K extends keyof T>(key: K, value: T[K]): IImmutableMap2<T>;
>set : <K extends keyof T>(key: K, value: T[K]) => IImmutableMap2<T>
>key : K
>value : T[K]
}