Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 18005

Is it possible to fix the typescript error below by Record?

$
0
0

Like below, the vscode will show type error because missing a 'aa' type in the data field. Well, how can I fix it elegantly?

interface A {    data: Record<'aa' | 'bb', string>}let a: A = {    data: {        bb: ""    }}

Also I put a typescript playground link, hope you guy can quickly understand what I mean. Thanks very much.

https://www.typescriptlang.org/play/?ssl=9&ssc=2&pln=1&pc=1#code/JYOwLgpgTgZghgYwgAgILIN4Chm+QEzjDgC5kAlCBAeynwB4ByOOR5AH2UYCNvGAaZAGcwUUAHMAfFgC+WLABsIYZKTTIAvJhx5CxMtjxHkvMgCIzO3HJlA


Viewing all articles
Browse latest Browse all 18005


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>