#Typescript - decorators

4 messages · Page 1 of 1 (latest)

inland thunder
#

Hey guys,

Anyone know what the code is saying here? I can't find why a section of code is sort of commented out but also works? This is a challenge I'm supposed to be doing but I'm completely stuck. I don't know what this is called so I don't know what to search. I've tried typing bits of the code directly into Google, but no luck!

limpid raven
# inland thunder Hey guys, Anyone know what the code is saying here? I can't find why a section ...

The code is creating a JSDoc reference @param - in short, it's the blueprint for a parameter used in a function. The parameter has a custom type, which is an object with 2 properties: documentName and caseInfo.

documentName is a string.

caseInfo is an object with the following properties:
firstName - string
surname - string
dateOfBirth - string
postCode - string

The ? for those properties tell us they are all optional. Finally, param0 is the name of the param, so to use it you would do (for example):

function getDocumentName(param0) {
  return param0.documentName
}
inland thunder
#

You are a life saver! Thank you!

I'd spent so long in the Typescript docs, I just couldn't find the answer!

So it's a JS thing, not specifically TS?

... Goes to revise JS....