File: constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js

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 (27 lines) | stat: -rw-r--r-- 1,000 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
//// [constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.ts]
// https://github.com/Microsoft/TypeScript/issues/25379

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

export type ImmutableTypes = IImmutableMap<any>;

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

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

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


//// [constraintOfRecursivelyMappedTypeWithConditionalIsResolvable.js]
"use strict";
// https://github.com/Microsoft/TypeScript/issues/25379
exports.__esModule = true;