Add support for question tokens in typecheck.ts

This commit is contained in:
Jerko Steiner 2019-08-12 09:08:13 +07:00
parent e55738f547
commit 0ce76eb648

View File

@ -32,6 +32,11 @@ export function typecheck() {
} }
return return
function getAllTypeParameters(type: ts.Type) {
// checker.typeToTypeNode
// ts.isParameterPropertyDeclaration(type.
// if (type.
}
/** visit nodes finding exported classes */ /** visit nodes finding exported classes */
function visit(node: ts.Node) { function visit(node: ts.Node) {
@ -76,14 +81,34 @@ export function typecheck() {
return !(flags & ts.ModifierFlags.NonPublicAccessibilityModifier) return !(flags & ts.ModifierFlags.NonPublicAccessibilityModifier)
}) })
.map(p => { .map(p => {
const vd = p.valueDeclaration
const questionToken = ts.isPropertyDeclaration(vd) && !!vd.questionToken
const propType = checker const propType = checker
.getTypeOfSymbolAtLocation(p, p.valueDeclaration) .getTypeOfSymbolAtLocation(p, p.valueDeclaration)
const s = propType.getSymbol()
if (s) {
// if (ts,
// console.log(' ', p.getName(), checker.getFullyQualifiedName(s))
// s.value
// checker.
// const d = s.getDeclarations()
// if (d) {
// d.forEach(dec => {
// console.log(' ', dec.getText())
// })
// }
}
p.flags
return { return {
name: p.getName(), name: p.getName(),
type: checker.typeToString(propType), type: checker.typeToString(propType),
classOrIface: propType.isClassOrInterface(), questionToken,
union: propType.isUnion(), // classOrIface: propType.isClassOrInterface(),
// union: propType.isUnion(),
} }
})) }))
// output.push(serializeClass(symbol)) // output.push(serializeClass(symbol))