This content originally appeared on 2ality – JavaScript and more and was authored by Dr. Axel Rauschmayer
The problem
Consider the following TypeScript code:
interface Person {
first: string;
last: string;
}
const personKeys = [
'first',
'last',
] as const;
personKeys
lists the property keys of Person
. Can we check at compile time if this list is correct?
This content originally appeared on 2ality – JavaScript and more and was authored by Dr. Axel Rauschmayer
Dr. Axel Rauschmayer | Sciencx (2022-07-27T00:00:00+00:00) TypeScript: checking at compile time if an Array lists all property keys. Retrieved from https://www.scien.cx/2022/07/27/typescript-checking-at-compile-time-if-an-array-lists-all-property-keys/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.