Chore: Upgrade typescript to 3.7 (#20375)

* Chore: Upgrade typescript to 3.7
This commit is contained in:
kay delaney 2019-11-15 09:18:09 +00:00 committed by GitHub
parent d4e013fd44
commit f1c8330877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 80 additions and 68 deletions

View File

@ -131,13 +131,13 @@
"style-loader": "0.23.1",
"terser-webpack-plugin": "1.2.3",
"ts-jest": "24.1.0",
"ts-loader": "6.1.1",
"ts-node": "8.4.1",
"ts-loader": "6.2.1",
"ts-node": "8.5.0",
"tslib": "1.10.0",
"tslint": "5.20.0",
"tslint": "5.20.1",
"tslint-loader": "3.5.4",
"tslint-react": "4.1.0",
"typescript": "3.6.3",
"typescript": "3.7.2",
"webpack": "4.29.6",
"webpack-bundle-analyzer": "3.3.2",
"webpack-cleanup-plugin": "0.5.1",

View File

@ -40,6 +40,6 @@
"rollup-plugin-visualizer": "0.9.2",
"rxjs": "6.4.0",
"sinon": "1.17.6",
"typescript": "3.6.3"
"typescript": "3.7.2"
}
}

View File

@ -5,7 +5,7 @@ import { PanelData } from './panel';
import { LogRowModel } from './logs';
import { AnnotationEvent, KeyValue, LoadingState, TableData, TimeSeries } from './data';
import { DataFrame, DataFrameDTO } from './dataFrame';
import { RawTimeRange, TimeRange } from './time';
import { RawTimeRange, TimeRange, AbsoluteTimeRange } from './time';
import { ScopedVars } from './ScopedVars';
export interface DataSourcePluginOptionsEditorProps<JSONData = DataSourceJsonData, SecureJSONData = {}> {
@ -13,18 +13,31 @@ export interface DataSourcePluginOptionsEditorProps<JSONData = DataSourceJsonDat
onOptionsChange: (options: DataSourceSettings<JSONData, SecureJSONData>) => void;
}
// Utility type to extract the query type TQuery from a class extending DataSourceApi<TQuery, TOptions>
export type DataSourceQueryType<DSType extends DataSourceApi<any, any>> = DSType extends DataSourceApi<
infer TQuery,
infer _TOptions
>
? TQuery
: never;
// Utility type to extract the options type TOptions from a class extending DataSourceApi<TQuery, TOptions>
export type DataSourceOptionsType<DSType extends DataSourceApi<any, any>> = DSType extends DataSourceApi<
infer _TQuery,
infer TOptions
>
? TOptions
: never;
export class DataSourcePlugin<
DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData
TQuery extends DataQuery = DataSourceQueryType<DSType>,
TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>
> extends GrafanaPlugin<DataSourcePluginMeta> {
DataSourceClass: DataSourceConstructor<DSType, TQuery, TOptions>;
components: DataSourcePluginComponents<DSType, TQuery, TOptions>;
components: DataSourcePluginComponents<DSType, TQuery, TOptions> = {};
constructor(DataSourceClass: DataSourceConstructor<DSType, TQuery, TOptions>) {
constructor(public DataSourceClass: DataSourceConstructor<DSType, TQuery, TOptions>) {
super();
this.DataSourceClass = DataSourceClass;
this.components = {};
}
setConfigEditor(editor: ComponentType<DataSourcePluginOptionsEditorProps<TOptions>>) {
@ -284,6 +297,7 @@ export interface ExploreQueryFieldProps<
> extends QueryEditorProps<DSType, TQuery, TOptions> {
history: any[];
onBlur?: () => void;
absoluteRange?: AbsoluteTimeRange;
}
export interface ExploreStartPageProps {
@ -555,12 +569,13 @@ export interface HistoryItem<TQuery extends DataQuery = DataQuery> {
}
export abstract class LanguageProvider {
datasource!: DataSourceApi;
request!: (url: string, params?: any) => Promise<any>;
abstract datasource: DataSourceApi<any, any>;
abstract request: (url: string, params?: any) => Promise<any>;
/**
* Returns startTask that resolves with a task list when main syntax is loaded.
* Task list consists of secondary promises that load more detailed language features.
*/
start!: () => Promise<any[]>;
abstract start: () => Promise<any[]>;
startTask?: Promise<any[]>;
}

View File

@ -37,7 +37,7 @@
"rollup-plugin-terser": "4.0.4",
"rollup-plugin-typescript2": "0.19.3",
"rollup-plugin-visualizer": "0.9.2",
"typescript": "3.6.3"
"typescript": "3.7.2"
},
"types": "src/index.ts"
}

View File

@ -85,12 +85,12 @@
"style-loader": "^0.23.1",
"terser-webpack-plugin": "^1.3.0",
"ts-jest": "24.1.0",
"ts-loader": "6.1.1",
"ts-node": "8.4.1",
"ts-loader": "6.2.1",
"ts-node": "8.5.0",
"tslib": "1.10.0",
"tslint": "5.20.0",
"tslint": "5.20.1",
"tslint-config-prettier": "^1.18.0",
"typescript": "3.6.3",
"typescript": "3.7.2",
"url-loader": "^2.0.1",
"webpack": "4.35.0"
},

View File

@ -89,7 +89,7 @@
"rollup-plugin-terser": "4.0.4",
"rollup-plugin-typescript2": "0.19.3",
"rollup-plugin-visualizer": "0.9.2",
"typescript": "3.6.3"
"typescript": "3.7.2"
},
"types": "src/index.ts"
}

