@goast/typescript 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/dist/src/assets.d.ts +18 -0
  2. package/dist/src/assets.js +18 -0
  3. package/dist/src/ast/common.d.ts +6 -0
  4. package/dist/src/ast/node.d.ts +15 -0
  5. package/dist/src/ast/node.js +15 -0
  6. package/dist/src/ast/nodes/argument.d.ts +31 -0
  7. package/dist/src/ast/nodes/argument.js +31 -0
  8. package/dist/src/ast/nodes/array-type.d.ts +32 -0
  9. package/dist/src/ast/nodes/array-type.js +32 -0
  10. package/dist/src/ast/nodes/arrow-function.d.ts +56 -0
  11. package/dist/src/ast/nodes/arrow-function.js +56 -0
  12. package/dist/src/ast/nodes/call.d.ts +34 -0
  13. package/dist/src/ast/nodes/call.js +34 -0
  14. package/dist/src/ast/nodes/class.d.ts +73 -0
  15. package/dist/src/ast/nodes/class.js +73 -0
  16. package/dist/src/ast/nodes/constructor-parameter.d.ts +37 -0
  17. package/dist/src/ast/nodes/constructor-parameter.js +37 -0
  18. package/dist/src/ast/nodes/constructor.d.ts +44 -0
  19. package/dist/src/ast/nodes/constructor.js +44 -0
  20. package/dist/src/ast/nodes/decorator.d.ts +35 -0
  21. package/dist/src/ast/nodes/decorator.js +35 -0
  22. package/dist/src/ast/nodes/doc-tag.d.ts +39 -0
  23. package/dist/src/ast/nodes/doc-tag.js +39 -0
  24. package/dist/src/ast/nodes/doc.d.ts +38 -0
  25. package/dist/src/ast/nodes/doc.js +38 -0
  26. package/dist/src/ast/nodes/enum-value.d.ts +37 -0
  27. package/dist/src/ast/nodes/enum-value.js +37 -0
  28. package/dist/src/ast/nodes/enum.d.ts +47 -0
  29. package/dist/src/ast/nodes/enum.js +47 -0
  30. package/dist/src/ast/nodes/export.d.ts +51 -0
  31. package/dist/src/ast/nodes/export.js +51 -0
  32. package/dist/src/ast/nodes/function-type.d.ts +35 -0
  33. package/dist/src/ast/nodes/function-type.js +35 -0
  34. package/dist/src/ast/nodes/function.d.ts +61 -0
  35. package/dist/src/ast/nodes/function.js +61 -0
  36. package/dist/src/ast/nodes/generic-parameter.d.ts +44 -0
  37. package/dist/src/ast/nodes/generic-parameter.js +44 -0
  38. package/dist/src/ast/nodes/indexer.d.ts +41 -0
  39. package/dist/src/ast/nodes/indexer.js +41 -0
  40. package/dist/src/ast/nodes/interface.d.ts +57 -0
  41. package/dist/src/ast/nodes/interface.js +57 -0
  42. package/dist/src/ast/nodes/intersection-type.d.ts +32 -0
  43. package/dist/src/ast/nodes/intersection-type.js +32 -0
  44. package/dist/src/ast/nodes/lookup-type.d.ts +34 -0
  45. package/dist/src/ast/nodes/lookup-type.js +34 -0
  46. package/dist/src/ast/nodes/method.d.ts +90 -0
  47. package/dist/src/ast/nodes/method.js +90 -0
  48. package/dist/src/ast/nodes/object-type.d.ts +34 -0
  49. package/dist/src/ast/nodes/object-type.js +34 -0
  50. package/dist/src/ast/nodes/object.d.ts +34 -0
  51. package/dist/src/ast/nodes/object.js +34 -0
  52. package/dist/src/ast/nodes/parameter.d.ts +51 -0
  53. package/dist/src/ast/nodes/parameter.js +51 -0
  54. package/dist/src/ast/nodes/property-accessor.d.ts +94 -0
  55. package/dist/src/ast/nodes/property-accessor.js +94 -0
  56. package/dist/src/ast/nodes/property.d.ts +113 -0
  57. package/dist/src/ast/nodes/property.js +113 -0
  58. package/dist/src/ast/nodes/reference.d.ts +90 -0
  59. package/dist/src/ast/nodes/reference.js +66 -0
  60. package/dist/src/ast/nodes/string.d.ts +35 -0
  61. package/dist/src/ast/nodes/string.js +35 -0
  62. package/dist/src/ast/nodes/tuple.d.ts +33 -0
  63. package/dist/src/ast/nodes/tuple.js +33 -0
  64. package/dist/src/ast/nodes/type-alias.d.ts +44 -0
  65. package/dist/src/ast/nodes/type-alias.js +44 -0
  66. package/dist/src/ast/nodes/typeof.d.ts +41 -0
  67. package/dist/src/ast/nodes/typeof.js +41 -0
  68. package/dist/src/ast/nodes/types.d.ts +12 -0
  69. package/dist/src/ast/nodes/union-type.d.ts +31 -0
  70. package/dist/src/ast/nodes/union-type.js +31 -0
  71. package/dist/src/ast/nodes/variable.d.ts +46 -0
  72. package/dist/src/ast/nodes/variable.js +46 -0
  73. package/dist/src/ast/references/angular.d.ts +7 -0
  74. package/dist/src/ast/references/angular.js +7 -0
  75. package/dist/src/ast/references/easy-network-stub.d.ts +4 -0
  76. package/dist/src/ast/references/easy-network-stub.js +4 -0
  77. package/dist/src/ast/references/k6.d.ts +3 -0
  78. package/dist/src/ast/references/k6.js +3 -0
  79. package/dist/src/ast/references/rxjs.d.ts +5 -0
  80. package/dist/src/ast/references/rxjs.js +5 -0
  81. package/dist/src/ast/references/typescript.d.ts +30 -0
  82. package/dist/src/ast/references/typescript.js +30 -0
  83. package/dist/src/ast/utils/get-type-script-builder-options.d.ts +8 -0
  84. package/dist/src/ast/utils/get-type-script-builder-options.js +8 -0
  85. package/dist/src/ast/utils/to-ts-node.d.ts +28 -0
  86. package/dist/src/ast/utils/write-ts-generic-parameters.d.ts +9 -0
  87. package/dist/src/ast/utils/write-ts-generic-parameters.js +9 -0
  88. package/dist/src/ast/utils/write-ts-members.d.ts +12 -0
  89. package/dist/src/ast/utils/write-ts-members.js +12 -0
  90. package/dist/src/ast/utils/write-ts-nodes.d.ts +16 -0
  91. package/dist/src/ast/utils/write-ts-nodes.js +16 -0
  92. package/dist/src/ast/utils/write-ts-parameters.d.ts +9 -0
  93. package/dist/src/ast/utils/write-ts-parameters.js +9 -0
  94. package/dist/src/common-results.d.ts +65 -0
  95. package/dist/src/config.d.ts +32 -0
  96. package/dist/src/config.js +5 -0
  97. package/dist/src/file-builder.d.ts +104 -0
  98. package/dist/src/file-builder.js +93 -0
  99. package/dist/src/generators/file-generator.d.ts +14 -0
  100. package/dist/src/generators/file-generator.js +9 -0
  101. package/dist/src/generators/models/model-generator.d.ts +24 -0
  102. package/dist/src/generators/models/model-generator.js +15 -0
  103. package/dist/src/generators/models/models-generator.d.ts +16 -0
  104. package/dist/src/generators/models/models-generator.js +16 -0
  105. package/dist/src/generators/models/models.d.ts +53 -0
  106. package/dist/src/generators/models/models.js +8 -0
  107. package/dist/src/generators/services/angular-services/angular-service-generator.d.ts +27 -0
  108. package/dist/src/generators/services/angular-services/angular-service-generator.js +17 -0
  109. package/dist/src/generators/services/angular-services/angular-services-generator.d.ts +21 -0
  110. package/dist/src/generators/services/angular-services/angular-services-generator.js +21 -0
  111. package/dist/src/generators/services/angular-services/models.d.ts +70 -1
  112. package/dist/src/generators/services/angular-services/models.js +5 -0
  113. package/dist/src/generators/services/angular-services/refs.d.ts +11 -0
  114. package/dist/src/generators/services/angular-services/refs.js +11 -0
  115. package/dist/src/generators/services/easy-network-stub/easy-network-stub-generator.d.ts +22 -0
  116. package/dist/src/generators/services/easy-network-stub/easy-network-stub-generator.js +12 -0
  117. package/dist/src/generators/services/easy-network-stub/easy-network-stubs-generator.d.ts +16 -0
  118. package/dist/src/generators/services/easy-network-stub/easy-network-stubs-generator.js +16 -0
  119. package/dist/src/generators/services/easy-network-stub/models.d.ts +61 -0
  120. package/dist/src/generators/services/easy-network-stub/models.js +5 -0
  121. package/dist/src/generators/services/easy-network-stub/refs.d.ts +7 -0
  122. package/dist/src/generators/services/easy-network-stub/refs.js +7 -0
  123. package/dist/src/generators/services/fetch-clients/fetch-client-generator.d.ts +22 -0
  124. package/dist/src/generators/services/fetch-clients/fetch-client-generator.js +12 -0
  125. package/dist/src/generators/services/fetch-clients/fetch-clients-generator.d.ts +17 -0
  126. package/dist/src/generators/services/fetch-clients/fetch-clients-generator.js +17 -0
  127. package/dist/src/generators/services/fetch-clients/models.d.ts +64 -1
  128. package/dist/src/generators/services/fetch-clients/models.js +5 -0
  129. package/dist/src/generators/services/fetch-clients/refs.d.ts +7 -0
  130. package/dist/src/generators/services/fetch-clients/refs.js +7 -0
  131. package/dist/src/generators/services/k6-clients/k6-client-generator.d.ts +21 -0
  132. package/dist/src/generators/services/k6-clients/k6-client-generator.js +11 -0
  133. package/dist/src/generators/services/k6-clients/k6-clients-generator.d.ts +18 -0
  134. package/dist/src/generators/services/k6-clients/k6-clients-generator.js +18 -0
  135. package/dist/src/generators/services/k6-clients/models.d.ts +65 -1
  136. package/dist/src/generators/services/k6-clients/models.js +5 -0
  137. package/dist/src/generators/services/k6-clients/refs.d.ts +8 -0
  138. package/dist/src/generators/services/k6-clients/refs.js +8 -0
  139. package/dist/src/import-collection.d.ts +81 -0
  140. package/dist/src/import-collection.js +58 -0
  141. package/dist/src/utils.d.ts +62 -0
  142. package/dist/src/utils.js +47 -0
  143. package/package.json +2 -2
