typescript-docgen-types.ts 1.7 KB

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