typescript-docgen-types.ts 1.7 KB

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