@@ -14,5 +14,17 @@ import type { TsString } from './string.ts';
14
14
  import type { TsTuple } from './tuple.ts';
15
15
  import type { TsTypeof } from './typeof.ts';
16
16
  import type { TsUnionType } from './union-type.ts';
17
+ /**
18
+ * A type that can be written in a type position, such as a type annotation, a generic argument or a union member.
19
+ * Plain strings and other append values are written as they are.
20
+ *
21
+ * @template TBuilder The type of the source builder the type is written to.
22
+ */
17
23
  export type TsType<TBuilder extends SourceBuilder> = BasicAppendValue<TBuilder> | TsIntersectionType<TBuilder> | TsUnionType<TBuilder> | TsArrayType<TBuilder> | TsTuple<TBuilder> | TsFunctionType<TBuilder> | TsObjectType<TBuilder> | TsString<TBuilder> | TsLookupType<TBuilder> | TsTypeof<TBuilder> | TsReference<TBuilder>;
24
+ /**
25
+ * A value that can be written in an expression position, such as the initial value of a variable or the default value
26
+ * of a parameter. Plain strings and other append values are written as they are.
27
+ *
28
+ * @template TBuilder The type of the source builder the value is written to.
29
+ */
18
30
  export type TsValue<TBuilder extends SourceBuilder> = BasicAppendValue<TBuilder> | TsObject<TBuilder> | TsTuple<TBuilder> | TsString<TBuilder> | TsArrowFunction<TBuilder> | TsFunction<TBuilder> | TsClass<TBuilder> | TsCall<TBuilder> | TsReference<TBuilder>;
