Commit 19da963a by Torkel Ödegaard

Typings issues

parent a38490f4
...@@ -181,5 +181,13 @@ ...@@ -181,5 +181,13 @@
"caniuse-db": "1.0.30000772", "caniuse-db": "1.0.30000772",
"**/@types/react": "16.7.6" "**/@types/react": "16.7.6"
}, },
"workspaces": ["packages/grafana-ui"] "workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"**/@types/*",
"**/@types/*/**"
]
}
} }
...@@ -11,18 +11,19 @@ ...@@ -11,18 +11,19 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@torkelo/react-select": "2.1.1", "@torkelo/react-select": "2.1.1",
"@types/jquery": "^1.10.35",
"lodash": "^4.17.10",
"moment": "^2.22.2", "moment": "^2.22.2",
"react": "^16.6.3", "react": "^16.6.3",
"react-dom": "^16.6.3", "react-dom": "^16.6.3",
"react-highlight-words": "0.11.0", "react-highlight-words": "0.11.0",
"react-popper": "^1.3.0", "react-popper": "^1.3.0",
"react-transition-group": "^2.2.1", "react-transition-group": "^2.2.1",
"lodash": "^4.17.10",
"react-virtualized": "^9.21.0" "react-virtualized": "^9.21.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^23.3.2", "@types/jest": "^23.3.2",
"@types/lodash": "^4.17.10", "@types/lodash": "^4.14.119",
"@types/react": "^16.7.6", "@types/react": "^16.7.6",
"typescript": "^3.2.2" "typescript": "^3.2.2"
} }
......
...@@ -22,7 +22,7 @@ export class Graph extends PureComponent<GraphProps> { ...@@ -22,7 +22,7 @@ export class Graph extends PureComponent<GraphProps> {
showBars: false, showBars: false,
}; };
element: HTMLElement; element: HTMLElement | null;
componentDidUpdate() { componentDidUpdate() {
this.draw(); this.draw();
...@@ -33,6 +33,10 @@ export class Graph extends PureComponent<GraphProps> { ...@@ -33,6 +33,10 @@ export class Graph extends PureComponent<GraphProps> {
} }
draw() { draw() {
if (this.element === null) {
return;
}
const { width, timeSeries, timeRange, showLines, showBars, showPoints } = this.props; const { width, timeSeries, timeRange, showLines, showBars, showPoints } = this.props;
if (!width) { if (!width) {
...@@ -74,7 +78,7 @@ export class Graph extends PureComponent<GraphProps> { ...@@ -74,7 +78,7 @@ export class Graph extends PureComponent<GraphProps> {
max: max, max: max,
label: 'Datetime', label: 'Datetime',
ticks: ticks, ticks: ticks,
timeformat: time_format(ticks, min, max), timeformat: timeFormat(ticks, min, max),
}, },
grid: { grid: {
minBorderMargin: 0, minBorderMargin: 0,
...@@ -107,7 +111,7 @@ export class Graph extends PureComponent<GraphProps> { ...@@ -107,7 +111,7 @@ export class Graph extends PureComponent<GraphProps> {
} }
// Copied from graph.ts // Copied from graph.ts
function time_format(ticks, min, max) { function timeFormat(ticks: number, min: number, max: number): string {
if (min && max && ticks) { if (min && max && ticks) {
const range = max - min; const range = max - min;
const secPerTick = range / ticks / 1000; const secPerTick = range / ticks / 1000;
......
interface JQueryStatic {
plot: (element: HTMLElement, data: any[], options: any) => void;
}
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
"noUnusedLocals": true, "noUnusedLocals": true,
"baseUrl": "public", "baseUrl": "public",
"pretty": true, "pretty": true,
"typeRoots": ["node_modules/@types", "types"],
"paths": { "paths": {
"app": ["app"] "app": ["app"]
} }
......
...@@ -1029,6 +1029,11 @@ ...@@ -1029,6 +1029,11 @@
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-23.3.4.tgz#cc43ae176a91dcb1504839b0b9d6659386cf0af5" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-23.3.4.tgz#cc43ae176a91dcb1504839b0b9d6659386cf0af5"
integrity sha512-46jSw0QMerCRkhJZbOwPA0Eb9T1p74HtECsfa0GXdgjkenSGhgvK96w+e2PEPu4GF0/brUK5WQKq/rUQQFyAxA== integrity sha512-46jSw0QMerCRkhJZbOwPA0Eb9T1p74HtECsfa0GXdgjkenSGhgvK96w+e2PEPu4GF0/brUK5WQKq/rUQQFyAxA==
"@types/jquery@^1.10.35":
version "1.10.35"
resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-1.10.35.tgz#4e5c2b1e5b3bf0b863efb8c5e70081f52e6c9518"
integrity sha512-SVtqEcudm7yjkTwoRA1gC6CNMhGDdMx4Pg8BPdiqI7bXXdCn1BPmtxgeWYQOgDxrq53/5YTlhq5ULxBEAlWIBg==
"@types/lodash@^4.14.119": "@types/lodash@^4.14.119":
version "4.14.119" version "4.14.119"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.119.tgz#be847e5f4bc3e35e46d041c394ead8b603ad8b39" resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.119.tgz#be847e5f4bc3e35e46d041c394ead8b603ad8b39"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment