Take into account alias type parameters
This commit is contained in:
parent
0da43b0411
commit
78f39517ce
@ -93,11 +93,16 @@ export function typecheck(...argv: string[]) {
|
|||||||
// e.g. string or number types have no symbol
|
// e.g. string or number types have no symbol
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (symbol && !((symbol as any).parent)) {
|
if (symbol && symbol.flags & ts.SymbolFlags.Transient) {
|
||||||
// console.log(' no parent')
|
console.log(' is transient')
|
||||||
// e.g. Array symbol has no parent
|
// Array is transient. not sure if this is the best way to figure this
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// if (symbol && !((symbol as any).parent)) {
|
||||||
|
// // console.log(' no parent', symbol)
|
||||||
|
// // e.g. Array symbol has no parent
|
||||||
|
// return false
|
||||||
|
// }
|
||||||
if (type.isLiteral()) {
|
if (type.isLiteral()) {
|
||||||
// console.log(' is literal')
|
// console.log(' is literal')
|
||||||
return false
|
return false
|
||||||
@ -206,16 +211,16 @@ export function typecheck(...argv: string[]) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// if (type.aliasSymbol) {
|
// if (type.aliasSymbol) {
|
||||||
// TODO figure out how to prevent iterating of properties from types
|
// // TODO figure out how to prevent iterating of properties from types
|
||||||
// such as strings
|
// // such as strings
|
||||||
// return
|
// 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[] = []
|
||||||
|
|
||||||
if (type.isClassOrInterface() && type.typeParameters) {
|
function handleTypeParameters(typeParams: readonly ts.Type[]) {
|
||||||
type.typeParameters.forEach(tp => {
|
typeParams.forEach(tp => {
|
||||||
const constraint = tp.getConstraint()
|
const constraint = tp.getConstraint()
|
||||||
if (constraint) {
|
if (constraint) {
|
||||||
expandedTypeParameters.push(...getAllTypeParameters(tp))
|
expandedTypeParameters.push(...getAllTypeParameters(tp))
|
||||||
@ -229,6 +234,14 @@ export function typecheck(...argv: string[]) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type.isClassOrInterface() && type.typeParameters) {
|
||||||
|
handleTypeParameters(type.typeParameters)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type.aliasSymbol && type.aliasTypeArguments) {
|
||||||
|
handleTypeParameters(type.aliasTypeArguments)
|
||||||
|
}
|
||||||
|
|
||||||
const properties = type.getApparentProperties()
|
const properties = type.getApparentProperties()
|
||||||
|
|
||||||
const filterClassTypeParameters =
|
const filterClassTypeParameters =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user