typescript-docgen-types.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import ts from 'typescript';
  2. export interface MethodParameterInfo {
  3. name: string;
  4. type: string;
  5. }
  6. export interface MemberInfo {
  7. name: string;
  8. description: string;
  9. type: string;
  10. fullText: string;
  11. }
  12. export interface PropertyInfo extends MemberInfo {
  13. kind: 'property';
  14. defaultValue: string;
  15. }
  16. export interface MethodInfo extends MemberInfo {
  17. kind: 'method';
  18. parameters: MethodParameterInfo[];
  19. }
  20. export interface DeclarationInfo {
  21. packageName: string;
  22. sourceFile: string;
  23. sourceLine: number;
  24. title: string;
  25. fullText: string;
  26. weight: number;
  27. category: string;
  28. description: string;
  29. fileName: string;
  30. }
  31. export interface InterfaceInfo extends DeclarationInfo {
  32. kind: 'interface';
  33. extends?: string;
  34. members: Array<PropertyInfo | MethodInfo>;
  35. }
  36. export interface ClassInfo extends DeclarationInfo {
  37. kind: 'class';
  38. implements?: string;
  39. extends?: string;
  40. members: Array<PropertyInfo | MethodInfo>;
  41. }
  42. export interface TypeAliasInfo extends DeclarationInfo {
  43. kind: 'typeAlias';
  44. members?: Array<PropertyInfo | MethodInfo>;
  45. type: ts.TypeNode;
  46. }
  47. export interface EnumInfo extends DeclarationInfo {
  48. kind: 'enum';
  49. members: PropertyInfo[];
  50. }
  51. export interface FunctionInfo extends DeclarationInfo {
  52. kind: 'function';
  53. parameters: MethodParameterInfo[];
  54. type?: ts.TypeNode;
  55. }
  56. export type ParsedDeclaration = TypeAliasInfo | ClassInfo | InterfaceInfo | EnumInfo | FunctionInfo;
  57. export type ValidDeclaration = ts.InterfaceDeclaration | ts.TypeAliasDeclaration | ts.ClassDeclaration | ts.EnumDeclaration | ts.FunctionDeclaration;
  58. export type TypeMap = Map<string, string>;