Clean up comments

This commit is contained in:
Jerko Steiner 2019-08-12 12:33:49 +07:00
parent aa78b12e54
commit 3ba279a0ab

View File

@ -10,18 +10,8 @@ function isTypeReference(type: ts.ObjectType): type is ts.TypeReference {
} }
export function typecheck() { export function typecheck() {
interface DocEntry { /** Generate interfaces for all exported classes in a set of .ts files */
name?: string function generateInterfaces(
fileName?: string
documentation?: string
type?: string
constructors?: DocEntry[]
parameters?: DocEntry[]
returnType?: string
}
/** Generate documentation for all classes in a set of .ts files */
function generateDocumentation(
fileNames: string[], fileNames: string[],
options: ts.CompilerOptions, options: ts.CompilerOptions,
): void { ): void {
@ -71,16 +61,7 @@ export function typecheck() {
} }
function getAllTypeParameters(type: ts.Type): ts.Type[] { function getAllTypeParameters(type: ts.Type): ts.Type[] {
// console.log('TTT', checker.typeToString(type), if (isObjectType(type) && isTypeReference(type)) {
// {
// isObject: !!(type.flags & ts.TypeFlags.Object),
// isTuple: (type as any).objectFlags & ts.ObjectFlags.Tuple,
// typeFlags: type.flags,
// objectFlags: (type as any).objectFlags,
// },
// )
if (isObjectType(type)) {
if (isTypeReference(type)) {
const types: ts.Type[] = [type] const types: ts.Type[] = [type]
if (type.typeArguments) { if (type.typeArguments) {
@ -91,10 +72,8 @@ export function typecheck() {
} }
return types return types
} }
}
if (type.isUnionOrIntersection()) { if (type.isUnionOrIntersection()) {
// console.log('TTT isUnionOrIntersection')
const unionOrIntersectionTypes = type.types const unionOrIntersectionTypes = type.types
// const types = [type, ...type.types] // const types = [type, ...type.types]
const types: ts.Type[] = [type] const types: ts.Type[] = [type]
@ -105,12 +84,8 @@ export function typecheck() {
return types return types
} }
// type.
if (type.isClassOrInterface()) { if (type.isClassOrInterface()) {
// console.log('TTT isClassOrInterface')
if (type.typeParameters) { if (type.typeParameters) {
// console.log('TTT typeParameters')
const types = [type, ...type.typeParameters] const types = [type, ...type.typeParameters]
type.typeParameters.forEach(t => { type.typeParameters.forEach(t => {
const tsp = getAllTypeParameters(t) const tsp = getAllTypeParameters(t)
@ -121,13 +96,6 @@ export function typecheck() {
return [type] return [type]
} }
// if (type.isIntersection()) {
// }
// if (type.isTypeParameter()) {
// console.log('AAAAAAAAAAAAAAAAAAAAAAAAAAAA')
// }
return [type] return [type]
} }
@ -174,14 +142,12 @@ export function typecheck() {
console.log(' %o', properties console.log(' %o', properties
.filter(p => { .filter(p => {
const flags = ts.getCombinedModifierFlags(p.valueDeclaration) const flags = ts.getCombinedModifierFlags(p.valueDeclaration)
// return s.parent && s.parent.flags & 32 /* Class */
// ? flags
// : flags & ~28 /* AccessibilityModifier */;
return !(flags & ts.ModifierFlags.NonPublicAccessibilityModifier) return !(flags & ts.ModifierFlags.NonPublicAccessibilityModifier)
}) })
.map(p => { .map(p => {
const vd = p.valueDeclaration const vd = p.valueDeclaration
const questionToken = ts.isPropertyDeclaration(vd) && !!vd.questionToken const questionToken =
ts.isPropertyDeclaration(vd) && !!vd.questionToken
const propType = checker const propType = checker
.getTypeOfSymbolAtLocation(p, p.valueDeclaration) .getTypeOfSymbolAtLocation(p, p.valueDeclaration)
@ -201,13 +167,7 @@ export function typecheck() {
.map(typeToString), .map(typeToString),
} }
})) }))
// output.push(serializeClass(symbol))
} }
// No need to walk any further, class expressions/inner declarations
// cannot be exported
// } else if (ts.isModuleDeclaration(node)) {
// // This is a namespace, visit its children
// ts.forEachChild(node, visit)
} }
} }
@ -222,7 +182,7 @@ export function typecheck() {
} }
const path = __dirname + '/' + 'intergen.sample.ts' const path = __dirname + '/' + 'intergen.sample.ts'
generateDocumentation([path], { generateInterfaces([path], {
target: ts.ScriptTarget.ES5, target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS, module: ts.ModuleKind.CommonJS,
}) })