bump typescript to 4.5

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-01-18 00:08:58 +01:00
parent 4c176a81d6
commit 08fa6a604a
7 changed files with 92 additions and 14 deletions
+40
View File
@@ -0,0 +1,40 @@
---
'@backstage/cli': minor
---
Removed the `typescript` dependency from the Backstage CLI in order to decouple the TypeScript version in Backstage projects. To keep using a specific TypeScript version, be sure to add an explicit dependency in your root `package.json`:
```json
"dependencies": {
...
"typescript": "~4.5.4",
}
```
We recommend using a `~` version range since TypeScript releases do not adhere to semver.
It may be the case that you end up with errors if upgrade the TypeScript version. This is because there was a change to TypeScript not long ago that defaulted the type of errors caught in `catch` blocks to `unknown`. You can work around this by adding `"useUnknownInCatchVariables": false` to the `"compilerOptions"` in your `tsconfig.json`:
```json
"compilerOptions": {
...
"useUnknownInCatchVariables": false
}
```
Another option is to use the utilities from `@backstage/errors` to assert the type of errors caught in `catch` blocks:
```ts
import { assertError, isError } from '@backstage/errors';
try {
...
} catch (error) {
assertError(error);
...
// OR
if (isError(error)) {
...
}
}
```
+42
View File
@@ -0,0 +1,42 @@
---
'@backstage/create-app': patch
---
The app template has been updated to add an explicit dependency on `typescript` in the root `package.json`. This is because it was removed as a dependency of `@backstage/cli` in order to decouple the TypeScript versioning in Backstage projects.
To apply this change in an existing app, add a `typescript` dependency to your `package.json` in the project root:
```json
"dependencies": {
...
"typescript": "~4.5.4",
}
```
We recommend using a `~` version range since TypeScript releases do not adhere to semver.
It may be the case that you end up with errors if upgrade the TypeScript version. This is because there was a change to TypeScript not long ago that defaulted the type of errors caught in `catch` blocks to `unknown`. You can work around this by adding `"useUnknownInCatchVariables": false` to the `"compilerOptions"` in your `tsconfig.json`:
```json
"compilerOptions": {
...
"useUnknownInCatchVariables": false
}
```
Another option is to use the utilities from `@backstage/errors` to assert the type of errors caught in `catch` blocks:
```ts
import { assertError, isError } from '@backstage/errors';
try {
...
} catch (error) {
assertError(error);
...
// OR
if (isError(error)) {
...
}
}
```
+1 -1
View File
@@ -79,7 +79,7 @@
"prettier": "^2.2.1",
"shx": "^0.3.2",
"ts-node": "^10.4.0",
"typescript": "~4.3.5",
"typescript": "~4.5.4",
"yarn-lock-check": "^1.0.5"
},
"prettier": "@spotify/prettier-config",
-1
View File
@@ -105,7 +105,6 @@
"sucrase": "^3.20.2",
"tar": "^6.1.2",
"terser-webpack-plugin": "^5.1.3",
"typescript": "^4.0.3",
"util": "^0.12.3",
"webpack": "^5.48.0",
"webpack-dev-server": "4.3.1",
@@ -34,7 +34,8 @@
"@spotify/prettier-config": "^12.0.0",
"concurrently": "^6.0.0",
"lerna": "^4.0.0",
"prettier": "^2.3.2"
"prettier": "^2.3.2",
"typescript": "~4.5.4"
},
"prettier": "@spotify/prettier-config",
"lint-staged": {
+2 -1
View File
@@ -8,6 +8,7 @@
],
"compilerOptions": {
"outDir": "dist-types",
"rootDir": "."
"rootDir": ".",
"useUnknownInCatchVariables": false
}
}
+5 -10
View File
@@ -27648,21 +27648,16 @@ typescript-json-schema@^0.52.0:
typescript "~4.4.4"
yargs "^17.1.1"
typescript@^4.0.3, typescript@~4.5.2:
version "4.5.4"
resolved "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz#a17d3a0263bf5c8723b9c52f43c5084edf13c2e8"
integrity sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==
typescript@~4.3.5:
version "4.3.5"
resolved "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==
typescript@~4.4.4:
version "4.4.4"
resolved "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c"
integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==
typescript@~4.5.2, typescript@~4.5.4:
version "4.5.4"
resolved "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz#a17d3a0263bf5c8723b9c52f43c5084edf13c2e8"
integrity sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==
ua-parser-js@^0.7.18:
version "0.7.28"
resolved "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.28.tgz#8ba04e653f35ce210239c64661685bf9121dec31"