
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
@hubspot/ts-export-types-reader
Advanced tools
Types and utilities for working with generated API types
Companion package to @hubspot/ts-export-types for consuming and traversing analyzed type information.
Overview • Installation • Usage • API Reference
This package provides TypeScript types and utilities for working with the type information generated by @hubspot/ts-export-types. It includes:
ApiNode types representing exports, functions, classes, properties, and moreApiNode types safelynpm install @hubspot/ts-export-types-reader
import {
type AnalyzePackageResult,
createAnalyzeResultReader,
} from '@hubspot/ts-export-types-reader';
// Load your generated API types (from @hubspot/ts-export-types output)
import apiData from './api/api.json';
const api = createAnalyzeResultReader(apiData as AnalyzePackageResult);
// Find an export by name
const myFunction = api.findExportByName({
exportPath: '.',
exportName: 'myFunction',
});
// Find a referenced type by its ID
const myType = api.findReferencedTypeById('MyType:my-package:dist/index.d.ts');
import {
type ApiNode,
isFunctionNode,
isObjectNode,
isTypeReferenceNode,
isUnionNode,
} from '@hubspot/ts-export-types-reader';
function processNode(node: ApiNode) {
if (isFunctionNode(node)) {
console.log('Function parameters:', node.parameters);
console.log('Return type:', node.returnType);
}
if (isObjectNode(node)) {
node.properties.forEach((prop) => {
console.log(`Property: ${prop.name}`);
});
}
if (isUnionNode(node)) {
node.types.forEach(processNode);
}
if (isTypeReferenceNode(node)) {
console.log('References type:', node.typeId);
}
}
import {
type AnalyzePackageResult,
type ApiNode,
createAnalyzeResultReader,
isTypeReferenceNode,
} from '@hubspot/ts-export-types-reader';
function collectAllTypeIds(
api: ReturnType<typeof createAnalyzeResultReader>,
node: ApiNode,
visited = new Set<string>()
): string[] {
const typeIds: string[] = [];
if (isTypeReferenceNode(node)) {
if (!visited.has(node.typeId)) {
visited.add(node.typeId);
typeIds.push(node.typeId);
const referencedType = api.findReferencedTypeById(node.typeId);
typeIds.push(...collectAllTypeIds(api, referencedType, visited));
}
}
return typeIds;
}
createAnalyzeResultReader(result: AnalyzePackageResult): AnalyzeResultExportCreates a helper object for querying analyze results.
interface AnalyzeResultExport {
findExportByName(options: FindExportByNameOptions): ExportNode;
findReferencedTypeById(typeId: string): ApiNode;
}
interface FindExportByNameOptions {
exportPath: string; // e.g., "." or "./utils"
exportName: string; // e.g., "myFunction"
}
AnalyzePackageResultThe root type for analyze output:
interface AnalyzePackageResult {
exports: Record<string, ExportNode[]>;
types: Record<string, ApiNode>;
}
ApiNodeUnion of all possible node types:
type ApiNode =
| ArrayNode
| BuiltInTypeReferenceNode
| ClassNode
| ConditionalNode
| ConstructorNode
| ExportNode
| ExternalTypeReferenceNode
| FunctionNode
| InlinedTypeReferenceNode
| IntersectionNode
| LiteralNode
| MappedTypeNode
| MethodNode
| ObjectNode
| ParameterNode
| PrimitiveNode
| PropertyNode
| TupleElementNode
| TupleNode
| TypeParameterNode
| TypeReferenceNode
| UnionNode
| UnknownNode;
ApiNodeKindConstants for all node kinds:
const ApiNodeKind = {
Array: 'array',
BuiltInTypeReference: 'built-in-type-reference',
Class: 'class',
Conditional: 'conditional',
Constructor: 'constructor',
Export: 'export',
ExternalTypeReference: 'external-type-reference',
Function: 'function',
InlinedTypeReference: 'inlined-type-reference',
Intersection: 'intersection',
Literal: 'literal',
MappedType: 'mapped-type',
Method: 'method',
Object: 'object',
Parameter: 'parameter',
Primitive: 'primitive',
Property: 'property',
Tuple: 'tuple',
TupleElement: 'tuple-element',
TypeParameter: 'type-parameter',
TypeReference: 'type-reference',
Union: 'union',
Unknown: 'unknown',
} as const;
All type guards follow the pattern is{NodeType}(node: ApiNode): node is {NodeType}:
| Function | Narrows to |
|---|---|
isArrayNode | ArrayNode |
isBuiltInTypeReferenceNode | BuiltInTypeReferenceNode |
isClassNode | ClassNode |
isConditionalNode | ConditionalNode |
isConstructorNode | ConstructorNode |
isExportNode | ExportNode |
isExternalTypeReferenceNode | ExternalTypeReferenceNode |
isFunctionNode | FunctionNode |
isInlinedTypeReferenceNode | InlinedTypeReferenceNode |
isIntersectionNode | IntersectionNode |
isLiteralNode | LiteralNode |
isMappedTypeNode | MappedTypeNode |
isMethodNode | MethodNode |
isObjectNode | ObjectNode |
isParameterNode | ParameterNode |
isPrimitiveNode | PrimitiveNode |
isPropertyNode | PropertyNode |
isTupleElementNode | TupleElementNode |
isTupleNode | TupleNode |
isTypeParameterNode | TypeParameterNode |
isTypeReferenceNode | TypeReferenceNode |
isUnionNode | UnionNode |
isUnknownNode | UnknownNode |
ExportNodeRepresents an exported symbol:
interface ExportNode {
kind: 'export';
exportName: string;
declarationKind: ExportDeclarationKind;
isType?: boolean;
isDefault?: boolean;
type: ApiNode;
jsdoc?: Jsdoc;
}
type ExportDeclarationKind =
| 'const'
| 'let'
| 'var'
| 'function'
| 'class'
| 'type'
| 'interface'
| 'enum';
FunctionNodeRepresents a function type:
interface FunctionNode {
kind: 'function';
functionKind: FunctionKind;
parameters: ParameterNode[];
returnType: ApiNode;
typeParameters?: TypeParameterNode[];
name?: string;
isAsync?: boolean;
jsdoc?: Jsdoc;
}
type FunctionKind = 'arrow' | 'expression' | 'declaration' | 'call-signature';
ClassNodeRepresents a class:
interface ClassNode {
kind: 'class';
name?: string;
isAbstract: boolean;
typeParameters?: TypeParameterNode[];
implements?: ApiNode[];
constructors: ConstructorNode[];
properties: PropertyNode[];
methods: MethodNode[];
staticProperties: PropertyNode[];
staticMethods: MethodNode[];
jsdoc?: Jsdoc;
}
TypeReferenceNodeReferences a type defined in the types map:
interface TypeReferenceNode {
kind: 'type-reference';
typeId: string;
typeString: string;
typeArguments?: ApiNode[];
}
ExternalTypeReferenceNodeReferences a type from an external package:
interface ExternalTypeReferenceNode {
kind: 'external-type-reference';
typeName: string;
typeString: string;
packageName: string;
packageVersion: string;
typeArguments?: ApiNode[];
}
MIT © HubSpot
FAQs
Reader utilities for the @hubspot/ts-export-types package
We found that @hubspot/ts-export-types-reader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 39 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.