@goast/typescript 0.3.6 → 0.3.7-beta1

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 (46) hide show
  1. package/README.md +43 -43
  2. package/assets/client/angular/angular-service.utils.ts +82 -80
  3. package/assets/client/angular/request-builder.ts +374 -372
  4. package/assets/client/fetch/fetch-client.utils.ts +52 -52
  5. package/assets/client/k6/request-builder.js +411 -411
  6. package/assets/stubs/easy-network-stub/easy-network-stub.utils.ts +260 -258
  7. package/cjs/lib/ast/nodes/export.js +4 -2
  8. package/cjs/lib/ast/nodes/reference.js +8 -8
  9. package/cjs/lib/ast/references/angular.js +1 -1
  10. package/cjs/lib/ast/references/easy-network-stub.js +4 -2
  11. package/cjs/lib/file-builder.js +3 -3
  12. package/cjs/lib/generators/models/model-generator.js +13 -7
  13. package/cjs/lib/generators/models/models-generator.js +4 -1
  14. package/cjs/lib/generators/services/angular-services/angular-service-generator.js +10 -10
  15. package/cjs/lib/generators/services/angular-services/angular-services-generator.js +1 -1
  16. package/cjs/lib/generators/services/angular-services/refs.js +4 -2
  17. package/cjs/lib/generators/services/easy-network-stub/easy-network-stub-generator.js +9 -9
  18. package/cjs/lib/generators/services/easy-network-stub/easy-network-stubs-generator.js +8 -4
  19. package/cjs/lib/generators/services/easy-network-stub/refs.js +11 -5
  20. package/cjs/lib/generators/services/fetch-clients/fetch-client-generator.js +2 -2
  21. package/cjs/lib/generators/services/fetch-clients/refs.js +2 -2
  22. package/cjs/lib/generators/services/k6-clients/k6-client-generator.js +6 -6
  23. package/cjs/lib/import-collection.js +37 -14
  24. package/esm/lib/ast/nodes/export.js +4 -2
  25. package/esm/lib/ast/nodes/reference.js +8 -8
  26. package/esm/lib/ast/references/angular.js +1 -1
  27. package/esm/lib/ast/references/easy-network-stub.js +4 -2
  28. package/esm/lib/file-builder.js +3 -3
  29. package/esm/lib/generators/models/model-generator.js +13 -7
  30. package/esm/lib/generators/models/models-generator.js +4 -1
  31. package/esm/lib/generators/services/angular-services/angular-service-generator.js +10 -10
  32. package/esm/lib/generators/services/angular-services/angular-services-generator.js +1 -1
  33. package/esm/lib/generators/services/angular-services/refs.js +4 -2
  34. package/esm/lib/generators/services/easy-network-stub/easy-network-stub-generator.js +9 -9
  35. package/esm/lib/generators/services/easy-network-stub/easy-network-stubs-generator.js +8 -4
  36. package/esm/lib/generators/services/easy-network-stub/refs.js +11 -5
  37. package/esm/lib/generators/services/fetch-clients/fetch-client-generator.js +2 -2
  38. package/esm/lib/generators/services/fetch-clients/refs.js +2 -2
  39. package/esm/lib/generators/services/k6-clients/k6-client-generator.js +6 -6
  40. package/esm/lib/import-collection.js +37 -14
  41. package/package.json +2 -3
  42. package/types/lib/ast/nodes/export.d.ts +4 -1
  43. package/types/lib/ast/nodes/reference.d.ts +18 -6
  44. package/types/lib/common-results.d.ts +7 -2
  45. package/types/lib/file-builder.d.ts +2 -2
  46. package/types/lib/import-collection.d.ts +9 -4
@@ -94,15 +94,15 @@ export class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGen
94
94
  ],
95
95
  returnType: 'this',
