Compare commits

...

4 Commits

Author SHA1 Message Date
Jack Westbrook
b910e2e39e chore(tsgo): clean up some more types, disable js typechecks 2025-12-01 14:58:45 +01:00
Jack Westbrook
8a93d5331a chore(typescript): appease ts-go stricter type inference in callbacks 2025-12-01 12:28:44 +01:00
Jack Westbrook
eb84c5d02f build(typescript): update tsconfigs to work with tsgo 2025-11-28 10:03:13 +01:00
Jack Westbrook
ba380fd15d build(typescript): add tsgo and separate typecheck:tsgo npm script 2025-11-28 10:02:30 +01:00
35 changed files with 166 additions and 53 deletions

View File

@@ -1,4 +1,5 @@
// @ts-check
// TODO: Migrate to Typescript.
// @ts-nocheck
const emotionPlugin = require('@emotion/eslint-plugin');
const restrictedGlobals = require('confusing-browser-globals');
const importPlugin = require('eslint-plugin-import');

View File

@@ -66,6 +66,7 @@
"themes-generate": "yarn themes-schema && esbuild --target=es6 ./scripts/cli/generateSassVariableFiles.ts --bundle --platform=node --tsconfig=./scripts/cli/tsconfig.json | node",
"themes:usage": "eslint . --ignore-pattern '*.test.ts*' --ignore-pattern '*.spec.ts*' --cache --plugin '@grafana' --rule '{ @grafana/theme-token-usage: \"error\" }'",
"typecheck": "tsc --noEmit && yarn run packages:typecheck",
"typecheck:tsgo": "tsgo --noEmit",
"plugins:build-bundled": "echo 'bundled plugins are no longer supported'",
"watch": "yarn start -d watch,start core:start --watchTheme",
"i18n:stats": "node ./scripts/cli/reportI18nStats.mjs",
@@ -166,6 +167,7 @@
"@types/yargs": "17.0.33",
"@typescript-eslint/eslint-plugin": "8.38.0",
"@typescript-eslint/parser": "8.38.0",
"@typescript/native-preview": "^7.0.0-dev.20251128.1",
"autoprefixer": "10.4.21",
"babel-loader": "10.0.0",
"blob-polyfill": "9.0.20240710",

View File

@@ -110,10 +110,9 @@ export function getInheritedProperties<T extends Route>(
...propertiesParentInherited,
} as const;
// @ts-expect-error we're using "keyof" for the property so the type checker can help us out but this makes the
// reduce function signature unhappy
const inherited = reduce(
inheritableProperties,
// @ts-expect-error we're using "keyof" for the property so the type checker can help us out but this makes the
(inheritedProperties: InheritableProperties, parentValue, property: keyof InheritableProperties) => {
const parentHasValue = parentValue != null;

View File

@@ -1,4 +1,7 @@
{
"exclude": ["dist", "node_modules", "tests", "**/*.test.ts*", "**/*.story.tsx"],
"extends": "./tsconfig.json"
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
}
}

View File

@@ -1,4 +1,7 @@
{
"extends": "./tsconfig.json",
"exclude": ["dist", "node_modules", "**/*.test.ts*"]
"exclude": ["dist", "node_modules", "**/*.test.ts*"],
"compilerOptions": {
"rootDir": "./src"
}
}

View File

@@ -1,4 +1,7 @@
{
"exclude": ["dist", "node_modules", "test", "**/*.test.ts*"],
"extends": "./tsconfig.json"
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
}
}

View File

@@ -1,4 +1,7 @@
{
"exclude": ["dist", "node_modules", "**/*.test.ts*"],
"extends": "./tsconfig.json"
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
}
}

View File

@@ -2,7 +2,8 @@
"compilerOptions": {
"paths": {
"@emotion/core": ["./src/types/emotion-core-stub.d.ts"]
}
},
"rootDir": "./src"
},
"exclude": ["**/*.test.ts*"],
"extends": "./tsconfig.json"

View File

@@ -1,4 +1,7 @@
{
"exclude": ["dist", "node_modules", "test", "**/*.test.ts*"],
"extends": "./tsconfig.json"
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
}
}