@@ -6,12 +6,43 @@ type Injects = never;
6
6
  type Options<TBuilder extends SourceBuilder, TInjects extends string = never> = AstNodeOptions<typeof TsNode<TBuilder, TInjects | Injects>, {
7
7
  types: Nullable<TsType<TBuilder>>[];
8
8
  }>;
9
+ /**
10
+ * Represents a union type, which combines alternative types with `|`, such as `(string) | (number)`.
11
+ *
12
+ * Each type is wrapped in parentheses. Nested union types are flattened into the same list. A union without types is
13
+ * written as `never`, and one with a single type is written as that type without parentheses. Unions of more than three
14
+ * types are written with one type per line, and each line starts with `|`.
15
+ *
16
+ * @template TBuilder The type of the source builder the union type is written to.
17
+ * @template TInjects Additional names of custom injection points (`before*` and `after*`) accepted by this node.
18
+ * @see tsUnionType
19
+ */
9
20
  export declare class TsUnionType<TBuilder extends SourceBuilder, TInjects extends string = never> extends TsNode<TBuilder, TInjects | Injects> {
21
+ /**
22
+ * The alternative types, in the given order. Null entries are skipped. Nested union types are flattened into this
23
+ * list when the node is written, so they add no nested parentheses.
24
+ */
10
25
  types: TsType<TBuilder>[];
26
+ /**
27
+ * Initializes a new instance of the TsUnionType class.
28
+ * @param options The options to use for this instance.
29
+ */
11
30
  constructor(options: Options<TBuilder, TInjects>);
12
31
  protected onWrite(builder: TBuilder): void;
13
32
  }
14
33
  declare const createUnionType: <TBuilder extends SourceBuilder>(types: Options<TBuilder>['types'], options?: Prettify<Omit<Options<TBuilder>, 'types'>>) => TsUnionType<TBuilder>;
34
+ /**
35
+ * Factory for creating union type nodes. The `write` function writes one or more union type nodes to a builder.
36
+ *
37
+ * @param types The alternative types. See `TsUnionType.types` for how they are written.
38
+ * @param options The settings of the union type. See `TsUnionType` for the available properties.
39
+ * @example
40
+ * ```ts
41
+ * tsUnionType(['string', 'number']);
42
+ * // Emits:
43
+ * // (string) | (number)
44
+ * ```
45
+ */
15
46
  export declare const tsUnionType: typeof createUnionType & {
16
47
  write: typeof writeTsNodes;
17
48
  };
@@ -1,8 +1,27 @@
1
1
  import { notNullish } from '@goast/core';
2
2
  import { TsNode } from '../node.js';
3
3
  import { writeTsNode, writeTsNodes } from '../utils/write-ts-nodes.js';
4
+ /**
5
+ * Represents a union type, which combines alternative types with `|`, such as `(string) | (number)`.
6
+ *
7
+ * Each type is wrapped in parentheses. Nested union types are flattened into the same list. A union without types is
8
+ * written as `never`, and one with a single type is written as that type without parentheses. Unions of more than three
9
+ * types are written with one type per line, and each line starts with `|`.
10
+ *
11
+ * @template TBuilder The type of the source builder the union type is written to.
12
+ * @template TInjects Additional names of custom injection points (`before*` and `after*`) accepted by this node.
13
+ * @see tsUnionType
14
+ */
4
15
  export class TsUnionType extends TsNode {
16
+ /**
17
+ * The alternative types, in the given order. Null entries are skipped. Nested union types are flattened into this
18
+ * list when the node is written, so they add no nested parentheses.
19
+ */
5
20
  types;
21
+ /**
22
+ * Initializes a new instance of the TsUnionType class.
23
+ * @param options The options to use for this instance.
24
+ */
6
25
  constructor(options) {
7
26
  super(options);
8
27
  this.types = options.types.filter(notNullish);
@@ -24,6 +43,18 @@ export class TsUnionType extends TsNode {
24
43
  }
25
44
  }
26
45
  const createUnionType = (types, options) => new TsUnionType({ ...options, types });
46
+ /**
47
+ * Factory for creating union type nodes. The `write` function writes one or more union type nodes to a builder.
48
+ *
49
+ * @param types The alternative types. See `TsUnionType.types` for how they are written.
50
+ * @param options The settings of the union type. See `TsUnionType` for the available properties.
51
+ * @example
52
+ * ```ts
53
+ * tsUnionType(['string', 'number']);
54
+ * // Emits:
55
+ * // (string) | (number)
56
+ * ```
57
+ */
27
58
  export const tsUnionType = Object.assign(createUnionType, {
28
59
  write: writeTsNodes,
29
60
  });
@@ -12,17 +12,63 @@ type Options<TBuilder extends SourceBuilder, TInjects extends string = never> =
12
12
  export?: Nullable<boolean>;
13
13
  readonly?: Nullable<boolean>;
14
14
  }>;
15
+ /**
16
+ * Represents a variable declaration, such as `export const x: number = 42;`.
17
+ *
18
+ * Written in this order: doc comment, `export` keyword, `const` or `let`, name, type annotation, initial value, and a
19
+ * semicolon. A variable is declared with `let` unless `readonly` is set, which declares it with `const`.
20
+ *
21
+ * @template TBuilder The type of the source builder the variable is written to.
22
+ * @template TInjects Additional names of custom injection points (`before*` and `after*`) accepted by this node.
23
+ * @see tsVariable
24
+ */
15
25
  export declare class TsVariable<TBuilder extends SourceBuilder, TInjects extends string = never> extends TsNode<TBuilder, TInjects | Injects> {
26
+ /**
27
+ * The name of the variable, written verbatim after `let` or `const`.
28
+ */
16
29
  name: string;
30
+ /**
31
+ * The doc comment written above the declaration, or `null` to omit it. It is written as given.
32
+ */
17
33
  doc: TsDoc<TBuilder> | null;
34
+ /**
35
+ * The type annotation written after the name, such as `: number`, or `null` to omit it.
36
+ */
18
37
  type: TsType<TBuilder> | null;
38
+ /**
39
+ * The initial value written after ` = `, such as ` = 42`, or `null` to omit it. Falsy values are not written.
40
+ */
19
41
  value: TsValue<TBuilder> | null;
42
+ /**
43
+ * Whether the declaration is written with the `export` keyword.
44
+ * @default false
45
+ */
20
46
  export: boolean;
47
+ /**
48
+ * Whether the variable is declared with `const` instead of `let`.
49
+ * @default false
50
+ */
21
51
  readonly: boolean;
52
+ /**
53
+ * Initializes a new instance of the TsVariable class.
54
+ * @param options The options to use for this instance.
55
+ */
22
56
  constructor(options: Options<TBuilder, TInjects>);
23
57
  protected onWrite(builder: TBuilder): void;
24
58
  }
