(type: ts.Type)
| 229 | } |
| 230 | |
| 231 | function serializeType(type: ts.Type) { |
| 232 | if (type.isUnionOrIntersection()) { |
| 233 | type.types.forEach((subType) => { |
| 234 | serializeType(subType) |
| 235 | }) |
| 236 | if (type.aliasSymbol) { |
| 237 | serializeAliasType(type.aliasSymbol) |
| 238 | } |
| 239 | return |
| 240 | } |
| 241 | let typeName = '' |
| 242 | if (type.getSymbol()) { |
| 243 | typeName = type.getSymbol().name |
| 244 | if (type.getSymbol().name === 'globalThis') { |
| 245 | // Don't load globalThis, it contains mostly duplicates of Window |
| 246 | return |
| 247 | } |
| 248 | } else { |
| 249 | console.log('literal:', type.isLiteral()) |
| 250 | return |
| 251 | } |
| 252 | |
| 253 | if (seenTypes.has(typeName)) { |
| 254 | return |
| 255 | } |
| 256 | seenTypes.add(typeName) |
| 257 | |
| 258 | const typeDec = { |
| 259 | properties: [], |
| 260 | methods: [], |
| 261 | } as TypeDefinition |
| 262 | |
| 263 | typeDec.name = typeName |
| 264 | type.getConstructSignatures().forEach((signature) => { |
| 265 | const params = signature.getDeclaration().parameters.map((paramDeclaration) => { |
| 266 | return { |
| 267 | name: paramDeclaration.name.getText(), |
| 268 | type: serializeTypeExpression(paramDeclaration.type), |
| 269 | deprecated: false, |
| 270 | documentation: '', |
| 271 | } |
| 272 | }) |
| 273 | typeDec.constructorParams = params |
| 274 | }) |
| 275 | type.getProperties().forEach((propertySymbol) => { |
| 276 | // Documentation |
| 277 | const documentation = serializeDocumentation(propertySymbol.getDocumentationComment(checker)) |
| 278 | // Is deprecated |
| 279 | let deprecated = false |
| 280 | propertySymbol.getJsDocTags().forEach((tagInfo) => { |
| 281 | if (tagInfo.name === 'deprecated') { |
| 282 | deprecated = true |
| 283 | } |
| 284 | }) |
| 285 | if (!propertySymbol.valueDeclaration) { |
| 286 | return |
| 287 | } |
| 288 | if (ts.isPropertySignature(propertySymbol.valueDeclaration)) { |
no test coverage detected