View File

@@ -8,7 +8,8 @@
"emitDeclarationOnly": true,
"isolatedModules": true,
"allowJs": true,
"rootDirs": ["."]
"rootDirs": ["."],
"rootDir": "../.."
},
"exclude": ["dist/**/*"],
"include": [

View File

@@ -8,5 +8,8 @@
"src/querybuilder/testUtils.ts",
"../../public/test/setupTests.ts"
],
"extends": "./tsconfig.json"
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
}
}

View File

@@ -1,4 +1,7 @@
{
"exclude": ["dist", "node_modules", "**/*.test.ts*", "../../public/test/setupTests.ts"],
"extends": "./tsconfig.json"
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
}
}

View File

@@ -1,4 +1,7 @@
{
"exclude": ["dist/**/*", "**/*.test.ts*"],
"extends": "./tsconfig.json"
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
}
}

View File

@@ -1,7 +1,7 @@
import { css } from '@emotion/css';
import { useMemo, useState } from 'react';
import { useMeasure } from 'react-use';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { Trans, t } from '@grafana/i18n';
@@ -61,7 +61,7 @@ export function RawEditor({ db, query, onChange, onRunQuery, onValidate, queryTo
const renderEditor = (standalone = false) => {
return standalone ? (
<AutoSizer>
{({ width, height }) => {
{({ width, height }: Size) => {
return renderQueryEditor(width, height);
}}
</AutoSizer>

View File

@@ -8,7 +8,8 @@
"emitDeclarationOnly": true,
"isolatedModules": true,
"strict": true,
"rootDirs": ["."]
"rootDirs": ["."],
"rootDir": "./src"
},
"exclude": ["dist/**/*"],
"include": ["src/**/*.ts*", "../../public/app/types/*.d.ts", "../grafana-ui/src/types/*.d.ts"]

View File

@@ -7,7 +7,8 @@
"emitDeclarationOnly": true,
"isolatedModules": true,
"rootDirs": ["."],
"moduleResolution": "bundler"
"moduleResolution": "bundler",
"rootDir": "./src"
},
"ts-node": {
"compilerOptions": {

View File

@@ -3,7 +3,8 @@
"paths": {
"@emotion/core": ["./src/types/emotion-core-stub.d.ts"],
"@grafana/ui": ["."]
}
},
"rootDir": "./src"
},
"exclude": [
"**/*.story.tsx",

View File

@@ -1,6 +1,6 @@
import { css, cx } from '@emotion/css';
import { CSSProperties, useCallback, useMemo, useState } from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { FixedSizeList } from 'react-window';
import { GrafanaTheme2 } from '@grafana/data';
@@ -235,7 +235,7 @@ export function AlertInstanceModalSelector({
{!loading && (
<AutoSizer>
{({ height, width }) => (
{({ height, width }: Size) => (
<FixedSizeList itemSize={50} height={height} width={width} itemCount={filteredRulesKeys.length}>
{RuleRow}
</FixedSizeList>
@@ -263,7 +263,7 @@ export function AlertInstanceModalSelector({
{selectedRule && rulesWithInstances[selectedRule].length && !loading && (
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<FixedSizeList
itemSize={32}
height={height}

View File

@@ -1,7 +1,7 @@
import { css, cx } from '@emotion/css';
import { useState } from 'react';
import * as React from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { Trans, t } from '@grafana/i18n';
@@ -124,7 +124,7 @@ export function PayloadEditor({
<div className={styles.editorWrapper}>
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<CodeEditor
containerStyles={styles.editorContainer}
width={width}

View File

@@ -4,7 +4,7 @@ import { Location } from 'history';
import { useRef, useState } from 'react';
import { FormProvider, useForm } from 'react-hook-form';
import { useToggle } from 'react-use';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { Trans, t } from '@grafana/i18n';
@@ -306,7 +306,7 @@ export const TemplateForm = ({ originalTemplate, prefill, alertmanager }: Props)
</div>
<Box flex={1}>
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<TemplateEditor
value={getValues('content')}
onBlur={(value) => setValue('content', value)}

View File

@@ -1,6 +1,6 @@
import { css, cx } from '@emotion/css';
import * as React from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { t } from '@grafana/i18n';
@@ -44,7 +44,7 @@ export function TemplateContentAndPreview({
<Box flex={1}>
<div className={styles.viewerContainer({ height: 400 })}>
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<TemplateEditor
value={templateContent}
containerStyles={styles.editorContainer}

View File

@@ -2,7 +2,7 @@ import { css, cx } from '@emotion/css';
import { noop } from 'lodash';
import { CSSProperties, useCallback, useMemo, useState } from 'react';
import { useAsync, useDebounce } from 'react-use';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { FixedSizeList } from 'react-window';
import { GrafanaTheme2 } from '@grafana/data';
@@ -257,7 +257,7 @@ export const DashboardPicker = ({ dashboardUid, panelId, isOpen, onChange, onDis
{!isDashSearchFetching && (
<AutoSizer>
{({ height, width }) => (
{({ height, width }: Size) => (
<FixedSizeList
ref={scrollToItem}
itemSize={50}
@@ -291,7 +291,7 @@ export const DashboardPicker = ({ dashboardUid, panelId, isOpen, onChange, onDis
{selectedDashboardUid && !isDashboardFetching && (
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<FixedSizeList itemSize={32} height={height} width={width} itemCount={filteredPanels.length}>
{PanelRow}
</FixedSizeList>

View File

@@ -1,6 +1,6 @@
import { css } from '@emotion/css';
import * as React from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { FieldConfigSource, FieldMatcherID, GrafanaTheme2, LoadingState } from '@grafana/data';
import { Trans, t } from '@grafana/i18n';
@@ -67,7 +67,7 @@ export function PreviewRuleResult(props: Props): React.ReactElement | null {
)}
<div className={styles.table}>
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<div style={{ width: `${width}px`, height: `${height}px` }}>
<PanelRenderer
title=""

View File

@@ -1,7 +1,7 @@
import { css } from '@emotion/css';
import { memo, useEffect, useMemo } from 'react';
import { useLocation, useParams } from 'react-router-dom-v5-compat';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { Trans } from '@grafana/i18n';
@@ -197,7 +197,7 @@ const BrowseDashboardsPage = memo(({ queryParams }: { queryParams: Record<string
<div className={styles.subView}>
<AutoSizer>
{({ width, height }) =>
{({ width, height }: Size) =>
isSearching ? (
<SearchView
permissions={permissions}

View File

@@ -1,6 +1,6 @@
import { css } from '@emotion/css';
import { memo, useEffect } from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { t } from '@grafana/i18n';
@@ -73,7 +73,7 @@ const RecentlyDeletedPage = memo(() => {
<div className={styles.subView}>
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<SearchView
permissions={permissions}
width={width}

View File

@@ -1,7 +1,7 @@
import { css } from '@emotion/css';
import { PureComponent } from 'react';
import { connect, ConnectedProps } from 'react-redux';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { Subscription } from 'rxjs';
import { FieldConfigSource, GrafanaTheme2, NavModel, NavModelItem, PageLayoutType } from '@grafana/data';
@@ -201,7 +201,7 @@ export class PanelEditorUnconnected extends PureComponent<Props> {
{this.renderPanelToolbar(styles)}
<div className={styles.panelWrapper}>
<AutoSizer>
{({ width, height }) => {
{({ width, height }: Size) => {
if (width < 3 || height < 3) {
return null;
}

View File

@@ -2,7 +2,7 @@ import { css } from '@emotion/css';
import { useCallback, useEffect, useState } from 'react';
import { connect, ConnectedProps } from 'react-redux';
import { useParams } from 'react-router-dom-v5-compat';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { GrafanaTheme2 } from '@grafana/data';
import { Trans, t } from '@grafana/i18n';
@@ -119,7 +119,7 @@ export const SoloPanel = ({ dashboard, notFound, panel, panelId, timezone }: Sol
return (
<div className={styles.container}>
<AutoSizer>
{({ width, height }) => {
{({ width, height }: Size) => {
if (width === 0) {
return null;
}

View File

@@ -1,7 +1,7 @@
import { css, cx } from '@emotion/css';
import { useMemo, useRef, useEffect, useState, lazy, Suspense, useCallback } from 'react';
import { useMeasure } from 'react-use';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { SelectableValue, GrafanaTheme2 } from '@grafana/data';
import { t, Trans } from '@grafana/i18n';
@@ -349,7 +349,7 @@ LIMIT
const renderStandaloneEditor = () => (
<AutoSizer>
{({ width, height }) => (
{({ width, height }: Size) => (
<SQLEditor
query={query.expression || initialQuery}
onChange={onEditorChange}

View File

@@ -1,6 +1,6 @@
import { cloneDeep } from 'lodash';
import { PureComponent } from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import {
applyFieldOverrides,
@@ -292,7 +292,7 @@ export class InspectDataTab extends PureComponent<Props, State> {
</div>
<div className={styles.content}>
<AutoSizer>
{({ width, height }) => {
{({ width, height }: Size) => {
if (width === 0) {
return null;
}

View File

@@ -1,7 +1,7 @@
import { css } from '@emotion/css';
import { useMemo } from 'react';
import { useAsync } from 'react-use';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { of } from 'rxjs';
import { GrafanaTheme2, PluginMeta, PluginType } from '@grafana/data';
@@ -52,7 +52,7 @@ export function PluginUsage({ plugin }: Props) {
</Trans>
</div>
<AutoSizer>
{({ width, height }) => {
{({ width, height }: Size) => {
return (
<SearchResultsTable
response={found}

View File

@@ -1,6 +1,6 @@
import { nanoid } from 'nanoid';
import { ReactElement, useState } from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import AutoSizer, { type Size } from 'react-virtualized-auto-sizer';
import { sceneUtils, VizConfigBuilders } from '@grafana/scenes';
import {
@@ -56,7 +56,7 @@ function LogViewScene(): ReactElement | null {
actions={<LogViewFilters provider={data} filteredProvider={filteredData} filter={filter} onChange={setFilter} />}
>
<AutoSizer>
{({ height, width }) => (
{({ height, width }: Size) => (
<VizGridLayout minHeight={height} minWidth={width}>
<VizPanel title="" viz={logsViz} dataProvider={filteredData} />
</VizGridLayout>

View File

@@ -331,7 +331,7 @@ export function LokiContextUi(props: LokiContextUiProps) {
>
Widen the search
</Label>
<MultiSelect
<MultiSelect<string>
isLoading={loading}
options={realLabels.map(contextFilterToSelectFilter)}
value={realLabelsEnabled.map(contextFilterToSelectFilter)}
@@ -372,7 +372,7 @@ export function LokiContextUi(props: LokiContextUiProps) {
>
Refine the search
</Label>
<MultiSelect
<MultiSelect<string>
isLoading={loading}
options={parsedLabels.map(contextFilterToSelectFilter)}
value={parsedLabelsEnabled.map(contextFilterToSelectFilter)}

View File

@@ -1,4 +1,4 @@
// @ts-check
// @ts-nocheck
const { parse } = require('ini');
const { readFileSync, existsSync } = require('node:fs');
const path = require('path');

View File

@@ -2,7 +2,6 @@
"extends": "./scripts/tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"baseUrl": "public/",
"outDir": "public/dist",
"rootDirs": ["public/"],
"allowJs": true,
@@ -14,7 +13,8 @@
"moduleResolution": "bundler",
"tsBuildInfoFile": "./tsconfig.tsbuildinfo",
"paths": {
"@grafana/schema/dist/esm/*": ["../packages/grafana-schema/src/*"]
"@grafana/schema/dist/esm/*": ["./packages/grafana-schema/src/*"],
"*": ["./public/*"]
}
},
"ts-node": {

View File

@@ -11244,6 +11244,87 @@ __metadata:
languageName: node
linkType: hard
"@typescript/native-preview-darwin-arm64@npm:7.0.0-dev.20251128.1":
version: 7.0.0-dev.20251128.1
resolution: "@typescript/native-preview-darwin-arm64@npm:7.0.0-dev.20251128.1"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
"@typescript/native-preview-darwin-x64@npm:7.0.0-dev.20251128.1":
version: 7.0.0-dev.20251128.1
resolution: "@typescript/native-preview-darwin-x64@npm:7.0.0-dev.20251128.1"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
"@typescript/native-preview-linux-arm64@npm:7.0.0-dev.20251128.1":
version: 7.0.0-dev.20251128.1
resolution: "@typescript/native-preview-linux-arm64@npm:7.0.0-dev.20251128.1"
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard
"@typescript/native-preview-linux-arm@npm:7.0.0-dev.20251128.1":
version: 7.0.0-dev.20251128.1
resolution: "@typescript/native-preview-linux-arm@npm:7.0.0-dev.20251128.1"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard
"@typescript/native-preview-linux-x64@npm:7.0.0-dev.20251128.1":
version: 7.0.0-dev.20251128.1
resolution: "@typescript/native-preview-linux-x64@npm:7.0.0-dev.20251128.1"
conditions: os=linux & cpu=x64
languageName: node
linkType: hard
"@typescript/native-preview-win32-arm64@npm:7.0.0-dev.20251128.1":
version: 7.0.0-dev.20251128.1
resolution: "@typescript/native-preview-win32-arm64@npm:7.0.0-dev.20251128.1"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
"@typescript/native-preview-win32-x64@npm:7.0.0-dev.20251128.1":
version: 7.0.0-dev.20251128.1
resolution: "@typescript/native-preview-win32-x64@npm:7.0.0-dev.20251128.1"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
"@typescript/native-preview@npm:^7.0.0-dev.20251128.1":
version: 7.0.0-dev.20251128.1
resolution: "@typescript/native-preview@npm:7.0.0-dev.20251128.1"
dependencies:
"@typescript/native-preview-darwin-arm64": "npm:7.0.0-dev.20251128.1"
"@typescript/native-preview-darwin-x64": "npm:7.0.0-dev.20251128.1"
"@typescript/native-preview-linux-arm": "npm:7.0.0-dev.20251128.1"
"@typescript/native-preview-linux-arm64": "npm:7.0.0-dev.20251128.1"
"@typescript/native-preview-linux-x64": "npm:7.0.0-dev.20251128.1"
"@typescript/native-preview-win32-arm64": "npm:7.0.0-dev.20251128.1"
"@typescript/native-preview-win32-x64": "npm:7.0.0-dev.20251128.1"
dependenciesMeta:
"@typescript/native-preview-darwin-arm64":
optional: true
"@typescript/native-preview-darwin-x64":
optional: true
"@typescript/native-preview-linux-arm":
optional: true
"@typescript/native-preview-linux-arm64":
optional: true
"@typescript/native-preview-linux-x64":
optional: true
"@typescript/native-preview-win32-arm64":
optional: true
"@typescript/native-preview-win32-x64":
optional: true
bin:
tsgo: bin/tsgo.js
checksum: 10/797dccc0ffdc81525f0497daeb9e475744936be89ef12386f6b73fca5b2b3c11ef34ce052b803194e65b9a85d61c3494094c0063ce4c00579307769aa1e3cfa1
languageName: node
linkType: hard
"@visx/bounds@npm:3.12.0":
version: 3.12.0
resolution: "@visx/bounds@npm:3.12.0"
@@ -19334,6 +19415,7 @@ __metadata:
"@types/yargs": "npm:17.0.33"
"@typescript-eslint/eslint-plugin": "npm:8.38.0"
"@typescript-eslint/parser": "npm:8.38.0"
"@typescript/native-preview": "npm:^7.0.0-dev.20251128.1"
"@visx/event": "npm:3.12.0"
"@visx/gradient": "npm:3.12.0"
"@visx/group": "npm:3.12.0"