Skip to content

Commit

Permalink
Merge pull request #319 from belgattitude/ts-4.4
Browse files Browse the repository at this point in the history
Typescript 4.4.2
  • Loading branch information
belgattitude authored Aug 27, 2021
2 parents df874a5 + 2ccb056 commit 1e41205
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 43 deletions.
9 changes: 9 additions & 0 deletions .changeset/hip-crews-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'blog-app': minor
'web-app': minor
'@your-org/core-lib': minor
'@your-org/db-main-prisma': minor
'@your-org/ui-lib': minor
---

Updated to Typescript 4.4.2 strict ("useUnknownInCatchVariables": true)
4 changes: 2 additions & 2 deletions apps/blog-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@testing-library/jest-dom": "5.14.1",
"@testing-library/react": "12.0.0",
"@testing-library/react-hooks": "7.0.1",
"@types/node": "16.7.1",
"@types/node": "16.7.2",
"@types/react": "17.0.19",
"@types/react-dom": "17.0.9",
"@typescript-eslint/eslint-plugin": "4.29.3",
Expand Down Expand Up @@ -86,7 +86,7 @@
"sync-directory": "2.2.22",
"tailwindcss": "2.2.8",
"ts-jest": "27.0.5",
"typescript": "4.3.5"
"typescript": "4.4.2"
},
"dependencies": {
"@babel/core": "7.15.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@testing-library/react-hooks": "7.0.1",
"@types/cors": "2.8.12",
"@types/graphql": "14.5.0",
"@types/node": "16.7.1",
"@types/node": "16.7.2",
"@types/react": "17.0.19",
"@types/react-dom": "17.0.9",
"@typescript-eslint/eslint-plugin": "4.29.3",
Expand Down Expand Up @@ -98,7 +98,7 @@
"tailwindcss": "2.2.8",
"ts-jest": "27.0.5",
"ts-node": "10.2.1",
"typescript": "4.3.5"
"typescript": "4.4.2"
},
"dependencies": {
"@babel/core": "7.15.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/web-app/src/pages/api/rest/poem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function handleListPoems(
)
);
} catch (e) {
const apiError = JsonApiErrorFactory.fromTsedException(e);
const apiError = JsonApiErrorFactory.fromCatchVariable(e);
return res
.status(apiError.status ?? 500)
.json(JsonApiResponseFactory.fromError(apiError));
Expand Down
2 changes: 1 addition & 1 deletion apps/web-app/src/pages/api/rest/post/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default async function handleGetPost(
JsonApiResponseFactory.fromSuccess(await postRepo.getPost(postId))
);
} catch (e) {
const apiError = JsonApiErrorFactory.fromTsedException(e);
const apiError = JsonApiErrorFactory.fromCatchVariable(e);
return res
.status(apiError.status ?? 500)
.json(JsonApiResponseFactory.fromError(apiError));
Expand Down
2 changes: 1 addition & 1 deletion apps/web-app/src/pages/api/rest/post/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function handleListPosts(
)
);
} catch (e) {
const apiError = JsonApiErrorFactory.fromTsedException(e);
const apiError = JsonApiErrorFactory.fromCatchVariable(e);
return res
.status(apiError.status ?? 500)
.json(JsonApiResponseFactory.fromError(apiError));
Expand Down
6 changes: 3 additions & 3 deletions packages/core-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"fix:all-files": "eslint . --ext .ts,.tsx,.js,.jsx --fix"
},
"dependencies": {
"@tsed/exceptions": "^6.63.2",
"@tsed/exceptions": "^6.64.0",
"dequal": "^2.0.2"
},
"devDependencies": {
"@testing-library/jest-dom": "5.14.1",
"@testing-library/react": "12.0.0",
"@testing-library/react-hooks": "7.0.1",
"@types/node": "16.7.1",
"@types/node": "16.7.2",
"@types/react": "17.0.19",
"@types/react-dom": "17.0.9",
"@typescript-eslint/eslint-plugin": "4.29.3",
Expand All @@ -61,7 +61,7 @@
"rimraf": "3.0.2",
"shell-quote": "1.7.2",
"ts-jest": "27.0.5",
"typescript": "4.3.5"
"typescript": "4.4.2"
},
"peerDependencies": {
"react": "^16.14.0 || ^17.0.2",
Expand Down
11 changes: 11 additions & 0 deletions packages/core-lib/src/api/json-api/json-api-error.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ import { JsonApiError } from './json-api-response.types';
import { Exception } from '@tsed/exceptions';

export class JsonApiErrorFactory {
static fromCatchVariable = (
error: unknown,
defaultHttpStatus = 500
): JsonApiError => {
const e =
typeof error === 'string' || error instanceof Error
? error
: `Unknown error (type of catched variable: ${typeof error}`;
return JsonApiErrorFactory.fromTsedException(e, defaultHttpStatus);
};

static fromTsedException = (
exception: Exception | Error | string,
/** fallback http status if it can't be inferred from exception */
Expand Down
4 changes: 2 additions & 2 deletions packages/db-main-prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"fix:all-files": "eslint . --ext .ts,.tsx,.js,.jsx --fix"
},
"devDependencies": {
"@types/node": "16.7.1",
"@types/node": "16.7.2",
"@typescript-eslint/eslint-plugin": "4.29.3",
"@typescript-eslint/parser": "4.29.3",
"camelcase": "6.2.0",
Expand All @@ -51,7 +51,7 @@
"transliteration": "2.2.0",
"ts-jest": "27.0.5",
"ts-node": "10.2.1",
"typescript": "4.3.5"
"typescript": "4.4.2"
},
"dependencies": {
"@prisma/client": "2.30.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@testing-library/jest-dom": "5.14.1",
"@testing-library/react": "12.0.0",
"@testing-library/react-hooks": "7.0.1",
"@types/node": "16.7.1",
"@types/node": "16.7.2",
"@types/react": "17.0.19",
"@types/react-dom": "17.0.9",
"@typescript-eslint/eslint-plugin": "4.29.3",
Expand All @@ -57,7 +57,7 @@
"rimraf": "3.0.2",
"shell-quote": "1.7.2",
"ts-jest": "27.0.5",
"typescript": "4.3.5"
"typescript": "4.4.2"
},
"peerDependencies": {
"react": "^16.14.0 || ^17.0.2",
Expand Down
8 changes: 3 additions & 5 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"strict": true,
"useUnknownInCatchVariables": true,
"allowJs": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
Expand All @@ -10,8 +11,5 @@
"resolveJsonModule": true,
"isolatedModules": true
},
"exclude": [
"node_modules",
".yarn"
]
}
"exclude": ["node_modules", ".yarn"]
}
48 changes: 24 additions & 24 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3351,7 +3351,7 @@ __metadata:
languageName: node
linkType: hard

