Remove unused comments from typecheck.ts

TODO: figure out how to determine locations of used:

a) interfaces
b) type aliases
c) union types
d) complex types like Array<MyType>

There should be two scenarios:

a) Type is imported from a library
b) Type is imported from an adjacent module
c) Type is privately declared in current module
This commit is contained in:
Jerko Steiner 2019-08-11 23:14:14 +07:00
parent 472c7b3574
commit e55738f547
2 changed files with 12 additions and 25 deletions

View File

@ -53,4 +53,5 @@ export class Typed<A, B extends 'singleVal', C = 'defVal'> {
a!: ITyped<A> a!: ITyped<A>
b!: ITyped<B> b!: ITyped<B>
c!: ITyped<C> c!: ITyped<C>
d!: ITyped<A> | ITyped<B>
} }

View File

@ -44,25 +44,9 @@ export function typecheck() {
// This is a top level class, get its symbol // This is a top level class, get its symbol
const symbol = checker.getSymbolAtLocation(node.name) const symbol = checker.getSymbolAtLocation(node.name)
if (symbol) { if (symbol) {
console.log('===')
console.log('text', node.getText(node.getSourceFile()))
console.log('class', symbol.getName()) console.log('class', symbol.getName())
// console.log('symbolToString', checker.symbolToString(symbol))
// const tpd = checker.symbolToTypeParameterDeclarations(symbol)
// if (tpd) {
// console.log(' type params: %o', tpd.map(t => {
// ts.getCombinedModifierFlags(t.symbol.valueDeclaration)
// return {
// name: t.name.text,
// constraint: !!t.constraint,
// default: !!t.default,
// // constraint: !!t.constraint
// // ? checker.getTypeFromTypeNode(t.constraint)
// // : undefined,
// }
// }))
// }
const type = checker.getDeclaredTypeOfSymbol(symbol) const type = checker.getDeclaredTypeOfSymbol(symbol)
if (type.isClassOrInterface() && type.typeParameters) { if (type.isClassOrInterface() && type.typeParameters) {
@ -70,7 +54,8 @@ export function typecheck() {
console.log(' tp.symbol.name', tp.symbol.name) console.log(' tp.symbol.name', tp.symbol.name)
const constraint = tp.getConstraint() const constraint = tp.getConstraint()
if (constraint) { if (constraint) {
console.log('tp.constraint', checker.typeToString(constraint)) console.log(' tp.constraint',
checker.typeToString(constraint))
} }
const def = tp.getDefault() const def = tp.getDefault()
if (def) { if (def) {
@ -92,21 +77,22 @@ export function typecheck() {
}) })
.map(p => { .map(p => {
const propType = checker const propType = checker
.getTypeOfSymbolAtLocation(p, p.valueDeclaration!) .getTypeOfSymbolAtLocation(p, p.valueDeclaration)
return { return {
name: p.getName(), name: p.getName(),
type: checker.typeToString(propType), type: checker.typeToString(propType),
classOrIface: propType.isClassOrInterface(), classOrIface: propType.isClassOrInterface(),
union: propType.isUnion(),
} }
})) }))
// output.push(serializeClass(symbol)) // output.push(serializeClass(symbol))
} }
// No need to walk any further, class expressions/inner declarations // No need to walk any further, class expressions/inner declarations
// cannot be exported // cannot be exported
} else if (ts.isModuleDeclaration(node)) { // } else if (ts.isModuleDeclaration(node)) {
// This is a namespace, visit its children // // This is a namespace, visit its children
ts.forEachChild(node, visit) // ts.forEachChild(node, visit)
} }
} }