I wrote the following code:
public getTypeDetail(node : Type)
{
let callSignatures = node.getCallSignatures(); // 'node' is Type, 'getCallSignatures()' returns Signature[]
let params = signature.getParameters().map(x => {
return {
isOptional : x.getValueDeclarationOrThrow().getQuestionTokenNode() !== undefined // getQuestionTokenNode does not exist.
}
}
}
How to get QuestionToken information for each parameter of getCallSignatures() ?
I can find it in the final result but no method found!

The getValueDeclarationOrThrow() returns a Node type. In this case you should be able to just assert it as a ParameterDeclaration.
Also, there are more ways for a parameter declaration to be optional, so you'll probably want to use the isOptional() helper method, which will handle all the scenarios for you (ex. it could be a rest parameter or have an initializer):
(x.getValueDeclarationOrThrow() as ParameterDeclaration).isOptional()
@dsherret
Is isOptional() helper method available for PropertyDecleration and PropertySignature ?


@HamedFathi no, there's only one way for a property to be optional. There only exists a #hasQuestionToken() method. If an #isOptional() method existed it would just do return this.hasQuestionToken().