"@tsed/exceptions@npm:6.64.0, @tsed/exceptions@npm:^6.63.2":
"@tsed/exceptions@npm:6.64.0, @tsed/exceptions@npm:^6.64.0":
version: 6.64.0
resolution: "@tsed/exceptions@npm:6.64.0"
dependencies:
Expand Down Expand Up @@ -3562,10 +3562,10 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:*, @types/node@npm:16.7.1":
version: 16.7.1
resolution: "@types/node@npm:16.7.1"
checksum: fcf1a2c7b1f19c2201574b2110176b49c6efd824a39b2ed8ac3e6688740e2a35bef95a3334dfa345f4bd4873fd8b79d8ac8cfcc9fcd3d2f4f8f993c2c37ce4ab
"@types/node@npm:*, @types/node@npm:16.7.2":
version: 16.7.2
resolution: "@types/node@npm:16.7.2"
checksum: aef77c109e2fd93b5dc6ec0a57a0878aaaa58adf0e63d9618d67b116ad3f2a3eb2589a99deaf9fda4a0805068b2533e3d2cf8e8dc3572251c498ec3dc929a76c
languageName: node
linkType: hard

Expand Down Expand Up @@ -3833,8 +3833,8 @@ __metadata:
"@testing-library/jest-dom": 5.14.1
"@testing-library/react": 12.0.0
"@testing-library/react-hooks": 7.0.1
"@tsed/exceptions": ^6.63.2
"@types/node": 16.7.1
"@tsed/exceptions": ^6.64.0
"@types/node": 16.7.2
"@types/react": 17.0.19
"@types/react-dom": 17.0.9
"@typescript-eslint/eslint-plugin": 4.29.3
Expand All @@ -3859,7 +3859,7 @@ __metadata:
rimraf: 3.0.2
shell-quote: 1.7.2
ts-jest: 27.0.5
typescript: 4.3.5
typescript: 4.4.2
peerDependencies:
react: ^16.14.0 || ^17.0.2
react-dom: ^16.14.0 || ^17.0.2
Expand All @@ -3876,7 +3876,7 @@ __metadata:
resolution: "@your-org/db-main-prisma@workspace:packages/db-main-prisma"
dependencies:
"@prisma/client": 2.30.0
"@types/node": 16.7.1
"@types/node": 16.7.2
"@typescript-eslint/eslint-plugin": 4.29.3
"@typescript-eslint/parser": 4.29.3
camelcase: 6.2.0
Expand All @@ -3898,7 +3898,7 @@ __metadata:
transliteration: 2.2.0
ts-jest: 27.0.5
ts-node: 10.2.1
typescript: 4.3.5
typescript: 4.4.2
languageName: unknown
linkType: soft

