TS: Avoid infinite recursion in stringifyType

This commit is contained in:
Asger F
2019-06-28 10:24:34 +01:00
parent d2f8029625
commit f5569b8b58
5 changed files with 25 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
| test.ts:3:1:7:6 | type Di ... \\n T; | Disjunction<T> |
| test.ts:9:8:9:65 | type Tr ... n<T>>>; | Disjunction<Disjunction<Disjunction<T>>> |

View File

@@ -0,0 +1,4 @@
import javascript
from TypeAliasDeclaration decl
select decl, decl.getDefinition().getType()

View File

@@ -0,0 +1,9 @@
import { ArrayBox, Box } from 'somewhere';
type Disjunction<T> =
T extends ArrayBox<infer U1> ? U1[] :
T extends Box<infer U2> ? U2 :
T extends ({[P in keyof T]: T[P]} & {p: any}) ? {[P in Exclude<keyof T, 'p'>]: Disjunction<T[P]>} :
T;
export type Triple<T> = Disjunction<Disjunction<Disjunction<T>>>;