github-actions[bot] 13102e9baf
feat(question): add #15260 - Tree path array (#15261)
Co-authored-by: Neil Richter <19751938+noook@users.noreply.github.com>
2022-10-27 15:17:45 +08:00

21 lines
631 B
TypeScript

import type { ExpectTrue,ExpectFalse,ExpectExtends } from '@type-challenges/utils'
declare const example: {
foo: {
bar: {
a: string;
};
baz: {
b: number
c: number
}
};
}
type cases = [
ExpectTrue<ExpectExtends<Path<typeof example['foo']['bar']>, ['a']>>,
ExpectTrue<ExpectExtends<Path<typeof example['foo']['baz']>,['b'] | ['c'] >>,
ExpectTrue<ExpectExtends<Path<typeof example['foo']>, ['bar'] | ['baz'] | ['bar', 'a'] | ['baz', 'b'] | ['baz', 'c']>>,
ExpectFalse<ExpectExtends<Path<typeof example['foo']['bar']>, ['z']>>,
]