Skip to content

Commit dcad5ac

Browse files
author
devgioele
committed
upgrade tsconfig and fix new errors
1 parent a607663 commit dcad5ac

8 files changed

Lines changed: 79 additions & 35 deletions

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
"node": "^16"
99
},
1010
"scripts": {
11-
"build": "npm run build:node && npm run build:esm",
12-
"build:node": "tsc",
13-
"build:esm": "tsc --project tsconfig.esnext.json",
11+
"build": "rimraf dist && npm run build:types && npm run build:esm && npm run build:cjs",
12+
"build:esm": "tsc -p tsconfig.esm.json",
13+
"build:cjs": "tsc -p tsconfig.cjs.json",
14+
"build:types": "tsc -p tsconfig.types.json",
1415
"lint": "eslint --ext js,ts,tsx src",
1516
"lint:fix": "npm run lint -- --fix",
1617
"typecheck": "tsc --noEmit",
@@ -65,8 +66,9 @@
6566
"react": "^18.0.0",
6667
"react-dom": "^18.0.0",
6768
"react-router-dom": "^6.7.0",
69+
"rimraf": "^5.0.1",
6870
"ts-jest": "^28.0.5",
69-
"typescript": "^4.7.4"
71+
"typescript": "^5.1.6"
7072
},
7173
"peerDependencies": {
7274
"next": "^12.0.0 || ^13.0.0",

src/nextRouterPagination.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ParsedUrlQuery } from 'querystring'
22
import { useRouter } from 'next/router'
33
import { useCallback } from 'react'
4-
54
import { IndexType, IUseQueryAndPagination, QueryParameters } from './types'
65
import { convert } from './utils'
76

@@ -64,7 +63,7 @@ export const useQueryAndPagination: IUseQueryAndPagination = function (config) {
6463
) {
6564
delete params[parameter]
6665
} else {
67-
params[parameter] = queryParameters[parameter].toString()
66+
params[parameter] = queryParameters[parameter]?.toString()
6867
}
6968
}
7069

src/reactRouterPagination.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const useQueryAndPagination: IUseQueryAndPagination = function (config) {
4242
) {
4343
params.delete(parameter)
4444
} else {
45-
params.set(parameter, queryParameters[parameter].toString())
45+
params.set(parameter, queryParameters[parameter] as string)
4646
}
4747
}
4848

tsconfig.cjs.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "./dist/cjs",
6+
"declaration": false,
7+
"declarationMap": false,
8+
"sourceMap": false,
9+
"removeComments": true
10+
},
11+
"exclude": ["node_modules", "**/__test__/*", "**/__tests__/*"],
12+
"include": ["src"]
13+
}

tsconfig.esm.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "es2020",
5+
"outDir": "./dist/esm",
6+
"declaration": false,
7+
"declarationMap": false,
8+
"sourceMap": false,
9+
"removeComments": true
10+
},
11+
"exclude": ["node_modules", "**/__test__/*", "**/__tests__/*"],
12+
"include": ["src"]
13+
}

tsconfig.esnext.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

tsconfig.json

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
{
2-
"compilerOptions": {
3-
"target": "es5",
4-
"jsx": "react",
5-
"esModuleInterop": true,
6-
"outDir": "./dist",
7-
"declaration": true,
8-
"strict": true,
9-
"sourceMap": true,
10-
"skipLibCheck": true
11-
},
12-
"include": ["src"],
13-
"exclude": ["node_modules", "**/__test__/*", "**/__tests__/*"]
2+
"compilerOptions": {
3+
"target": "es2020",
4+
"moduleResolution": "node",
5+
"esModuleInterop": true,
6+
"resolveJsonModule": true,
7+
"strict": true,
8+
"noUnusedLocals": true,
9+
"noUnusedParameters": true,
10+
"noImplicitReturns": true,
11+
"noImplicitOverride": true,
12+
"noFallthroughCasesInSwitch": true,
13+
"noUncheckedIndexedAccess": true,
14+
"forceConsistentCasingInFileNames": true,
15+
"allowUnreachableCode": false,
16+
"downlevelIteration": true,
17+
"isolatedModules": true,
18+
"jsx": "react-jsx",
19+
"importHelpers": true,
20+
"outDir": "./dist",
21+
"declaration": true,
22+
"sourceMap": true,
23+
"skipLibCheck": true
24+
},
25+
"include": ["src"],
26+
"exclude": ["node_modules", "**/__test__/*", "**/__tests__/*"]
1427
}

tsconfig.types.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"emitDeclarationOnly": true,
5+
"outDir": "./dist/types",
6+
"declaration": true,
7+
"declarationMap": true,
8+
"removeComments": false
9+
},
10+
"exclude": [
11+
"src/vitest.ts",
12+
"**/__test__/*",
13+
"**/__tests__/*",
14+
"**/*.stories.tsx",
15+
"**/*.stories.ts",
16+
"src/examples/*",
17+
".storybook/*"
18+
],
19+
"include": ["src"]
20+
}

0 commit comments

Comments
 (0)