Skip to content

Commit

Permalink
fix(template): tsdk type error in some projects
Browse files Browse the repository at this point in the history
  • Loading branch information
suhaotian committed Feb 23, 2024
1 parent 6be35b2 commit d08cba0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
This is the log of notable changes to the `tsdk` that are developer-facing.


### 0.1.8 2024/2/23

- Fix: `RequestConfig` type in `gen-api.ts` should be `XiorRequestConfig` when `httpLib: 'xior'`
- Fix: run sync-sdk error, `fe-sdk-template` add `"lib": ["DOM", "ES2015", "ES5"],` to `tsconfig.json`

### 0.1.7 2024/2/20

- Chore: bump `xior` version to v0.0.5
Expand Down
2 changes: 1 addition & 1 deletion packages/tsdk-server-adapters/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsdk-server-adapters",
"version": "0.1.7",
"version": "0.1.8",
"main": "lib/index.js",
"repository": "tsdk-monorepo/tsdk",
"bugs": "https://github.com/tsdk-monorepo/tsdk/issues",
Expand Down
4 changes: 3 additions & 1 deletion packages/tsdk/fe-sdk-template/src/gen-api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { RequestConfig } from './axios';
import type { RequestConfig as AxiosRequestConfig } from './axios';
import { NoHandlerError } from './error';
import { APIConfig, ObjectLiteral } from './shared/tsdk-helper';
import type { XiorRequestConfig } from './xior';

type RequestConfig<T> = AxiosRequestConfig<T>;

let handler = (
apiConfig: APIConfig,
requestData: any,
Expand Down
1 change: 1 addition & 0 deletions packages/tsdk/fe-sdk-template/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"declaration": true,
"target": "ES5",
"outDir": "lib",
"lib": ["DOM", "ES2015", "ES5"],
"incremental": true,
"skipLibCheck": true,
"resolveJsonModule": true
Expand Down
2 changes: 1 addition & 1 deletion packages/tsdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsdk",
"version": "0.1.7",
"version": "0.1.8",
"description": "Type-safe API development and code share tool for TypeScript projects.",
"repository": "tsdk-monorepo/tsdk",
"bugs": "https://github.com/tsdk-monorepo/tsdk/issues",
Expand Down
13 changes: 12 additions & 1 deletion packages/tsdk/src/sync-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function deleteSDKFolder() {

export async function syncAPI() {
console.log(symbols.bullet, 'generating APIs');

await replaceGenAPI();
const pkgJSON = require(path.join(baseDir, 'package.json'));
const apiconfs = require(path.join(baseDir, 'lib', `${config.apiconfExt}-refs`));

Expand Down Expand Up @@ -382,3 +382,14 @@ export function copyPermissionsJSON() {
overwrite: true,
});
}

export async function replaceGenAPI() {
if (config.httpLib === 'xior') {
const genAPIfile = path.join(ensureDir, 'src', 'gen-api.ts');
const res = await fsExtra.readFile(genAPIfile, 'utf-8');
return fsExtra.writeFile(
genAPIfile,
res.replace('= AxiosRequestConfig<T>', '= XiorRequestConfig<T>')
);
}
}

0 comments on commit d08cba0

Please sign in to comment.