Expand All @@ -3909,7 +3909,7 @@ __metadata:
"@testing-library/jest-dom": 5.14.1
"@testing-library/react": 12.0.0
"@testing-library/react-hooks": 7.0.1
"@types/node": 16.7.1
"@types/node": 16.7.2
"@types/react": 17.0.19
"@types/react-dom": 17.0.9
"@typescript-eslint/eslint-plugin": 4.29.3
Expand All @@ -3934,7 +3934,7 @@ __metadata:
rimraf: 3.0.2
shell-quote: 1.7.2
ts-jest: 27.0.5
typescript: 4.3.5
typescript: 4.4.2
peerDependencies:
react: ^16.14.0 || ^17.0.2
react-dom: ^16.14.0 || ^17.0.2
Expand Down Expand Up @@ -4897,7 +4897,7 @@ __metadata:
"@testing-library/jest-dom": 5.14.1
"@testing-library/react": 12.0.0
"@testing-library/react-hooks": 7.0.1
"@types/node": 16.7.1
"@types/node": 16.7.2
"@types/react": 17.0.19
"@types/react-dom": 17.0.9
"@typescript-eslint/eslint-plugin": 4.29.3
Expand Down Expand Up @@ -4935,7 +4935,7 @@ __metadata:
sync-directory: 2.2.22
tailwindcss: 2.2.8
ts-jest: 27.0.5
typescript: 4.3.5
typescript: 4.4.2
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -16563,23 +16563,23 @@ resolve@^2.0.0-next.3:
languageName: node
linkType: hard

"typescript@4.3.5, typescript@^4.1.3":
version: 4.3.5
resolution: "typescript@npm:4.3.5"
"typescript@4.4.2, typescript@^4.1.3":
version: 4.4.2
resolution: "typescript@npm:4.4.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: bab033b5e2b0790dd35b77fd005df976ef80b8d84fd2c6e63cc31808151875beae9216e5a315fe7068e8499905c3c354248fe83272cdfc13b7705635f0c66c97
checksum: 194e08e9d1971d667d6fd1a0554616b7022312a2319d70e81a64e502a265992061ee7817ed9a69b52bbabe7a9b85e7938cb8c11c433e40a516b277f8c4dacd51
languageName: node
linkType: hard

"typescript@patch:typescript@4.3.5#~builtin<compat/typescript>, typescript@patch:typescript@^4.1.3#~builtin<compat/typescript>":
version: 4.3.5
resolution: "typescript@patch:typescript@npm%3A4.3.5#~builtin<compat/typescript>::version=4.3.5&hash=d8b4e7"
"typescript@patch:typescript@4.4.2#~builtin<compat/typescript>, typescript@patch:typescript@^4.1.3#~builtin<compat/typescript>":
version: 4.4.2
resolution: "typescript@patch:typescript@npm%3A4.4.2#~builtin<compat/typescript>::version=4.4.2&hash=d8b4e7"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: bc2c4fdf0f1557fdafe4ef74848c72ebd9c8c60829568248f869121aea2bb20e16649a252431d0acb185ec118143be22bed73d08f64379557810d82756afedde
checksum: 11d6ab6e868117908c388401e2ac06d503c5c8709115ab80ee69a1a6352c1f98471d1e595636bfe6a2d6b20b03a44df6bb2d3d198cea97c0c328968cd18d2b70
languageName: node
linkType: hard

Expand Down Expand Up @@ -17027,7 +17027,7 @@ resolve@^2.0.0-next.3:
"@tsed/exceptions": 6.64.0
"@types/cors": 2.8.12
"@types/graphql": 14.5.0
"@types/node": 16.7.1
"@types/node": 16.7.2
"@types/react": 17.0.19
"@types/react-dom": 17.0.9
"@typescript-eslint/eslint-plugin": 4.29.3
Expand Down Expand Up @@ -17085,7 +17085,7 @@ resolve@^2.0.0-next.3:
ts-jest: 27.0.5
ts-node: 10.2.1
type-fest: 2.1.0
typescript: 4.3.5
typescript: 4.4.2
languageName: unknown
linkType: soft

Expand Down

2 comments on commit 1e41205

@vercel
Copy link

@vercel vercel bot commented on 1e41205 Aug 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 1e41205 Aug 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.