Skip to content

Commit 0b03344

Browse files
academorenovate[bot]zoltanbedijoshhunt
authored
Chore: Update to typescript 5 (grafana#76511)
* Update dependency typescript to v5 * Update yarn.lock * Fix typescript errors * Update typescript version sdk * Revert useDescription.ts * Fix ts errors * Fix Typescript errors after Symbol.unscopables type change * Fix colormanipulator errors * Update packages/grafana-data/src/vector/FunctionalVector.ts * Fix ts errors in dashboardmigrator * Fix sandbox component typescript error * Update yarn * Update to typescript 5.2 * Fix typescript error * update typescript/vscode patch/sdk/whatever * fix ts errors in elasticsearch * Fix two errors in alerting * Fix error in dashboard-scene * Fix errors in dashboard tests * Fix errors in explore tests * Fix error in plugins sandbox * fix error in DashboardQueryRunner * fix errors in grafana-data * fix errors in PanelChrome story * update betterer * better fix for cloud monitoring * fix error in reducer tester --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Zoltán Bedi <[email protected]> Co-authored-by: Josh Hunt <[email protected]> Co-authored-by: joshhunt <[email protected]>
1 parent 895c137 commit 0b03344

File tree

34 files changed

+951
-203
lines changed

34 files changed

+951
-203
lines changed

.betterer.results

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4669,9 +4669,6 @@ exports[`better eslint`] = {
46694669
"public/app/features/plugins/sandbox/distortion_map.ts:5381": [
46704670
[0, 0, 0, "Do not use any type assertions.", "0"]
46714671
],
4672-
"public/app/features/plugins/sandbox/sandbox_components.tsx:5381": [
4673-
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
4674-
],
46754672
"public/app/features/plugins/sandbox/sandbox_plugin_loader.ts:5381": [
46764673
[0, 0, 0, "Do not use any type assertions.", "0"],
46774674
[0, 0, 0, "Do not use any type assertions.", "1"],
@@ -5542,12 +5539,11 @@ exports[`better eslint`] = {
55425539
],
55435540
"public/app/plugins/datasource/cloud-monitoring/datasource.ts:5381": [
55445541
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
5545-
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
5546-
[0, 0, 0, "Do not use any type assertions.", "2"],
5542+
[0, 0, 0, "Do not use any type assertions.", "1"],
5543+
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
55475544
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
5548-
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
5549-
[0, 0, 0, "Do not use any type assertions.", "5"],
5550-
[0, 0, 0, "Do not use any type assertions.", "6"]
5545+
[0, 0, 0, "Do not use any type assertions.", "4"],
5546+
[0, 0, 0, "Do not use any type assertions.", "5"]
55515547
],
55525548
"public/app/plugins/datasource/cloud-monitoring/functions.ts:5381": [
55535549
[0, 0, 0, "Do not use any type assertions.", "0"],

.yarn/sdks/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript",
3-
"version": "4.8.4-sdk",
3+
"version": "5.2.2-sdk",
44
"main": "./lib/typescript.js",
55
"type": "commonjs",
66
"bin": {

.yarnrc.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ enableTelemetry: false
77
nodeLinker: pnp
88

99
packageExtensions:
10-
'@storybook/[email protected]':
10+
"@storybook/[email protected]":
1111
dependencies:
1212
'@storybook/react-webpack5': 7.4.5
1313
@@ -26,14 +26,14 @@ packageExtensions:
2626
react-simple-compat: 1.2.2
2727
2828
peerDependencies:
29-
prop-types: '*'
29+
prop-types: "*"
3030
3131
peerDependencies:
3232
react-dom: 17.0.1
3333

3434
plugins:
3535
- path: .yarn/plugins/@yarnpkg/plugin-outdated.cjs
36-
spec: 'https://mskelton.dev/yarn-outdated/v2'
36+
spec: "https://mskelton.dev/yarn-outdated/v2"
3737

3838
yarnPath: .yarn/releases/yarn-4.0.0.cjs
3939
# Uncomment the following lines if you want to use Verdaccio local npm registry. Read more at packages/README.md

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
"tracelib": "1.0.1",
227227
"ts-jest": "29.1.1",
228228
"ts-node": "10.9.1",
229-
"typescript": "4.8.4",
229+
"typescript": "5.2.2",
230230
"webpack": "5.89.0",
231231
"webpack-bundle-analyzer": "4.9.0",
232232
"webpack-cli": "5.1.4",

packages/grafana-data/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"rollup-plugin-dts": "^5.0.0",
9292
"rollup-plugin-esbuild": "5.0.0",
9393
"rollup-plugin-node-externals": "^5.0.0",
94-
"typescript": "4.8.4"
94+
"typescript": "5.2.2"
9595
},
9696
"peerDependencies": {
9797
"react": "^17.0.0 || ^18.0.0",

packages/grafana-data/src/themes/colorManipulator.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@ export function hexToRgb(color: string) {
3232
color = color.slice(1);
3333

3434
const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
35-
let colors = color.match(re);
35+
let result = color.match(re);
3636

37-
if (colors && colors[0].length === 1) {
37+
if (!result) {
38+
return '';
39+
}
40+
41+
let colors = Array.from(result);
42+
43+
if (colors[0].length === 1) {
3844
colors = colors.map((n) => n + n);
3945
}
4046

packages/grafana-data/src/types/logs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export interface DataSourceWithLogsContextSupport<TQuery extends DataQuery = Dat
153153
}
154154

155155
export const hasLogsContextSupport = (datasource: unknown): datasource is DataSourceWithLogsContextSupport => {
156-
if (!datasource) {
156+
if (!datasource || typeof datasource !== 'object') {
157157
return false;
158158
}
159159

@@ -253,7 +253,7 @@ export const hasSupplementaryQuerySupport = <TQuery extends DataQuery>(
253253
};
254254

255255
export const hasLogsContextUiSupport = (datasource: unknown): datasource is DataSourceWithLogsContextSupport => {
256-
if (!datasource) {
256+
if (!datasource || typeof datasource !== 'object') {
257257
return false;
258258
}
259259

packages/grafana-data/src/types/query.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ export interface DataSourceWithQueryExportSupport<TQuery extends SchemaDataQuery
6666
export const hasQueryImportSupport = <TQuery extends SchemaDataQuery>(
6767
datasource: unknown
6868
): datasource is DataSourceWithQueryImportSupport<TQuery> => {
69-
if (!datasource) {
69+
if (!datasource || typeof datasource !== 'object') {
7070
return false;
7171
}
72+
7273
return 'importFromAbstractQueries' in datasource;
7374
};
7475

@@ -78,7 +79,7 @@ export const hasQueryImportSupport = <TQuery extends SchemaDataQuery>(
7879
export const hasQueryExportSupport = <TQuery extends SchemaDataQuery>(
7980
datasource: unknown
8081
): datasource is DataSourceWithQueryExportSupport<TQuery> => {
81-
if (!datasource) {
82+
if (!datasource || typeof datasource !== 'object') {
8283
return false;
8384
}
8485
return 'exportToAbstractQueries' in datasource;

packages/grafana-data/src/vector/FunctionalVector.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,8 @@ export abstract class FunctionalVector<T = any> implements Vector<T> {
101101
copyWithin(target: number, start: number, end?: number | undefined): this {
102102
throw new Error('Method not implemented.');
103103
}
104-
105-
[Symbol.unscopables](): {
106-
copyWithin: boolean;
107-
entries: boolean;
108-
fill: boolean;
109-
find: boolean;
110-
findIndex: boolean;
111-
keys: boolean;
112-
values: boolean;
113-
} {
114-
throw new Error('Method not implemented.');
115-
}
104+
// Object not implemented
105+
[Symbol.unscopables] = {};
116106

117107
//--------------------------------------------------------------------------------
118108
// Delegated Array function -- these will not be efficient :grimmice:

packages/grafana-e2e-selectors/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@
5252
"dependencies": {
5353
"@grafana/tsconfig": "^1.2.0-rc1",
5454
"tslib": "2.6.0",
55-
"typescript": "4.8.4"
55+
"typescript": "5.2.2"
5656
}
5757
}

0 commit comments

Comments
 (0)