typescript-docgen-types.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 DocsPage {
  24. title: string;
  25. category: string;
  26. declarations: ParsedDeclaration[];
  27. fileName: string;
  28. }
  29. export interface DeclarationInfo {
  30. packageName: string;
  31. sourceFile: string;
  32. sourceLine: number;
  33. title: string;
  34. fullText: string;
  35. weight: number;
  36. category: string;
  37. description: string;
  38. page: string | undefined;
  39. }
  40. export interface InterfaceInfo extends DeclarationInfo {
  41. kind: 'interface';
  42. extends?: string;
  43. members: Array<PropertyInfo | MethodInfo>;
  44. }
  45. export interface ClassInfo extends DeclarationInfo {
  46. kind: 'class';
  47. implements?: string;
  48. extends?: string;
  49. members: Array<PropertyInfo | MethodInfo>;
  50. }
  51. export interface TypeAliasInfo extends DeclarationInfo {
  52. kind: 'typeAlias';
  53. members?: Array<PropertyInfo | MethodInfo>;
  54. type: ts.TypeNode;
  55. }
  56. export interface EnumInfo extends DeclarationInfo {
  57. kind: 'enum';
  58. members: PropertyInfo[];
  59. }
  60. export interface FunctionInfo extends DeclarationInfo {
  61. kind: 'function';
  62. parameters: MethodParameterInfo[];
  63. type?: ts.TypeNode;
  64. }
  65. export type ParsedDeclaration = TypeAliasInfo | ClassInfo | InterfaceInfo | EnumInfo | FunctionInfo;
  66. export type ValidDeclaration = ts.InterfaceDeclaration | ts.TypeAliasDeclaration | ts.ClassDeclaration | ts.EnumDeclaration | ts.FunctionDeclaration;
  67. export type TypeMap = Map<string, string>;