96
96
  body: appendValueGroup([
97
- s `this.stubWrapper.stub2<${requestType}>()(${s.indent `
98
- ${ts.string(endpoint.method.toUpperCase())},
99
- ${this.getStubClassName(ctx)}.${this.getEndpointPathPropertyName(ctx, endpoint)},
100
- async (request) => {${s.indent `
101
- if (this.stubWrapper.options.rememberRequests) {${s.indent `
102
- this.${this.getEndpointRequestsFieldName(ctx, endpoint)}.push(request);`}
103
- }
104
- throw await response(${this.getResponderVariableName(ctx, endpoint)}, request);`}
105
- }`}
97
+ s `this.stubWrapper.stub2<${requestType}>()(${s.indent `
98
+ ${ts.string(endpoint.method.toUpperCase())},
99
+ ${this.getStubClassName(ctx)}.${this.getEndpointPathPropertyName(ctx, endpoint)},
100
+ async (request) => {${s.indent `
101
+ if (this.stubWrapper.options.rememberRequests) {${s.indent `
102
+ this.${this.getEndpointRequestsFieldName(ctx, endpoint)}.push(request);`}
103
+ }
104
+ throw await response(${this.getResponderVariableName(ctx, endpoint)}, request);`}
105
+ }`}
106
106
  );`,
107
107
  'return this;',
108
108
  ], '\n'),
@@ -79,13 +79,15 @@ export class TypeScriptEasyNetworkStubsGenerator extends OpenApiServicesGenerati
79
79
  ...Object.entries(ctx.output.typescript.stubs).map(([id, x]) => ts.property(toCasing(serviceNames[id], fieldCasing), {
80
80
  accessModifier: 'private',
81
81
  optional: true,
82
- type: ctx.refs.easyNetworkStubGroup([ts.reference(x.component, x.filePath), 'this']),
82
+ type: ctx.refs.easyNetworkStubGroup([ts.reference(x.component, x.filePath), 'this'], {
83
+ importType: 'type-import',
84
+ }),
83
85
  })),
84
86
  ts.constructor({
85
87
  parameters: [
86
88
  ts.constructorParameter('stub', { type: ts.refs.easyNetworkStub.easyNetworkStub() }),
87
89
  ts.constructorParameter('options', {
88
- type: ts.refs.partial([ctx.refs.easyNetworkStubWrapperOptions()]),
90
+ type: ts.refs.partial([ctx.refs.easyNetworkStubWrapperOptions()], { importType: 'type-import' }),
89
91
  optional: true,
90
92
  }),
91
93
  ],
@@ -93,14 +95,16 @@ export class TypeScriptEasyNetworkStubsGenerator extends OpenApiServicesGenerati
93
95
  }),
94
96
  ts.property('requests', {
95
97
  accessModifier: 'public',
96
- type: ts.arrayType(ctx.refs.stubRequestItem(), { readonly: true }),
98
+ type: ts.arrayType(ctx.refs.stubRequestItem({ importType: 'type-import' }), { readonly: true }),
97
99
  get: ts.property.getter({
98
100
  body: appendValueGroup(['return this._stubWrapper.requests;'], '\n'),
99
101
  }),
100
102
  }),
101
103
  ...Object.entries(ctx.output.typescript.stubs).map(([id, x]) => ts.property(toCasing(serviceNames[id], ctx.config.propertyNameCasing), {
102
104
  accessModifier: 'public',
103
- type: ctx.refs.easyNetworkStubGroup([ts.reference(x.component, x.filePath), 'this']),
105
+ type: ctx.refs.easyNetworkStubGroup([ts.reference(x.component, x.filePath), 'this'], {
106
+ importType: 'type-import',
107
+ }),
104
108
  get: ts.property.getter({
105
109
  body: appendValueGroup([
106
110
  s `return this.${toCasing(serviceNames[id], fieldCasing)} ??= ${ctx.refs.createEasyNetworkStubGroup.infer()}(this, this._stubWrapper, ${ts.reference(x.component, x.filePath)});`,
@@ -6,14 +6,20 @@ export function getReferenceFactories(options) {
6
6
  const easyNetworkStubUtilsPath = join(utilsDirPath, 'easy-network-stub.utils.ts');
7
7
  return {
8
8
  // easy-network-stub.utils.ts
9
- easyNetworkStubWrapperOptions: ts.reference.factory('EasyNetworkStubWrapperOptions', easyNetworkStubUtilsPath),
10
- stubRequestItem: ts.reference.factory('StubRequestItem', easyNetworkStubUtilsPath),
11
- stubRequestInfo: ts.reference.genericFactory('StubRequestInfo', easyNetworkStubUtilsPath),
12
- strictRouteResponseCallback: ts.reference.genericFactory('StrictRouteResponseCallback', easyNetworkStubUtilsPath),
9
+ easyNetworkStubWrapperOptions: ts.reference.factory('EasyNetworkStubWrapperOptions', easyNetworkStubUtilsPath, {
10
+ importType: 'type-import',
11
+ }),
12
+ stubRequestItem: ts.reference.factory('StubRequestItem', easyNetworkStubUtilsPath, { importType: 'type-import' }),
13
+ stubRequestInfo: ts.reference.genericFactory('StubRequestInfo', easyNetworkStubUtilsPath, {
14
+ importType: 'type-import',
15
+ }),
16
+ strictRouteResponseCallback: ts.reference.genericFactory('StrictRouteResponseCallback', easyNetworkStubUtilsPath, { importType: 'type-import' }),
13
17
  getStubResponder: ts.reference.genericFactory('getStubResponder', easyNetworkStubUtilsPath),
14
18
  easyNetworkStubWrapper: ts.reference.factory('EasyNetworkStubWrapper', easyNetworkStubUtilsPath),
15
19
  easyNetworkStubBase: ts.reference.factory('EasyNetworkStubBase', easyNetworkStubUtilsPath),
16
- easyNetworkStubGroup: ts.reference.genericFactory('EasyNetworkStubGroup', easyNetworkStubUtilsPath),
20
+ easyNetworkStubGroup: ts.reference.genericFactory('EasyNetworkStubGroup', easyNetworkStubUtilsPath, {
21
+ importType: 'type-import',
22
+ }),
17
23
  createEasyNetworkStubGroup: ts.reference.genericFactory('createEasyNetworkStubGroup', easyNetworkStubUtilsPath),
18
24
  };
19
25
  }
@@ -133,7 +133,7 @@ export class DefaultTypeScriptFetchClientGenerator extends TypeScriptFileGenerat
133
133
  const method = this.getInterfaceEndpointMethod(ctx, endpoint);
134
134
  method.accessModifier = 'public';
135
135
  method.body = appendValueGroup([
136
- s `const url = new ${ctx.refs.urlBuilder()}(this.options.baseUrl)${s.indent `
136
+ s `const url = new ${ctx.refs.urlBuilder()}(this.options.baseUrl)${s.indent `
137
137
  .withPath(${ts.string(endpoint.path)})${(b) => b.forEach(endpoint.parameters, (b, p) => {
138
138
  switch (p.target) {
139
139
  case 'path':
@@ -143,7 +143,7 @@ export class DefaultTypeScriptFetchClientGenerator extends TypeScriptFileGenerat
143
143
  b.append(s `\n.withQueryParam(${ts.string(p.name)}, params.${toCasing(p.name, ctx.config.paramNameCasing)})`);
144
144
  break;
145
145
  }
146
- })}
146
+ })}
147
147
  .build();`}`,
148
148
  s `const response = (this.options.fetch ?? fetch)(url, ${ts.object({
149
149
  members: [
@@ -6,8 +6,8 @@ export function getReferenceFactories(options) {
6
6
  const fetchClientUtilsPath = resolve(utilsDirPath, 'fetch-client.utils.ts');
7
7
  return {
8
8
  // fetch-client.utils.ts
9
- typedResponse: ts.reference.genericFactory('TypedResponse', fetchClientUtilsPath),
10
- fetchClientOptions: ts.reference.factory('FetchClientOptions', fetchClientUtilsPath),
9
+ typedResponse: ts.reference.genericFactory('TypedResponse', fetchClientUtilsPath, { importType: 'type-import' }),
10
+ fetchClientOptions: ts.reference.factory('FetchClientOptions', fetchClientUtilsPath, { importType: 'type-import' }),
11
11
  urlBuilder: ts.reference.factory('UrlBuilder', fetchClientUtilsPath),
12
12
  };
13
13
  }
@@ -186,7 +186,7 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator
186
186
  ],
187
187
  }),
188
188
  parameters: [ts.constructorParameter('rootUrl'), ts.constructorParameter('defaultK6ParamsFactory')],
189
- body: s `this.rootUrl = rootUrl;
189
+ body: s `this.rootUrl = rootUrl;
190
190
  this._defaultK6ParamsFactory = defaultK6ParamsFactory;`,
191
191
  }),
192
192
  ...ctx.service.endpoints.map((e) => this.getEndpointMethod(ctx, e)),
@@ -245,11 +245,11 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator
245
245
  }
246
246
  : null,
247
247
  '',
248
- s `return /** @type {${returnType}} */ (${s.indent `
249
- ${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${s.indent `
250
- accept: ${ts.string(accept)},
251
- params: this.getK6Params(k6Params),`}
252
- })`}
248
+ s `return /** @type {${returnType}} */ (${s.indent `
249
+ ${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${s.indent `
250
+ accept: ${ts.string(accept)},
251
+ params: this.getK6Params(k6Params),`}
252
+ })`}
253
253
  );`,
254
254
  ], '\n'),
255
255
  });
@@ -12,13 +12,14 @@ export class ImportExportCollection {
12
12
  this._typeImports = new Map();
13
13
  this._jsDocImports = new Map();
14
14
  this._exports = new Map();
15
+ this._typeExports = new Map();
15
16
  this._options = { ...defaultImportExportCollectionOptions, ...options };
16
17
  }
17
18
  get hasImports() {
18
19
  return this._imports.size > 0 || this._typeImports.size > 0 || this._jsDocImports.size > 0;
19
20
  }
20
21
  get hasExports() {
21
- return this._exports.size > 0;
22
+ return this._exports.size > 0 || this._typeExports.size > 0;
22
23
  }
23
24
  get imports() {
24
25
  return [
@@ -48,28 +49,23 @@ export class ImportExportCollection {
48
49
  map.set(fromModule, new Set([importName]));
49
50
  }
50
51
  }
51
- getImportMap(type) {
52
- switch (type) {
53
- case 'import':
54
- return this._imports;
55
- case 'type-import':
56
- return this._typeImports;
57
- case 'js-doc':
58
- return this._jsDocImports;
59
- }
60
- }
61
- addExport(exportName, fromModule) {
62
- const existingExport = this._exports.get(fromModule);
52
+ addExport(exportName, fromModule, options) {
53
+ var _a;
54
+ const map = this.getExportMap((_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : 'export');
55
+ const existingExport = map.get(fromModule);
63
56
  if (existingExport) {
64
57
  existingExport.add(exportName);
65
58
  }
66
59
  else {
67
- this._exports.set(fromModule, new Set([exportName]));
60
+ map.set(fromModule, new Set([exportName]));
68
61
  }
69
62
  }
70
63
  clear() {
71
64
  this._imports.clear();
65
+ this._typeImports.clear();
66
+ this._jsDocImports.clear();
72
67
  this._exports.clear();
68
+ this._typeExports.clear();
73
69
  }
74
70
  toString(options) {
75
71
  const builder = new StringBuilder(options);
@@ -108,6 +104,15 @@ export class ImportExportCollection {
108
104
  }
109
105
  const sortedExports = this.sortAndResolve(this._exports, filePath, importModuleTransformer);
110
106
  this.writeImportsExports(builder, 'export', sortedExports, { useSingleQuotes });
107
+ hasPrevious = true;
108
+ }
109
+ if (this._typeExports.size > 0) {
110
+ if (hasPrevious) {
111
+ builder.appendLine();
112
+ }
113
+ const sortedExports = this.sortAndResolve(this._typeExports, filePath, importModuleTransformer);
114
+ this.writeImportsExports(builder, 'export type', sortedExports, { useSingleQuotes });
115
+ hasPrevious = true;
111
116
  }
112
117
  }
113
118
  writeImportsExports(builder, keyword, data, options) {
@@ -150,4 +155,22 @@ export class ImportExportCollection {
150
155
  kind,
151
156
  ];
152
157
  }
158
+ getImportMap(type) {
159
+ switch (type) {
160
+ case 'import':
161
+ return this._imports;
162
+ case 'type-import':
163
+ return this._typeImports;
164
+ case 'js-doc':
165
+ return this._jsDocImports;
166
+ }
167
+ }
168
+ getExportMap(type) {
169
+ switch (type) {
170
+ case 'export':
171
+ return this._exports;
172
+ case 'type-export':
173
+ return this._typeExports;
174
+ }
175
+ }
153
176
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/typescript",
3
- "version": "0.3.6",
3
+ "version": "0.3.7-beta1",
4
4
  "repository": "https://github.com/MaSch0212/goast.git",
5
5
  "description": "Provides gOAst generators for generating TypeScript code from OpenAPI specifications.",
6
6
  "keywords": [
@@ -30,7 +30,6 @@
30
30
  "@goast/core": "0.3.5",
31
31
  "tslib": "2.6.3"
32
32
  },
33
- "packageManager": "pnpm@9.5.0",
34
33
  "module": "./esm/index.js",
35
34
  "main": "./cjs/index.js",
36
35
  "types": "./types/index.d.ts",
@@ -42,4 +41,4 @@
42
41
  },
43
42
  "./package.json": "./package.json"
44
43
  }
45
- }
44
+ }
@@ -1,14 +1,17 @@
1
- import { AstNodeOptions, Prettify, SourceBuilder } from '@goast/core';
1
+ import { AstNodeOptions, Nullable, Prettify, SourceBuilder } from '@goast/core';
2
+ import { TypeScriptExportType } from '../../common-results';
2
3
  import { TsNode } from '../node';
