Created
June 3, 2019 20:24
-
-
Save Kureev/f94b68d56e8392ff8df7ef683ffebbf7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (ts.isFunctionTypeNode(typeNode)) { | |
let argument: Schemify.TypeAnnotation; | |
this.checker | |
.getSignaturesOfType(type, ts.SignatureKind.Call) | |
/** | |
* At this moment, react-native doesn't support more than one argument | |
* (Event) passed back from the native side, however the implementation | |
* I wrote was designed to support multiple parameters (just in case). | |
* | |
* That said, I assume the "getParameters" to always return an array | |
* of one element (unless the schema in react-native is changed). | |
* Otherwise, the latter one will override the first one | |
*/ | |
.forEach(signature => { | |
signature.getParameters().forEach(parameter => { | |
const paramType = this.checker.getTypeOfSymbolAtLocation( | |
parameter, | |
this.sourceFile | |
); | |
let type: ts.Type; | |
(<any>paramType).typeArguments.forEach((typeArgument: ts.Type) => { | |
typeArgument.getSymbol().members.forEach((member: ts.Symbol) => { | |
type = this.checker.getTypeOfSymbolAtLocation( | |
member, | |
member.valueDeclaration | |
); | |
}); | |
}); | |
argument = this.getTypeAnnotation(type); | |
}); | |
}); | |
return { | |
type: 'FunctionTypeAnnotation', | |
argument, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment