Skip to content

Commit 07aac53

Browse files
committed
add key types tests
1 parent a44dd46 commit 07aac53

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/issue-91.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,18 @@ describe('template literal types', () => {
1919
is<`foo${string}${number}bar${1 | 2 | 3}baz${number}asdf`>('foobar1bar2baz123asdf'), true
2020
)
2121
)
22+
describe('key types', () => {
23+
it('primitives get resolved to strings', () =>
24+
assert.deepStrictEqual(is<{ [K in `foo${string}`]: any }>({foo: 'bar', baz: 'qux'}), true)
25+
)
26+
describe('unions', () => {
27+
type Foo = { [K in `foo${'bar' | 'baz'}`]: any }
28+
it('true', () =>
29+
assert.deepStrictEqual(is<Foo>({foobar: 'bar', foobaz: 'qux'}), true)
30+
)
31+
it('false', () =>
32+
assert.deepStrictEqual(is<Foo>({foo: 'bar', baz: 'qux'}), false)
33+
)
34+
})
35+
})
2236
})

0 commit comments

Comments
 (0)