From 0da43b041188c5cba4b8f4e2d4f4a689bbd6d8d6 Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Tue, 13 Aug 2019 10:01:21 +0700 Subject: [PATCH] Fix iterating over non-filtered array --- packages/scripts/src/commands/intergen.sample.ts | 5 +++-- packages/scripts/src/commands/typecheck.ts | 15 ++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/scripts/src/commands/intergen.sample.ts b/packages/scripts/src/commands/intergen.sample.ts index 7d4b7f0..d10ccdb 100644 --- a/packages/scripts/src/commands/intergen.sample.ts +++ b/packages/scripts/src/commands/intergen.sample.ts @@ -18,7 +18,7 @@ export class Name { } export interface IYear { - yeak: number + year: number } export interface ITyped { @@ -26,8 +26,9 @@ export interface ITyped { } type AorB = 'A' | 'B' +interface IB { a: number } /* tslint:disable-next-line */ -type Param = {t: T} +type Param = {t: T, b: IB} export class Person { readonly name!: Name diff --git a/packages/scripts/src/commands/typecheck.ts b/packages/scripts/src/commands/typecheck.ts index a0d0b1d..bceda57 100644 --- a/packages/scripts/src/commands/typecheck.ts +++ b/packages/scripts/src/commands/typecheck.ts @@ -205,6 +205,11 @@ export function typecheck(...argv: string[]) { if (typeDefinitions.has(type)) { return } + // if (type.aliasSymbol) { + // TODO figure out how to prevent iterating of properties from types + // such as strings + // return + // } const typeParameters: ts.TypeParameter[] = [] const expandedTypeParameters: ts.Type[] = [] const allRelevantTypes: ts.Type[] = [] @@ -278,19 +283,19 @@ export function typecheck(...argv: string[]) { console.log(`interface ${classDef.name} {`) console.log(' ', classDef.properties - .map(p => p.name + ': ' + typeToString(p.type)) // + ' {' + - // p.relevantTypes.map(typeToString) + '}') + .map(p => p.name + ': ' + typeToString(p.type) + ' {' + + p.relevantTypes.map(typeToString) + '}') .join('\n '), ) console.log('}') - // console.log('\n allRelevantTypes:\n ', - // classDef.allRelevantTypes.map(typeToString).join('\n ')) + console.log('\n allRelevantTypes:\n ', + classDef.allRelevantTypes.map(typeToString).join('\n ')) console.log('\n') classDefs.push(classDef) typeDefinitions.set(type, classDef) - allRelevantTypes.map(handleType) + classDef.allRelevantTypes.forEach(handleType) } /**