Fix iterating over non-filtered array

This commit is contained in:
Jerko Steiner 2019-08-13 10:01:21 +07:00
parent 1289913d06
commit 0da43b0411
2 changed files with 13 additions and 7 deletions

View File

@ -18,7 +18,7 @@ export class Name {
} }
export interface IYear { export interface IYear {
yeak: number year: number
} }
export interface ITyped<T> { export interface ITyped<T> {
@ -26,8 +26,9 @@ export interface ITyped<T> {
} }
type AorB = 'A' | 'B' type AorB = 'A' | 'B'
interface IB { a: number }
/* tslint:disable-next-line */ /* tslint:disable-next-line */
type Param<T> = {t: T} type Param<T> = {t: T, b: IB}
export class Person { export class Person {
readonly name!: Name readonly name!: Name

View File

@ -205,6 +205,11 @@ export function typecheck(...argv: string[]) {
if (typeDefinitions.has(type)) { if (typeDefinitions.has(type)) {
return return
} }
// if (type.aliasSymbol) {
// TODO figure out how to prevent iterating of properties from types
// such as strings
// return
// }
const typeParameters: ts.TypeParameter[] = [] const typeParameters: ts.TypeParameter[] = []
const expandedTypeParameters: ts.Type[] = [] const expandedTypeParameters: ts.Type[] = []
const allRelevantTypes: ts.Type[] = [] const allRelevantTypes: ts.Type[] = []
@ -278,19 +283,19 @@ export function typecheck(...argv: string[]) {
console.log(`interface ${classDef.name} {`) console.log(`interface ${classDef.name} {`)
console.log(' ', console.log(' ',
classDef.properties classDef.properties
.map(p => p.name + ': ' + typeToString(p.type)) // + ' {' + .map(p => p.name + ': ' + typeToString(p.type) + ' {' +
// p.relevantTypes.map(typeToString) + '}') p.relevantTypes.map(typeToString) + '}')
.join('\n '), .join('\n '),
) )
console.log('}') console.log('}')
// console.log('\n allRelevantTypes:\n ', console.log('\n allRelevantTypes:\n ',
// classDef.allRelevantTypes.map(typeToString).join('\n ')) classDef.allRelevantTypes.map(typeToString).join('\n '))
console.log('\n') console.log('\n')
classDefs.push(classDef) classDefs.push(classDef)
typeDefinitions.set(type, classDef) typeDefinitions.set(type, classDef)
allRelevantTypes.map(handleType) classDef.allRelevantTypes.forEach(handleType)
} }
/** /**