Question mark in callback

static setItem(key: string, value: string, callback?: ?(error: ?Error) => void)

      

This is a setitem declaration in AsyncStorage. the third parameter is the callback. Can someone explain the use of question marks here. I am familiar with how to use a promise but have not been able to handle the question mark.

+3


source to share


1 answer


AsyncStorage uses a stream - Facebook's open source static type checker. You will find @flow at the beginning of the file and mark the source with flow support. Flow does a lot of type checking for variables (including auto-inference), but it also allows you to specify the types of variables and parameters. In the above example, "key: string", for example, indicates that the key must be a string (this is not a valid javascript construct - you cannot specify a type in javascript). React has built-in transformers that convert it to pure javascript (so all types are removed), but before this thread checks if the types are passed correctly and look for things like passing null or undefined and using them later as an object and many more checks, you can read the specifications inhttp://flowtype.org/ .

So, answering your question about the question of the question:



+6


source







All Articles