25
59
  declare const createVariable: <TBuilder extends SourceBuilder>(name: Options<TBuilder>['name'], options?: Prettify<Omit<Options<TBuilder>, 'name'>>) => TsVariable<TBuilder>;
60
+ /**
61
+ * Factory for creating variable nodes. The `write` function writes one or more variable nodes to a builder.
62
+ *
63
+ * @param name The name of the variable. See `TsVariable.name`.
64
+ * @param options The settings of the variable. See `TsVariable` for the available properties.
65
+ * @example
66
+ * ```ts
67
+ * tsVariable('x', { type: 'number', value: 42, readonly: true, export: true });
68
+ * // Emits:
69
+ * // export const x: number = 42;
70
+ * ```
71
+ */
26
72
  export declare const tsVariable: typeof createVariable & {
27
73
  write: typeof writeTsNodes;
28
74
  };
@@ -1,12 +1,46 @@
1
1
  import { TsNode } from '../node.js';
2
2
  import { writeTsNode, writeTsNodes } from '../utils/write-ts-nodes.js';
3
+ /**
4
+ * Represents a variable declaration, such as `export const x: number = 42;`.
5
+ *
6
+ * Written in this order: doc comment, `export` keyword, `const` or `let`, name, type annotation, initial value, and a
7
+ * semicolon. A variable is declared with `let` unless `readonly` is set, which declares it with `const`.
8
+ *
9
+ * @template TBuilder The type of the source builder the variable is written to.
10
+ * @template TInjects Additional names of custom injection points (`before*` and `after*`) accepted by this node.
11
+ * @see tsVariable
12
+ */
3
13
  export class TsVariable extends TsNode {
14
+ /**
15
+ * The name of the variable, written verbatim after `let` or `const`.
16
+ */
4
17
  name;
18
+ /**
19
+ * The doc comment written above the declaration, or `null` to omit it. It is written as given.
20
+ */
5
21
  doc;
22
+ /**
23
+ * The type annotation written after the name, such as `: number`, or `null` to omit it.
24
+ */
6
25
  type;
26
+ /**
27
+ * The initial value written after ` = `, such as ` = 42`, or `null` to omit it. Falsy values are not written.
28
+ */
7
29
  value;
30
+ /**
31
+ * Whether the declaration is written with the `export` keyword.
32
+ * @default false
33
+ */
8
34
  export;
35
+ /**
36
+ * Whether the variable is declared with `const` instead of `let`.
37
+ * @default false
38
+ */
9
39
  readonly;
40
+ /**
41
+ * Initializes a new instance of the TsVariable class.
42
+ * @param options The options to use for this instance.
43
+ */
10
44
  constructor(options) {
11
45
  super(options);
12
46
  this.name = options.name;
@@ -36,6 +70,18 @@ export class TsVariable extends TsNode {
36
70
  }
37
71
  }
38
72
  const createVariable = (name, options) => new TsVariable({ ...options, name });
73
+ /**
74
+ * Factory for creating variable nodes. The `write` function writes one or more variable nodes to a builder.
75
+ *
76
+ * @param name The name of the variable. See `TsVariable.name`.
77
+ * @param options The settings of the variable. See `TsVariable` for the available properties.
78
+ * @example
79
+ * ```ts
80
+ * tsVariable('x', { type: 'number', value: 42, readonly: true, export: true });
81
+ * // Emits:
82
+ * // export const x: number = 42;
83
+ * ```
84
+ */
39
85
  export const tsVariable = Object.assign(createVariable, {
40
86
  write: writeTsNodes,
41
87
  });
@@ -1,8 +1,15 @@
1
1
  import { type TsGenericModuleReferenceFactory, type TsModuleReferenceFactory } from '../nodes/reference.ts';
2
+ /** Reference to `inject` from the `@angular/core` module. */
2
3
  export declare const inject: TsModuleReferenceFactory;
4
+ /** Reference to `Injectable` from the `@angular/core` module. */
3
5
  export declare const injectable: TsModuleReferenceFactory;
6
+ /** Reference to `Provider` from the `@angular/core` module, imported as a type. */
4
7
  export declare const provider: TsModuleReferenceFactory;
8
+ /** Reference to `HttpClient` from the `@angular/common/http` module. */
5
9
  export declare const httpClient: TsModuleReferenceFactory;
10
+ /** Reference to `HttpContext` from the `@angular/common/http` module. */
6
11
  export declare const httpContext: TsModuleReferenceFactory;
12
+ /** Reference to `HttpResponse` from the `@angular/common/http` module. Takes one type argument. */
7
13
  export declare const httpResponse: TsGenericModuleReferenceFactory<1>;
14
+ /** Reference to `HttpErrorResponse` from the `@angular/common/http` module. */
8
15
  export declare const httpErrorResponse: TsModuleReferenceFactory;
@@ -1,12 +1,19 @@
1
1
  import { tsReference, } from '../nodes/reference.js';
2
2
  // @angular/core
3
+ /** Reference to `inject` from the `@angular/core` module. */
3
4
  export const inject = tsReference.factory('inject', '@angular/core');
5
+ /** Reference to `Injectable` from the `@angular/core` module. */
4
6
  export const injectable = tsReference.factory('Injectable', '@angular/core');
7
+ /** Reference to `Provider` from the `@angular/core` module, imported as a type. */
5
8
  export const provider = tsReference.factory('Provider', '@angular/core', {
6
9
  importType: 'type-import',
7
10
  });
8
11
  // @angular/common/http
12
+ /** Reference to `HttpClient` from the `@angular/common/http` module. */
9
13
  export const httpClient = tsReference.factory('HttpClient', '@angular/common/http');
14
+ /** Reference to `HttpContext` from the `@angular/common/http` module. */
10
15
  export const httpContext = tsReference.factory('HttpContext', '@angular/common/http');
16
+ /** Reference to `HttpResponse` from the `@angular/common/http` module. Takes one type argument. */
11
17
  export const httpResponse = tsReference.genericFactory('HttpResponse', '@angular/common/http');
18
+ /** Reference to `HttpErrorResponse` from the `@angular/common/http` module. */
12
19
  export const httpErrorResponse = tsReference.factory('HttpErrorResponse', '@angular/common/http');
@@ -1,5 +1,9 @@
1
1
  import { type TsGenericModuleReferenceFactory, type TsModuleReferenceFactory } from '../nodes/reference.ts';
2
+ /** Reference to `EasyNetworkStub` from the `easy-network-stub` module. */
2
3
  export declare const easyNetworkStub: TsModuleReferenceFactory;
4
+ /** Reference to `HttpMethod` from the `easy-network-stub` module, imported as a type. */
3
5
  export declare const httpMethod: TsModuleReferenceFactory;
6
+ /** Type-only reference to `RouteResponseCallback` from the `easy-network-stub` module. Takes two type arguments. */
4
7
  export declare const routeResponseCallback: TsGenericModuleReferenceFactory<2>;
8
+ /** Reference to `ErrorResponse` from the `easy-network-stub` module. Takes one type argument. */
5
9
  export declare const errorResponse: TsGenericModuleReferenceFactory<1>;
@@ -1,9 +1,13 @@
1
1
  import { tsReference, } from '../nodes/reference.js';
2
+ /** Reference to `EasyNetworkStub` from the `easy-network-stub` module. */
2
3
  export const easyNetworkStub = tsReference.factory('EasyNetworkStub', 'easy-network-stub');
4
+ /** Reference to `HttpMethod` from the `easy-network-stub` module, imported as a type. */
3
5
  export const httpMethod = tsReference.factory('HttpMethod', 'easy-network-stub', {
4
6
  importType: 'type-import',
5
7
  });
8
+ /** Type-only reference to `RouteResponseCallback` from the `easy-network-stub` module. Takes two type arguments. */
6
9
  export const routeResponseCallback = tsReference.genericFactory('RouteResponseCallback', 'easy-network-stub', {
7
10
  importType: 'type-import',
8
11
  });
12
+ /** Reference to `ErrorResponse` from the `easy-network-stub` module. Takes one type argument. */
9
13
  export const errorResponse = tsReference.genericFactory('ErrorResponse', 'easy-network-stub');
@@ -1,4 +1,7 @@
1
1
  import { type TsModuleReferenceFactory } from '../nodes/reference.ts';
2
+ /** Reference to `JSONValue` from the `k6` module. */
2
3
  export declare const jsonValue: TsModuleReferenceFactory;
4
+ /** Reference to `Response` from the `k6/http` module. */
3
5
  export declare const response: TsModuleReferenceFactory;
6
+ /** Reference to `Params` from the `k6/http` module. */
4
7
  export declare const params: TsModuleReferenceFactory;
@@ -1,6 +1,9 @@
1
1
  import { tsReference } from '../nodes/reference.js';
2
2
  // k6
3
+ /** Reference to `JSONValue` from the `k6` module. */
3
4
  export const jsonValue = tsReference.factory('JSONValue', 'k6');
4
5
  // h6/http
6
+ /** Reference to `Response` from the `k6/http` module. */
5
7
  export const response = tsReference.factory('Response', 'k6/http');
8
+ /** Reference to `Params` from the `k6/http` module. */
6
9
  export const params = tsReference.factory('Params', 'k6/http');
@@ -1,6 +1,11 @@
1
1
  import { type TsModuleReferenceFactory } from '../nodes/reference.ts';
2
+ /** Reference to `Observable` from the `rxjs` module. */
2
3
  export declare const observable: TsModuleReferenceFactory;
4
+ /** Reference to the `firstValueFrom` function from the `rxjs` module. */
3
5
  export declare const firstValueFrom: TsModuleReferenceFactory;
6
+ /** Reference to the `filter` operator from the `rxjs` module. */
4
7
  export declare const filter: TsModuleReferenceFactory;
8
+ /** Reference to the `map` operator from the `rxjs` module. */
5
9
  export declare const map: TsModuleReferenceFactory;
10
+ /** Reference to the `take` operator from the `rxjs` module. */
6
11
  export declare const take: TsModuleReferenceFactory;
@@ -1,6 +1,11 @@
1
1
  import { tsReference } from '../nodes/reference.js';
2
+ /** Reference to `Observable` from the `rxjs` module. */
2
3
  export const observable = tsReference.factory('Observable', 'rxjs');
4
+ /** Reference to the `firstValueFrom` function from the `rxjs` module. */
3
5
  export const firstValueFrom = tsReference.factory('firstValueFrom', 'rxjs');
6
+ /** Reference to the `filter` operator from the `rxjs` module. */
4
7
  export const filter = tsReference.factory('filter', 'rxjs');
8
+ /** Reference to the `map` operator from the `rxjs` module. */
5
9
  export const map = tsReference.factory('map', 'rxjs');
10
+ /** Reference to the `take` operator from the `rxjs` module. */
6
11
  export const take = tsReference.factory('take', 'rxjs');
@@ -1,31 +1,61 @@
1
1
  import { type TsGenericReferenceFactory, type TsReferenceFactory } from '../nodes/reference.ts';
2
+ /** Reference to the global `any` type. No import is emitted. */
2
3
  export declare const any: TsReferenceFactory;
4
+ /** Reference to the global `unknown` type. No import is emitted. */
3
5
  export declare const unknown: TsReferenceFactory;
6
+ /** Reference to the global `void` type. The `_` suffix is needed because `void` is a reserved word. */
4
7
  export declare const void_: TsReferenceFactory;
8
+ /** Reference to the global `never` type. No import is emitted. */
5
9
  export declare const never: TsReferenceFactory;
10
+ /** Reference to the global `number` type. No import is emitted. */
6
11
  export declare const number: TsReferenceFactory;
12
+ /** Reference to the global `string` type. No import is emitted. */
7
13
  export declare const string: TsReferenceFactory;
14
+ /** Reference to the global `boolean` type. No import is emitted. */
8
15
  export declare const boolean: TsReferenceFactory;
16
+ /** Reference to the global `bigint` type. No import is emitted. */
9
17
  export declare const bigint: TsReferenceFactory;
18
+ /** Reference to the global `symbol` type. No import is emitted. */
10
19
  export declare const symbol: TsReferenceFactory;
20
+ /** Reference to the global `object` type. No import is emitted. */
11
21
  export declare const object: TsReferenceFactory;
22
+ /** Reference to the global `undefined` type. The `_` suffix keeps the name apart from the `undefined` value. */
12
23
  export declare const undefined_: TsReferenceFactory;
24
+ /** Reference to the global `null` type. The `_` suffix is needed because `null` is a reserved word. */
13
25
  export declare const null_: TsReferenceFactory;
26
+ /** Reference to the global `Array` type. Takes one type argument and emits no import. */
14
27
  export declare const array: TsGenericReferenceFactory<1>;
28
+ /** Reference to the global `Record` type. Takes two type arguments and emits no import. */
15
29
  export declare const record: TsGenericReferenceFactory<2>;
30
+ /** Reference to the global `Map` type. Takes two type arguments and emits no import. */
16
31
  export declare const map: TsGenericReferenceFactory<2>;
32
+ /** Reference to the global `Set` type. Takes one type argument and emits no import. */
17
33
  export declare const set: TsGenericReferenceFactory<1>;
34
+ /** Reference to the global `Promise` type. Takes one type argument and emits no import. */
18
35
  export declare const promise: TsGenericReferenceFactory<1>;
36
+ /** Reference to the global `ReadonlyArray` type. Takes one type argument and emits no import. */
19
37
  export declare const readonlyArray: TsGenericReferenceFactory<1>;
38
+ /** Reference to the global `Readonly` utility type. Takes one type argument and emits no import. */
20
39
  export declare const readonly: TsGenericReferenceFactory<1>;
40
+ /** Reference to the global `Partial` utility type. Takes one type argument and emits no import. */
21
41
  export declare const partial: TsGenericReferenceFactory<1>;
42
+ /** Reference to the global `Required` utility type. Takes one type argument and emits no import. */
22
43
  export declare const required: TsGenericReferenceFactory<1>;
44
+ /** Reference to the global `Pick` utility type. Takes two type arguments and emits no import. */
23
45
  export declare const pick: TsGenericReferenceFactory<2>;
46
+ /** Reference to the global `Omit` utility type. Takes two type arguments and emits no import. */
24
47
  export declare const omit: TsGenericReferenceFactory<2>;
48
+ /** Reference to the global `Exclude` utility type. Takes two type arguments and emits no import. */
25
49
  export declare const exclude: TsGenericReferenceFactory<2>;
50
+ /** Reference to the global `Extract` utility type. Takes two type arguments and emits no import. */
26
51
  export declare const extract: TsGenericReferenceFactory<2>;
52
+ /** Reference to the global `NonNullable` utility type. Takes one type argument and emits no import. */
27
53
  export declare const nonNullable: TsGenericReferenceFactory<1>;
54
+ /** Reference to the global `Parameters` utility type. Takes one type argument and emits no import. */
28
55
  export declare const parameters: TsGenericReferenceFactory<1>;
56
+ /** Reference to the global `ReturnType` utility type. Takes one type argument and emits no import. */
29
57
  export declare const returnType: TsGenericReferenceFactory<1>;
58
+ /** Reference to the global `InstanceType` utility type. Takes one type argument and emits no import. */
30
59
  export declare const instanceType: TsGenericReferenceFactory<1>;
60
+ /** Reference to the global `Blob` type. No import is emitted. */
31
61
  export declare const blob: TsReferenceFactory;
@@ -1,31 +1,61 @@
1
1
  import { tsReference } from '../nodes/reference.js';
2
+ /** Reference to the global `any` type. No import is emitted. */
2
3
  export const any = tsReference.factory('any');
4
+ /** Reference to the global `unknown` type. No import is emitted. */
3
5
  export const unknown = tsReference.factory('unknown');
6
+ /** Reference to the global `void` type. The `_` suffix is needed because `void` is a reserved word. */
4
7
  export const void_ = tsReference.factory('void');
8
+ /** Reference to the global `never` type. No import is emitted. */
5
9
  export const never = tsReference.factory('never');
10
+ /** Reference to the global `number` type. No import is emitted. */
6
11
  export const number = tsReference.factory('number');
12
+ /** Reference to the global `string` type. No import is emitted. */
7
13
  export const string = tsReference.factory('string');
14
+ /** Reference to the global `boolean` type. No import is emitted. */
8
15
  export const boolean = tsReference.factory('boolean');
16
+ /** Reference to the global `bigint` type. No import is emitted. */
9
17
  export const bigint = tsReference.factory('bigint');
18
+ /** Reference to the global `symbol` type. No import is emitted. */
10
19
  export const symbol = tsReference.factory('symbol');
20
+ /** Reference to the global `object` type. No import is emitted. */
11
21
  export const object = tsReference.factory('object');
22
+ /** Reference to the global `undefined` type. The `_` suffix keeps the name apart from the `undefined` value. */
12
23
  export const undefined_ = tsReference.factory('undefined');
24
+ /** Reference to the global `null` type. The `_` suffix is needed because `null` is a reserved word. */
13
25
  export const null_ = tsReference.factory('null');
26
+ /** Reference to the global `Array` type. Takes one type argument and emits no import. */
14
27
  export const array = tsReference.genericFactory('Array');
28
+ /** Reference to the global `Record` type. Takes two type arguments and emits no import. */
15
29
  export const record = tsReference.genericFactory('Record');
30
+ /** Reference to the global `Map` type. Takes two type arguments and emits no import. */
16
31
  export const map = tsReference.genericFactory('Map');
32
+ /** Reference to the global `Set` type. Takes one type argument and emits no import. */
17
33
  export const set = tsReference.genericFactory('Set');
34
+ /** Reference to the global `Promise` type. Takes one type argument and emits no import. */
18
35
  export const promise = tsReference.genericFactory('Promise');
36
+ /** Reference to the global `ReadonlyArray` type. Takes one type argument and emits no import. */
19
37
  export const readonlyArray = tsReference.genericFactory('ReadonlyArray');
38
+ /** Reference to the global `Readonly` utility type. Takes one type argument and emits no import. */
20
39
  export const readonly = tsReference.genericFactory('Readonly');
40
+ /** Reference to the global `Partial` utility type. Takes one type argument and emits no import. */
21
41
  export const partial = tsReference.genericFactory('Partial');
42
+ /** Reference to the global `Required` utility type. Takes one type argument and emits no import. */
22
43
  export const required = tsReference.genericFactory('Required');
44
+ /** Reference to the global `Pick` utility type. Takes two type arguments and emits no import. */
23
45
  export const pick = tsReference.genericFactory('Pick');
46
+ /** Reference to the global `Omit` utility type. Takes two type arguments and emits no import. */
24
47
  export const omit = tsReference.genericFactory('Omit');
48
+ /** Reference to the global `Exclude` utility type. Takes two type arguments and emits no import. */
25
49
  export const exclude = tsReference.genericFactory('Exclude');
50
+ /** Reference to the global `Extract` utility type. Takes two type arguments and emits no import. */
26
51
  export const extract = tsReference.genericFactory('Extract');
52
+ /** Reference to the global `NonNullable` utility type. Takes one type argument and emits no import. */
27
53
  export const nonNullable = tsReference.genericFactory('NonNullable');
54
+ /** Reference to the global `Parameters` utility type. Takes one type argument and emits no import. */
28
55
  export const parameters = tsReference.genericFactory('Parameters');
56
+ /** Reference to the global `ReturnType` utility type. Takes one type argument and emits no import. */
29
57
  export const returnType = tsReference.genericFactory('ReturnType');
58
+ /** Reference to the global `InstanceType` utility type. Takes one type argument and emits no import. */
30
59
  export const instanceType = tsReference.genericFactory('InstanceType');
60
+ /** Reference to the global `Blob` type. No import is emitted. */
31
61
  export const blob = tsReference.factory('Blob');
@@ -1,3 +1,11 @@
1
1
  import { type StringBuilder } from '@goast/core';
2
2
  import { type TypeScriptGeneratorConfig } from '../../config.ts';
3
+ /**
4
+ * Gets the TypeScript generator options that apply to a builder.
5
+ * A `TypeScriptFileBuilder` returns its own options. For any other builder, the options are merged from the OpenAPI
6
+ * defaults, the TypeScript defaults and the builder's own options, in that order, so later sources take precedence.
7
+ * The merged result is also stored on the builder under a private symbol.
8
+ * @param builder The builder to get the options for.
9
+ * @returns The TypeScript generator options for the builder.
10
+ */
3
11
  export declare function getTypeScriptBuilderOptions(builder: StringBuilder): TypeScriptGeneratorConfig;
@@ -2,6 +2,14 @@ import { defaultOpenApiGeneratorConfig } from '@goast/core';
2
2
  import { defaultTypeScriptGeneratorConfig } from '../../config.js';
3
3
  import { TypeScriptFileBuilder } from '../../file-builder.js';
4
4
  const tsConfigSymbol = Symbol();
5
+ /**
6
+ * Gets the TypeScript generator options that apply to a builder.
7
+ * A `TypeScriptFileBuilder` returns its own options. For any other builder, the options are merged from the OpenAPI
8
+ * defaults, the TypeScript defaults and the builder's own options, in that order, so later sources take precedence.
9
+ * The merged result is also stored on the builder under a private symbol.
10
+ * @param builder The builder to get the options for.
11
+ * @returns The TypeScript generator options for the builder.
12
+ */
5
13
  export function getTypeScriptBuilderOptions(builder) {
6
14
  if (builder instanceof TypeScriptFileBuilder) {
7
15
  return builder.options;
@@ -2,7 +2,35 @@ import type { BasicAppendValue, SourceBuilder } from '@goast/core';
2
2
  import { type TsObject } from '../nodes/object.ts';
3
3
  import { type TsString } from '../nodes/string.ts';
4
4
  import { type TsTuple } from '../nodes/tuple.ts';
5
+ /**
6
+ * Converts a plain object to a TypeScript object literal node.
7
+ * Each entry becomes a property named after its key, and each value is converted with this function.
8
+ * @template TBuilder The type of the source builder the node is written to.
9
+ * @param object The object to convert.
10
+ * @returns An object node with one property per entry of `object`.
11
+ */
5
12
  export declare function toTsNode<TBuilder extends SourceBuilder>(object: Record<string, unknown>): TsObject<TBuilder>;
13
+ /**
14
+ * Converts an array to a TypeScript tuple node.
15
+ * Each item is converted with this function, in order.
16
+ * @template TBuilder The type of the source builder the node is written to.
17
+ * @param tuple The array to convert.
18
+ * @returns A tuple node with one element per item of `tuple`.
19
+ */
6
20
  export declare function toTsNode<TBuilder extends SourceBuilder>(tuple: unknown[]): TsTuple<TBuilder>;
21
+ /**
22
+ * Converts a string to a TypeScript string literal node.
23
+ * @template TBuilder The type of the source builder the node is written to.
24
+ * @param string The string to convert.
25
+ * @returns A string literal node with the value of `string`.
26
+ */
7
27
  export declare function toTsNode<TBuilder extends SourceBuilder>(string: string): TsString<TBuilder>;
28
+ /**
29
+ * Converts a value of unknown type to a node. Arrays and objects are converted as in the overloads above.
30
+ * `null`, `undefined`, booleans and numbers are written as plain text, and any other value is written as a
31
+ * string literal of its `String()` form.
32
+ * @template TBuilder The type of the source builder the node is written to.
33
+ * @param value The value to convert.
34
+ * @returns The converted node.
35
+ */
8
36
  export declare function toTsNode<TBuilder extends SourceBuilder>(value: unknown): BasicAppendValue<TBuilder>;
@@ -1,3 +1,12 @@
1
1
  import { type AppendValue, type Nullable, type SingleOrMultiple, type SourceBuilder } from '@goast/core';
2
2
  import type { TsNode } from '../node.ts';
3
+ /**
4
+ * Writes a type parameter or type argument list in angle brackets, such as `<T, U>`.
5
+ * Nothing is written when there are no entries. The entries are written on one line, separated by `, `, unless there
6
+ * are more than two of them. Otherwise each entry is written on its own line, separated by `,` and a line break, and
7
+ * the closing `>` is written on its own line. Nullish entries are skipped.
8
+ * @template TBuilder The type of the source builder the entries are written to.
9
+ * @param builder The builder to write to.
10
+ * @param nodes The type parameters or arguments to write. A single entry is also accepted.
11
+ */
3
12
  export declare function writeTsGenericParameters<TBuilder extends SourceBuilder>(builder: TBuilder, nodes: SingleOrMultiple<Nullable<TsNode<TBuilder> | AppendValue<TBuilder>>>): void;
@@ -1,5 +1,14 @@
1
1
  import { notNullish, toArray, } from '@goast/core';
2
2
  import { writeTsNodes } from './write-ts-nodes.js';
3
+ /**
4
+ * Writes a type parameter or type argument list in angle brackets, such as `<T, U>`.
5
+ * Nothing is written when there are no entries. The entries are written on one line, separated by `, `, unless there
6
+ * are more than two of them. Otherwise each entry is written on its own line, separated by `,` and a line break, and
7
+ * the closing `>` is written on its own line. Nullish entries are skipped.
8
+ * @template TBuilder The type of the source builder the entries are written to.
9
+ * @param builder The builder to write to.
10
+ * @param nodes The type parameters or arguments to write. A single entry is also accepted.
11
+ */
3
12
  export function writeTsGenericParameters(builder, nodes) {
4
13
  const filteredNodes = toArray(nodes).filter(notNullish);
5
14
  const multiline = filteredNodes.length > 2;
@@ -1,5 +1,17 @@
1
1
  import { type AppendValue, type Nullable, type SourceBuilder } from '@goast/core';
2
2
  import type { TsNode } from '../node.ts';
3
+ /**
4
+ * Writes class or interface members to a builder, separating them with blank lines where needed.
5
+ * A compact member is a property or a bodyless method without a doc comment or decorators, or a plain appended value.
6
+ * Any other member gets a blank line before it, unless it is the first member and `alreadyHasMembers` is not set,
7
+ * and a blank line after it, unless it is the last member. Compact members get no blank lines of their own, but a
8
+ * line break is ensured after each one, so consecutive compact members are written on consecutive lines.
9
+ * @template TBuilder The type of the source builder the members are written to.
10
+ * @param builder The builder to write to.
11
+ * @param members The members to write. Nullish entries are skipped.
12
+ * @param options Options for writing the members. Set `alreadyHasMembers` when the members follow other content
13
+ * in the same body, so that the first member also gets a blank line before it.
14
+ */
3
15
  export declare function writeTsMembers<TBuilder extends SourceBuilder>(builder: TBuilder, members: Nullable<AppendValue<TBuilder> | TsNode<TBuilder>>[], options?: {
4
16
  alreadyHasMembers?: boolean;
5
17
  }): void;
@@ -3,6 +3,18 @@ import { tsDoc } from '../nodes/doc.js';
3
3
  import { TsMethod } from '../nodes/method.js';
4
4
  import { TsProperty } from '../nodes/property.js';
5
5
  import { writeTsNode } from './write-ts-nodes.js';
6
+ /**
7
+ * Writes class or interface members to a builder, separating them with blank lines where needed.
8
+ * A compact member is a property or a bodyless method without a doc comment or decorators, or a plain appended value.
9
+ * Any other member gets a blank line before it, unless it is the first member and `alreadyHasMembers` is not set,
10
+ * and a blank line after it, unless it is the last member. Compact members get no blank lines of their own, but a
11
+ * line break is ensured after each one, so consecutive compact members are written on consecutive lines.
12
+ * @template TBuilder The type of the source builder the members are written to.
13
+ * @param builder The builder to write to.
14
+ * @param members The members to write. Nullish entries are skipped.
15
+ * @param options Options for writing the members. Set `alreadyHasMembers` when the members follow other content
16
+ * in the same body, so that the first member also gets a blank line before it.
17
+ */
6
18
  export function writeTsMembers(builder, members, options) {
7
19
  const filteredMembers = members.filter(notNullish);
8
20
  builder.forEach(filteredMembers, (b, m, i) => b.if(() => !(m instanceof TsProperty && tsDoc.isEmpty(m.doc) && m.decorators.length === 0) &&
@@ -1,6 +1,22 @@
1
1
  import { type AppendValue, type Nullable, type Separator, type SingleOrMultiple, type SourceBuilder } from '@goast/core';
2
2
  import { TsNode } from '../node.ts';
3
+ /**
4
+ * Writes a single node or value to a builder.
5
+ * A `TsNode` writes itself. Any other value is passed to the builder's `append` method.
6
+ * @template TBuilder The type of the source builder the node is written to.
7
+ * @param builder The builder to write to.
8
+ * @param node The node or value to write.
9
+ */
3
10
  export declare function writeTsNode<TBuilder extends SourceBuilder>(builder: TBuilder, node: Nullable<AppendValue<TBuilder> | TsNode<TBuilder>>): void;
11
+ /**
12
+ * Writes one or more nodes or values to a builder, one after another.
13
+ * Nullish entries are skipped, and nothing is written when no entries remain. Without a separator, the entries are
14
+ * written back to back, so any line break has to come from the nodes themselves.
15
+ * @template TBuilder The type of the source builder the nodes are written to.
16
+ * @param builder The builder to write to.
17
+ * @param nodes The nodes or values to write. A single entry is also accepted.
18
+ * @param options Options for writing. `separator` is written between each pair of written entries.
19
+ */
4
20
  export declare function writeTsNodes<TBuilder extends SourceBuilder>(builder: TBuilder, nodes: SingleOrMultiple<Nullable<AppendValue<TBuilder> | TsNode<TBuilder>>>, options?: {
5
21
  separator?: Separator<TBuilder, AppendValue<TBuilder> | TsNode<TBuilder>>;
6
22
  }): void;