Skip to content

Commit 13c9577

Browse files
committed
fix: do not use named imports from typescript module
1 parent a204719 commit 13c9577

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

.changeset/tasty-candles-retire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix: do not use named imports from typescript module

packages/openapi-ts/src/compiler/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import * as utils from './utils';
1010
export type { Property } from './typedef';
1111
export type { FunctionParameter } from './types';
1212
export type { Comments } from './utils';
13-
export type { ClassElement, Node, TypeNode } from 'typescript';
1413

1514
export const compiler = {
1615
anonymousFunction: types.createAnonymousFunction,

packages/openapi-ts/src/generate/files.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
33

4-
import type ts from 'typescript';
5-
import type { ParsedCommandLine } from 'typescript';
6-
import { ModuleResolutionKind } from 'typescript';
4+
import ts from 'typescript';
75

86
import { compiler } from '../compiler';
97
import { type ImportExportItemObject, tsNodeToString } from '../compiler/utils';
@@ -285,14 +283,14 @@ export class TypeScriptFile {
285283
return [name, 'gen', extension].filter(Boolean).join('.');
286284
}
287285

288-
private _toString(separator: string, tsConfig: ParsedCommandLine | null) {
286+
private _toString(separator: string, tsConfig: ts.ParsedCommandLine | null) {
289287
let output: Array<string> = [];
290288
if (this._headers.length) {
291289
output.push(this._headers.join('\n'));
292290
}
293291

294292
const shouldAppendJs =
295-
tsConfig?.options.moduleResolution === ModuleResolutionKind.NodeNext;
293+
tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.NodeNext;
296294

297295
const importsStringArray: Array<string> = [];
298296

@@ -326,7 +324,7 @@ export class TypeScriptFile {
326324
return output.join(separator);
327325
}
328326

329-
public write(separator = '\n', tsConfig: ParsedCommandLine | null = null) {
327+
public write(separator = '\n', tsConfig: ts.ParsedCommandLine | null = null) {
330328
if (this.isEmpty()) {
331329
this.remove({ force: true });
332330
return;

packages/openapi-ts/src/generate/output.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'node:path';
22

3-
import { ModuleResolutionKind } from 'typescript';
3+
import ts from 'typescript';
44

55
import { compiler } from '../compiler';
66
import { parseIR } from '../ir/parser';
@@ -157,7 +157,7 @@ export const generateOutput = async ({ context }: { context: IR.Context }) => {
157157
findTsConfigPath(context.config.output.tsConfigPath),
158158
);
159159
const shouldAppendJs =
160-
tsConfig?.options.moduleResolution === ModuleResolutionKind.NodeNext;
160+
tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.NodeNext;
161161

162162
for (const file of Object.values(context.files)) {
163163
const fileName = file.nameWithoutExtension();

packages/openapi-ts/src/generate/tsConfig.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import fs from 'node:fs';
22
import path from 'node:path';
33
import { fileURLToPath } from 'node:url';
44

5-
import type { ParsedCommandLine } from 'typescript';
65
import ts from 'typescript';
76

87
const __filename = fileURLToPath(import.meta.url);
@@ -41,7 +40,7 @@ export const findTsConfigPath = (
4140

4241
export const loadTsConfig = (
4342
configPath: string | null,
44-
): ParsedCommandLine | null => {
43+
): ts.ParsedCommandLine | null => {
4544
if (!configPath) {
4645
return null;
4746
}

packages/openapi-ts/src/plugins/@hey-api/sdk/plugin-legacy.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import type {
2-
ClassElement,
3-
Comments,
4-
FunctionParameter,
5-
Node,
6-
} from '../../../compiler';
1+
import type ts from 'typescript';
2+
3+
import type { Comments, FunctionParameter } from '../../../compiler';
74
import { compiler } from '../../../compiler';
85
import type {
96
FunctionTypeParameter,
@@ -36,7 +33,7 @@ import type { Plugin } from '../../types';
3633
import { getClientPlugin } from '../client-core/utils';
3734
import type { Config } from './types';
3835

39-
type OnNode = (node: Node) => void;
36+
type OnNode = (node: ts.Node) => void;
4037
type OnImport = (name: string) => void;
4138

4239
export const generateImport = ({
@@ -712,7 +709,7 @@ const processService = ({
712709
return;
713710
}
714711

715-
let members: ClassElement[] = service.operations.map((operation) => {
712+
let members: ts.ClassElement[] = service.operations.map((operation) => {
716713
const node = compiler.methodDeclaration({
717714
accessLevel: 'public',
718715
comment: toOperationComment(operation),

packages/openapi-ts/src/plugins/@hey-api/typescript/plugin-legacy.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { EnumDeclaration } from 'typescript';
1+
import type ts from 'typescript';
22

3-
import { type Comments, compiler, type Node } from '../../../compiler';
3+
import { type Comments, compiler } from '../../../compiler';
44
import { TypeScriptFile } from '../../../generate/files';
55
import { isOperationParameterRequired } from '../../../openApi';
66
import type {
@@ -29,7 +29,7 @@ import type { Config } from './types';
2929
export interface TypesProps {
3030
client: Client;
3131
model: Model;
32-
onNode: (node: Node) => void;
32+
onNode: (node: ts.Node) => void;
3333
onRemoveNode?: VoidFunction;
3434
}
3535

@@ -131,7 +131,7 @@ export const generateType = ({
131131
const processComposition = (props: TypesProps) => {
132132
const config = getConfig();
133133

134-
const enumDeclarations = [] as EnumDeclaration[];
134+
const enumDeclarations = [] as ts.EnumDeclaration[];
135135

136136
processType(props);
137137

@@ -149,7 +149,7 @@ const processComposition = (props: TypesProps) => {
149149
...props,
150150
model: enumerator,
151151
onNode: (node) => {
152-
enumDeclarations.push(node as EnumDeclaration);
152+
enumDeclarations.push(node as ts.EnumDeclaration);
153153
},
154154
});
155155
});

packages/openapi-ts/src/utils/type.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { compiler, type Property, type TypeNode } from '../compiler';
1+
import type ts from 'typescript';
2+
3+
import { compiler, type Property } from '../compiler';
24
import type { Model } from '../openApi';
35
import { sanitizeOperationParameterName } from '../openApi';
46
import type { Client } from '../types/client';
@@ -191,7 +193,7 @@ const typeInterface = (model: Model) => {
191193
});
192194
};
193195

194-
export const toType = (model: Model): TypeNode => {
196+
export const toType = (model: Model): ts.TypeNode => {
195197
switch (model.export) {
196198
case 'all-of':
197199
return typeUnionOrIntersection({

0 commit comments

Comments
 (0)