View File

@ -12,7 +12,7 @@ describe('Chart Tooltip', () => {
// We need to mock getBoundingClientRect to return what DOM would actually return
// when measuring tooltip container (wrapper with padding and content inside)
Element.prototype.getBoundingClientRect = jest.fn(() => {
return { width: 100, height: 100, top: 0, left: 0, bottom: 0, right: 0 };
return { width: 100, height: 100, top: 0, left: 0, bottom: 0, right: 0 } as DOMRect;
});
});

View File

@ -6,15 +6,10 @@ import { Editor as CoreEditor } from 'slate';
import { Plugin as SlatePlugin } from '@grafana/slate-react';
import TOKEN_MARK from './slate-prism/TOKEN_MARK';
import {
makeFragment,
TypeaheadOutput,
CompletionItem,
TypeaheadInput,
SuggestionsState,
CompletionItemGroup,
} from '..';
import { Typeahead } from '../components/Typeahead/Typeahead';
import { CompletionItem, TypeaheadOutput, TypeaheadInput, SuggestionsState } from '../types/completion';
import { makeFragment } from '../utils/slate';
export const TYPEAHEAD_DEBOUNCE = 100;
// Commands added to the editor by this plugin.
@ -23,13 +18,6 @@ interface SuggestionsPluginCommands {
applyTypeahead: (suggestion: CompletionItem) => CoreEditor;
}
export interface SuggestionsState {
groupedItems: CompletionItemGroup[];
typeaheadPrefix: string;
typeaheadContext: string;
typeaheadText: string;
}
export function SuggestionsPlugin({
onTypeahead,
cleanText,

View File

@ -34,7 +34,7 @@ export class AdHocFilterField<
> extends React.PureComponent<Props<TQuery, TOptions>, State> {
state: State = { pairs: [] };
componentDidUpdate(prevProps: Props) {
componentDidUpdate(prevProps: Props<TQuery, TOptions>) {
if (_.isEqual(prevProps.extendedOptions, this.props.extendedOptions) === false) {
const pairs: any[] = [];

View File

@ -146,7 +146,6 @@ export class QueryRow extends PureComponent<QueryRowProps, QueryRowState> {
<div className="query-row">
<div className="query-row-field flex-shrink-1">
{QueryField ? (
//@ts-ignore
<QueryField
datasource={datasourceInstance}
query={query}

View File

@ -17,7 +17,7 @@ import { GrafanaRootScope } from 'app/routes/GrafanaCtrl';
import { expressionDatasource } from 'app/features/expressions/ExpressionDatasource';
export class DatasourceSrv implements DataSourceService {
datasources: { [name: string]: DataSourceApi };
datasources: Record<string, DataSourceApi>;
/** @ngInject */
constructor(
@ -60,7 +60,7 @@ export class DatasourceSrv implements DataSourceService {
loadDatasource(name: string): Promise<DataSourceApi> {
// Expression Datasource (not a real datasource)
if (name === expressionDatasource.name) {
this.datasources[name] = expressionDatasource;
this.datasources[name] = expressionDatasource as any;
return this.$q.when(expressionDatasource);
}

View File

@ -22,7 +22,17 @@ import config from 'app/core/config';
import TimeSeries from 'app/core/time_series2';
import TableModel from 'app/core/table_model';
import { coreModule, appEvents, contextSrv } from 'app/core/core';
import { DataSourcePlugin, AppPlugin, PanelPlugin, PluginMeta, DataSourcePluginMeta, dateMath } from '@grafana/data';
import {
DataSourcePlugin,
AppPlugin,
PanelPlugin,
PluginMeta,
DataSourcePluginMeta,
dateMath,
DataSourceApi,
DataSourceJsonData,
DataQuery,
} from '@grafana/data';
import * as fileExport from 'app/core/utils/file_export';
import * as flatten from 'app/core/utils/flatten';
import * as ticks from 'app/core/utils/ticks';
@ -180,16 +190,20 @@ export async function importPluginModule(path: string): Promise<any> {
return grafanaRuntime.SystemJS.import(path);
}
export function importDataSourcePlugin(meta: DataSourcePluginMeta): Promise<DataSourcePlugin<any>> {
export function importDataSourcePlugin(meta: DataSourcePluginMeta): Promise<GenericDataSourcePlugin> {
return importPluginModule(meta.module).then(pluginExports => {
if (pluginExports.plugin) {
const dsPlugin = pluginExports.plugin as DataSourcePlugin<any>;
const dsPlugin = pluginExports.plugin as GenericDataSourcePlugin;
dsPlugin.meta = meta;
return dsPlugin;
}
if (pluginExports.Datasource) {
const dsPlugin = new DataSourcePlugin(pluginExports.Datasource);
const dsPlugin = new DataSourcePlugin<
DataSourceApi<DataQuery, DataSourceJsonData>,
DataQuery,
DataSourceJsonData
>(pluginExports.Datasource);
dsPlugin.setComponentsFromLegacyExports(pluginExports);
dsPlugin.meta = meta;
return dsPlugin;
@ -210,6 +224,7 @@ export function importAppPlugin(meta: PluginMeta): Promise<AppPlugin> {
}
import { getPanelPluginNotFound, getPanelPluginLoadError } from '../dashboard/dashgrid/PanelPluginError';
import { GenericDataSourcePlugin } from '../datasources/settings/PluginSettings';
interface PanelCache {
[key: string]: PanelPlugin;

View File

@ -224,7 +224,7 @@ export class ElasticQueryBuilder {
nestedAggs = query;
for (i = 0; i < target.bucketAggs.length; i++) {
const aggDef = target.bucketAggs[i];
const aggDef: any = target.bucketAggs[i];
const esAgg: any = {};
switch (aggDef.type) {

View File

@ -5862,11 +5862,6 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"
caniuse-db@1.0.30000772:
version "1.0.30000772"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000772.tgz#51aae891768286eade4a3d8319ea76d6a01b512b"
integrity sha1-UarokXaChureSj2DGep21qAbUSs=
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000939, caniuse-lite@^1.0.30000947, caniuse-lite@^1.0.30000989, caniuse-lite@^1.0.30000999:
version "1.0.30000999"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000999.tgz#427253a69ad7bea4aa8d8345687b8eec51ca0e43"
@ -20278,10 +20273,10 @@ ts-jest@24.1.0:
semver "^5.5"
yargs-parser "10.x"
ts-loader@6.1.1:
version "6.1.1"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-6.1.1.tgz#f30c68aa1ce59fa266f0bb70a36959ca68f40ddc"
integrity sha512-AoOek8ZWJlWwTRH5ttNmZPBRcASUJZc8wc8E/2PGOXef96H97J8KaLXaW/zUnvyFjvCoRBhTGh9ZIMKL1arcCA==
ts-loader@6.2.1:
version "6.2.1"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-6.2.1.tgz#67939d5772e8a8c6bdaf6277ca023a4812da02ef"
integrity sha512-Dd9FekWuABGgjE1g0TlQJ+4dFUfYGbYcs52/HQObE0ZmUNjQlmLAS7xXsSzy23AMaMwipsx5sNHvoEpT2CZq1g==
dependencies:
chalk "^2.3.0"
enhanced-resolve "^4.0.0"
@ -20289,10 +20284,10 @@ ts-loader@6.1.1:
micromatch "^4.0.0"
semver "^6.0.0"
ts-node@8.4.1:
version "8.4.1"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.4.1.tgz#270b0dba16e8723c9fa4f9b4775d3810fd994b4f"
integrity sha512-5LpRN+mTiCs7lI5EtbXmF/HfMeCjzt7DH9CZwtkr6SywStrNQC723wG+aOWFiLNn7zT3kD/RnFqi3ZUfr4l5Qw==
ts-node@8.5.0:
version "8.5.0"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.5.0.tgz#bc7d5a39133d222bf25b1693651e4d893785f884"
integrity sha512-fbG32iZEupNV2E2Fd2m2yt1TdAwR3GTCrJQBHDevIiEBNy1A8kqnyl1fv7jmRmmbtcapFab2glZXHJvfD1ed0Q==
dependencies:
arg "^4.1.0"
diff "^4.0.1"
@ -20338,10 +20333,10 @@ tslint-react@4.1.0:
dependencies:
tsutils "^3.9.1"
tslint@5.20.0:
version "5.20.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.20.0.tgz#fac93bfa79568a5a24e7be9cdde5e02b02d00ec1"
integrity sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==
tslint@5.20.1:
version "5.20.1"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.20.1.tgz#e401e8aeda0152bc44dd07e614034f3f80c67b7d"
integrity sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==
dependencies:
"@babel/code-frame" "^7.0.0"
builtin-modules "^1.1.1"
@ -20438,10 +20433,10 @@ typeface-oswald@0.0.54:
resolved "https://registry.yarnpkg.com/typeface-oswald/-/typeface-oswald-0.0.54.tgz#1e253011622cdd50f580c04e7d625e7f449763d7"
integrity sha512-U1WMNp4qfy4/3khIfHMVAIKnNu941MXUfs3+H9R8PFgnoz42Hh9pboSFztWr86zut0eXC8byalmVhfkiKON/8Q==
typescript@3.6.3:
version "3.6.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.3.tgz#fea942fabb20f7e1ca7164ff626f1a9f3f70b4da"
integrity sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==
typescript@3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb"
integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==
typical@^2.6.1:
version "2.6.1"