Skip to content

Commit b5f1e4b

Browse files
committed
refactor: remove TypeScript from peer dependencies
1 parent 236360b commit b5f1e4b

13 files changed

Lines changed: 63 additions & 61 deletions

File tree

.changeset/common-results-kneel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/codegen-core": patch
3+
---
4+
5+
**internal**: remove TypeScript from peer dependencies

.changeset/fruity-adults-invite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/shared": patch
3+
---
4+
5+
**internal**: remove TypeScript from peer dependencies

.changeset/rude-games-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/types": patch
3+
---
4+
5+
**internal**: remove TypeScript from peer dependencies

packages/codegen-core/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@
5656
"eslint": "9.39.1",
5757
"typescript": "5.9.3"
5858
},
59-
"peerDependencies": {
60-
"typescript": ">=5.5.3"
61-
},
6259
"engines": {
6360
"node": ">=20.19.0"
6461
}

packages/openapi-python/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@
7373
"typescript": "5.9.3",
7474
"yaml": "2.8.2"
7575
},
76-
"peerDependencies": {
77-
"typescript": ">=5.5.3"
78-
},
7976
"engines": {
8077
"node": ">=20.19.0"
8178
}

packages/openapi-ts/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
"@hey-api/types": "workspace:*",
7676
"ansi-colors": "4.1.3",
7777
"color-support": "1.1.3",
78-
"commander": "14.0.3"
78+
"commander": "14.0.3",
79+
"get-tsconfig": "4.13.6"
7980
},
8081
"devDependencies": {
8182
"@angular/common": "21.1.2",

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { fileURLToPath } from 'node:url';
33

44
import { log } from '@hey-api/codegen-core';
55
import type { PostProcessor, UserPostProcessor } from '@hey-api/shared';
6-
import { findTsConfigPath, loadTsConfig, resolveSource, valueToObject } from '@hey-api/shared';
6+
import { findTsConfigPath, resolveSource, valueToObject } from '@hey-api/shared';
77
import type { MaybeArray } from '@hey-api/types';
8-
import ts from 'typescript';
8+
import type { TsConfigJsonResolved } from 'get-tsconfig';
9+
import { parseTsconfig } from 'get-tsconfig';
910

1011
import { postProcessors } from './postprocess';
1112
import type { Output, UserOutput } from './types';
@@ -64,10 +65,14 @@ export function getOutput(userConfig: { output: MaybeArray<string | UserOutput>
6465
output.tsConfig = loadTsConfig(findTsConfigPath(__dirname, output.tsConfigPath));
6566
if (
6667
output.importFileExtension === undefined &&
67-
(output.tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.NodeNext ||
68-
output.tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.Node16 ||
69-
output.tsConfig?.options.module === ts.ModuleKind.NodeNext ||
70-
output.tsConfig?.options.module === ts.ModuleKind.Node16)
68+
(output.tsConfig?.compilerOptions?.moduleResolution === 'nodenext' ||
69+
output.tsConfig?.compilerOptions?.moduleResolution === 'NodeNext' ||
70+
output.tsConfig?.compilerOptions?.moduleResolution === 'node16' ||
71+
output.tsConfig?.compilerOptions?.moduleResolution === 'Node16' ||
72+
output.tsConfig?.compilerOptions?.module === 'nodenext' ||
73+
output.tsConfig?.compilerOptions?.module === 'NodeNext' ||
74+
output.tsConfig?.compilerOptions?.module === 'node16' ||
75+
output.tsConfig?.compilerOptions?.module === 'Node16')
7176
) {
7277
output.importFileExtension = '.js';
7378
}
@@ -134,3 +139,15 @@ function normalizePostProcess(input: UserOutput['postProcess']): ReadonlyArray<P
134139
};
135140
});
136141
}
142+
143+
function loadTsConfig(configPath: string | null): TsConfigJsonResolved | null {
144+
if (!configPath) {
145+
return null;
146+
}
147+
148+
try {
149+
return parseTsconfig(configPath);
150+
} catch {
151+
throw new Error(`Couldn't read tsconfig from path: ${configPath}`);
152+
}
153+
}

packages/openapi-ts/src/config/output/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { BaseOutput, BaseUserOutput, UserPostProcessor } from '@hey-api/shared';
22
import type { AnyString } from '@hey-api/types';
3-
import type ts from 'typescript';
3+
import type { TsConfigJsonResolved } from 'get-tsconfig';
44

55
import type { Formatters, Linters, PostProcessorPreset } from './postprocess';
66

@@ -85,7 +85,7 @@ export type Output = BaseOutput & {
8585
* The parsed TypeScript configuration used to generate the output.
8686
* If no `tsconfig` file path was provided or found, this will be `null`.
8787
*/
88-
tsConfig: ts.ParsedCommandLine | null;
88+
tsConfig: TsConfigJsonResolved | null;
8989
/**
9090
* Relative or absolute path to the tsconfig file we should use to
9191
* generate the output. If a path to tsconfig file is not provided, we

packages/shared/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@
5656
"typescript": "5.9.3",
5757
"yaml": "2.8.2"
5858
},
59-
"peerDependencies": {
60-
"typescript": ">=5.5.3"
61-
},
6259
"engines": {
6360
"node": ">=20.19.0"
6461
}

packages/shared/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export type {
117117
PluginContext,
118118
PluginNames,
119119
} from './plugins/types';
120-
export { findPackageJson, findTsConfigPath, loadPackageJson, loadTsConfig } from './tsConfig';
120+
export { findPackageJson, findTsConfigPath, loadPackageJson } from './tsConfig';
121121
export type { Logs } from './types/logs';
122122
export type { WatchValues } from './types/watch';
123123
export { escapeComment } from './utils/escape';

0 commit comments

Comments
 (0)