3
4
  import { writeTsNodes } from '../utils/write-ts-nodes';
4
5
  type Injects = never;
5
6
  type Options<TBuilder extends SourceBuilder, TInjects extends string = never> = AstNodeOptions<typeof TsNode<TBuilder, TInjects | Injects>, {
6
7
  name: string;
7
8
  filePath: string;
9
+ kind?: Nullable<TypeScriptExportType>;
8
10
  }>;
9
11
  export declare class TsExport<TBuilder extends SourceBuilder, TInjects extends string = never> extends TsNode<TBuilder, TInjects | Injects> {
10
12
  name: string;
11
13
  filePath: string;
14
+ kind: TypeScriptExportType;
12
15
  constructor(options: Options<TBuilder, TInjects>);
13
16
  protected onWrite(builder: TBuilder): void;
14
17
  }
@@ -27,23 +27,35 @@ export declare class TsReference<TBuilder extends SourceBuilder, TInjects extend
27
27
  protected onWrite(builder: TBuilder): void;
28
28
  static registerAddImportHandler<TBuilder extends SourceBuilder>(builderClass: _AddImportHandler<TBuilder>['builderClass'], handler: _AddImportHandler<TBuilder>['handler']): void;
29
29
  }
30
- declare function _createFactory(name: string, moduleNameOrfilePath?: Nullable<string>): (<TBuilder extends SourceBuilder>(options?: FactoryOptions<TBuilder>) => TsReference<TBuilder, never>) & {
30
+ declare function _createFactory(name: string, moduleNameOrfilePath?: Nullable<string>, defaultOptions?: {
31
+ importType?: Nullable<TypeScriptImportType>;
32
+ }): (<TBuilder extends SourceBuilder>(options?: FactoryOptions<TBuilder>) => TsReference<TBuilder, never>) & {
31
33
  refName: string;
32
34
  moduleNameOrfilePath: Nullable<string>;
33
35
  };
34
- declare function createFactory(name: string, moduleNameOrfilePath: string): ReturnType<typeof _createFactory> & {
36
+ declare function createFactory(name: string, moduleNameOrfilePath: string, defaultOptions?: {
37
+ importType?: Nullable<TypeScriptImportType>;
38
+ }): ReturnType<typeof _createFactory> & {
35
39
  moduleNameOrfilePath: string;
36
40
  };
37
- declare function createFactory(name: string, moduleNameOrfilePath?: Nullable<string>): ReturnType<typeof _createFactory>;
38
- declare function _createGenericFactory<TGenericCount extends number | number[]>(name: string, moduleNameOrfilePath?: Nullable<string>): (<TBuilder extends SourceBuilder>(generics: TupleWithCount<TsType<TBuilder>, TGenericCount>, options?: FactoryOptions<TBuilder>) => TsReference<TBuilder, never>) & {
41
+ declare function createFactory(name: string, moduleNameOrfilePath?: Nullable<string>, defaultOptions?: {
42
+ importType?: Nullable<TypeScriptImportType>;
43
+ }): ReturnType<typeof _createFactory>;
44
+ declare function _createGenericFactory<TGenericCount extends number | number[]>(name: string, moduleNameOrfilePath?: Nullable<string>, defaultOptions?: {
45
+ importType?: Nullable<TypeScriptImportType>;
46
+ }): (<TBuilder extends SourceBuilder>(generics: TupleWithCount<TsType<TBuilder>, TGenericCount>, options?: FactoryOptions<TBuilder>) => TsReference<TBuilder, never>) & {
39
47
  refName: string;
40
48
  moduleNameOrfilePath: Nullable<string>;
41
49
  infer: <TBuilder extends SourceBuilder>() => TsReference<TBuilder, never>;
42
50
  };
43
- declare function createGenericFactory<TGenericCount extends number | number[]>(name: string, moduleNameOrfilePath: string): ReturnType<typeof _createGenericFactory<TGenericCount>> & {
51
+ declare function createGenericFactory<TGenericCount extends number | number[]>(name: string, moduleNameOrfilePath: string, defaultOptions?: {
52
+ importType?: Nullable<TypeScriptImportType>;
53
+ }): ReturnType<typeof _createGenericFactory<TGenericCount>> & {
44
54
  moduleNameOrfilePath: string;
45
55
  };
46
- declare function createGenericFactory<TGenericCount extends number | number[]>(name: string, moduleNameOrfilePath?: Nullable<string>): ReturnType<typeof _createGenericFactory<TGenericCount>>;
56
+ declare function createGenericFactory<TGenericCount extends number | number[]>(name: string, moduleNameOrfilePath?: Nullable<string>, defaultOptions?: {
57
+ importType?: Nullable<TypeScriptImportType>;
58
+ }): ReturnType<typeof _createGenericFactory<TGenericCount>>;
47
59
  export declare const tsReference: (<TBuilder extends SourceBuilder>(name: Options<TBuilder>["name"], moduleNameOrfilePath?: Options<TBuilder>["moduleNameOrfilePath"], options?: Prettify<Omit<Options<TBuilder>, "name" | "moduleNameOrfilePath">>) => TsReference<TBuilder, never>) & {
48
60
  factory: typeof createFactory;
49
61
  genericFactory: typeof createGenericFactory;
@@ -1,15 +1,20 @@
1
+ import { TypeScriptExportOptions } from './import-collection';
1
2
  export type TypeScriptComponentOutput = {
2
3
  component: string;
3
4
  filePath?: string;
4
5
  imports: TypeScriptImport[];
5
- additionalExports?: string[];
6
+ additionalExports?: string[] | ({
7
+ name: string;
8
+ } & TypeScriptExportOptions)[];
9
+ kind: 'unknown' | 'interface' | 'type' | 'enum' | 'class' | 'function' | 'variable';
6
10
  };
7
11
  export type TypeScriptExportOutput = {
8
12
  component: string;
9
13
  filePath: string;
10
- };
14
+ } & TypeScriptExportOptions;
11
15
  export type TypeScriptImportKind = 'module' | 'file';
12
16
  export type TypeScriptImportType = 'import' | 'type-import' | 'js-doc';
17
+ export type TypeScriptExportType = 'export' | 'type-export';
13
18
  export type TypeScriptImport = {
14
19
  kind: TypeScriptImportKind;
15
20
  type: TypeScriptImportType;
@@ -2,7 +2,7 @@ import { AppendParam, AppendValue, Nullable, SourceBuilder } from '@goast/core';
2
2
  import { TsNode } from './ast/node';
3
3
  import { TypeScriptGeneratorConfig } from './config';
4
4
  import { TypeScriptModelGeneratorOutput } from './generators';
5
- import { ImportExportCollection, TypeScriptImportOptions } from './import-collection';
5
+ import { ImportExportCollection, TypeScriptExportOptions, TypeScriptImportOptions } from './import-collection';
6
6
  export type TypeScriptAppends<TAdditionalAppends> = TsNode<TypeScriptFileBuilder> | TAdditionalAppends;
7
7
  export type TypeScriptAppendParam<TBuilder extends TypeScriptFileBuilder, TAdditionalAppends> = AppendParam<TBuilder, TypeScriptAppends<TAdditionalAppends>>;
8
8
  export declare function isTypeScriptAppendValue<TBuilder extends TypeScriptFileBuilder = TypeScriptFileBuilder>(value: unknown): value is AppendValue<TBuilder>;
@@ -12,7 +12,7 @@ export declare class TypeScriptFileBuilder<TAdditionalAppends = never> extends S
12
12
  get options(): TypeScriptGeneratorConfig;
13
13
  constructor(filePath?: string, options?: TypeScriptGeneratorConfig);
14
14
  addImport(name: string, moduleNameOrfilePath: string, options?: TypeScriptImportOptions): this;
15
- addExport(name: string, filePath: string): this;
15
+ addExport(name: string, filePath: string, options?: TypeScriptExportOptions): this;
16
16
  clear(): void;
17
17
  toString(addPadding?: boolean): string;
18
18
  protected appendSingle(value: TypeScriptAppendParam<this, TAdditionalAppends>): void;
@@ -1,5 +1,5 @@
1
1
  import { SourceBuilderOptions, StringBuilder } from '@goast/core';
2
- import { TypeScriptImport, TypeScriptImportKind, TypeScriptImportType } from './common-results';
2
+ import { TypeScriptExportType, TypeScriptImport, TypeScriptImportKind, TypeScriptImportType } from './common-results';
3
3
  import { ImportModuleTransformer } from './utils';
4
4
  export type ImportExportCollectionOptions = {
5
5
  filePath?: string;
@@ -10,11 +10,15 @@ export declare const defaultImportExportCollectionOptions: ImportExportCollectio
10
10
  export type TypeScriptImportOptions = {
11
11
  type?: TypeScriptImportType;
12
12
  };
13
+ export type TypeScriptExportOptions = {
14
+ type?: TypeScriptExportType;
15
+ };
13
16
  export declare class ImportExportCollection {
14
17
  private readonly _imports;
15
18
  private readonly _typeImports;
16
19
  private readonly _jsDocImports;
17
20
  private readonly _exports;
21
+ private readonly _typeExports;
18
22
  private readonly _options;
19
23
  constructor(options?: Partial<ImportExportCollectionOptions>);
20
24
  get hasImports(): boolean;
@@ -22,15 +26,16 @@ export declare class ImportExportCollection {
22
26
  get imports(): TypeScriptImport[];
23
27
  private toImport;
24
28
  addImport(importName: string, fromModule: string, options?: TypeScriptImportOptions): void;
25
- getImportMap(type: TypeScriptImportType): Map<string, Set<string>>;
26
- addExport(exportName: string, fromModule: string): void;
29
+ addExport(exportName: string, fromModule: string, options?: TypeScriptExportOptions): void;
27
30
  clear(): void;
28
31
  toString(options: Partial<SourceBuilderOptions>): string;
29
32
  writeTo(builder: StringBuilder): void;
30
- protected writeImportsExports(builder: StringBuilder, keyword: 'import' | 'export' | 'import type' | ' * @import', data: (readonly [string, TypeScriptImportKind, string[]])[], options: {
33
+ protected writeImportsExports(builder: StringBuilder, keyword: 'import' | 'export' | 'import type' | 'export type' | ' * @import', data: (readonly [string, TypeScriptImportKind, string[]])[], options: {
31
34
  useSingleQuotes: boolean;
32
35
  }): void;
33
36
  protected sortAndResolve(data: Map<string, Set<string>>, filePath: string | undefined, importModuleTransformer: ImportModuleTransformer): (readonly [string, TypeScriptImportKind, string[]])[];
34
37
  protected getImportKind(fromModule: string): TypeScriptImportKind;
35
38
  protected resolveModulePath(fromModule: string, filePath: string | undefined, importModuleTransformer: ImportModuleTransformer): [string, TypeScriptImportKind];
39
+ protected getImportMap(type: TypeScriptImportType): Map<string, Set<string>>;
40
+ protected getExportMap(type: TypeScriptExportType): Map<string, Set<string>>;
36
41
  }