Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript What does this grammar '-?' (dash question) mean?

guys.

I am new to typescript and saw '-?' grammar in @types/prop-types package

e.g

export type ValidationMap<T> = { [K in keyof T]-?: Validator<T[K]> };

what does '[K in keyof T]-?' mean?

I tried my best to google that, but failed.

Thank you.

like image 248
Park Avatar asked Sep 10 '18 08:09

Park


1 Answers

Homomorphic mapped types copy the optionality of the original type field to the mapped type field. The -? is the syntax used to explicitly remove any optional modifier from the resulting mapped type. You can read more details here

like image 199
Titian Cernicova-Dragomir Avatar answered Oct 21 '22 15:10

Titian Cernicova-Dragomir