1
0

typescript-docgen-types.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import ts, { HeritageClause } 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. extendsClause: HeritageClause | undefined;
  43. members: Array<PropertyInfo | MethodInfo>;
  44. }
  45. export interface ClassInfo extends DeclarationInfo {
  46. kind: 'class';
  47. extendsClause: HeritageClause | undefined;
  48. implementsClause: HeritageClause | undefined;
  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 interface VariableInfo extends DeclarationInfo {
  66. kind: 'variable';
  67. }
  68. export type ParsedDeclaration =
  69. | TypeAliasInfo
  70. | ClassInfo
  71. | InterfaceInfo
  72. | EnumInfo
  73. | FunctionInfo
  74. | VariableInfo;
  75. export type ValidDeclaration =
  76. | ts.InterfaceDeclaration
  77. | ts.TypeAliasDeclaration
  78. | ts.ClassDeclaration
  79. | ts.EnumDeclaration
  80. | ts.FunctionDeclaration
  81. | ts.VariableStatement;
  82. export type TypeMap = Map<string, string>;