getdocs2ts
Version:
This is a utility that transforms code documented with getdocs-style doc comments into TypeScript definition files
59 lines (58 loc) • 1.59 kB
TypeScript
export interface FunctionType {
type: "Function";
id?: string;
params?: Parameter[];
returns?: ReturnType;
}
export interface ArrayType {
type: "Array";
typeParams: [Type];
}
export interface ObjectType {
type: "Object";
properties: {
[propertyName: string]: Property;
};
}
export interface OtherType {
type: string;
typeParams?: Type[];
}
export declare type Type = FunctionType | ArrayType | ObjectType | OtherType;
export interface ParameterArgs {
rest?: boolean;
name?: string;
optional?: boolean;
}
export declare type Parameter = Type & ParameterArgs;
export declare type ReturnType = Type & {
optional?: boolean;
};
export declare type Property = Type & {
optional?: boolean;
};
export declare function isFunction(t: Type): t is FunctionType;
export declare function isArray(t: Type): t is ArrayType;
export declare function isObject(t: Type): t is ObjectType;
export declare function isOther(t: Type): t is OtherType;
export interface ClassOrInterfaceDeclaration {
type: "class" | "interface";
typeParams?: Type[];
extends?: Type;
properties?: {
[propName: string]: Property;
};
staticProperties?: {
[propName: string]: Property;
};
}
export declare type Declaration = ClassOrInterfaceDeclaration | Type;
export declare function isClassOrInterfaceDeclaration(decl: Declaration): decl is ClassOrInterfaceDeclaration;
export interface ModuleContents {
items?: {
[name: string]: Declaration;
};
all?: {
[id: string]: Declaration;
};
}