From 493714c27dfbe8c14199e607feecbb5446d50c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 25 Dec 2018 09:59:23 +0100 Subject: [PATCH] Fixed JQuery typing issues --- package.json | 24 +++++++++++++------ packages/grafana-build/package.json | 3 ++- packages/grafana-ui/src/types/jquery.d.ts | 16 ++++++++++++- public/app/core/directives/tags.ts | 4 ++-- .../plugins/panel/graph/specs/graph.test.ts | 1 + public/app/types/jquery.d.ts | 17 +++++++++++++ yarn.lock | 4 ++-- 7 files changed, 56 insertions(+), 13 deletions(-) create mode 100644 public/app/types/jquery.d.ts diff --git a/package.json b/package.json index bb384197b8e..189ff637d4b 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,11 @@ }, "devDependencies": { "@babel/core": "^7.1.2", - "@rtsao/plugin-proposal-class-properties": "^7.0.1-patch.1", "@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/preset-env": "^7.1.0", "@babel/preset-react": "^7.0.0", "@babel/preset-typescript": "^7.1.0", + "@rtsao/plugin-proposal-class-properties": "^7.0.1-patch.1", "@types/d3": "^4.10.1", "@types/enzyme": "^3.1.13", "@types/jest": "^23.3.2", @@ -25,6 +25,7 @@ "@types/react-custom-scrollbars": "^4.0.5", "@types/react-dom": "^16.0.9", "@types/react-select": "^2.0.4", + "@types/jquery": "^1.10.35", "angular-mocks": "1.6.6", "autoprefixer": "^6.4.0", "axios": "^0.17.1", @@ -116,9 +117,18 @@ "precommit": "lint-staged && grunt precommit" }, "lint-staged": { - "*.{ts,tsx}": ["prettier --write", "git add"], - "*.scss": ["prettier --write", "git add"], - "*pkg/**/*.go": ["gofmt -w -s", "git add"] + "*.{ts,tsx}": [ + "prettier --write", + "git add" + ], + "*.scss": [ + "prettier --write", + "git add" + ], + "*pkg/**/*.go": [ + "gofmt -w -s", + "git add" + ] }, "prettier": { "trailingComma": "es5", @@ -128,6 +138,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/polyfill": "^7.0.0", + "@torkelo/react-select": "2.1.1", "angular": "1.6.6", "angular-bindonce": "0.3.1", "angular-native-dragdrop": "1.2.2", @@ -154,10 +165,9 @@ "react-custom-scrollbars": "^4.2.1", "react-dom": "^16.6.3", "react-grid-layout": "0.16.6", - "react-popper": "^1.3.0", "react-highlight-words": "0.11.0", + "react-popper": "^1.3.0", "react-redux": "^5.0.7", - "@torkelo/react-select": "2.1.1", "react-sizeme": "^2.3.6", "react-table": "^6.8.6", "react-transition-group": "^2.2.1", @@ -181,7 +191,7 @@ "caniuse-db": "1.0.30000772", "**/@types/react": "16.7.6" }, - "workspaces": { + "workspaces": { "packages": [ "packages/*" ], diff --git a/packages/grafana-build/package.json b/packages/grafana-build/package.json index 0bc9340a667..24fb648c8d4 100644 --- a/packages/grafana-build/package.json +++ b/packages/grafana-build/package.json @@ -5,7 +5,8 @@ "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "tslint": "echo \"Nothing to do\"", + "typecheck": "echo \"Nothing to do\"" }, "author": "", "license": "ISC" diff --git a/packages/grafana-ui/src/types/jquery.d.ts b/packages/grafana-ui/src/types/jquery.d.ts index e6e1be50edc..4a6f60b6029 100644 --- a/packages/grafana-ui/src/types/jquery.d.ts +++ b/packages/grafana-ui/src/types/jquery.d.ts @@ -1,3 +1,17 @@ +interface JQueryPlot { + (element: HTMLElement | JQuery, data: any, options: any): void; + plugins: any[]; +} + interface JQueryStatic { - plot: (element: HTMLElement, data: any[], options: any) => void; + plot: JQueryPlot; +} + +interface JQuery { + place_tt: any; + modal: any; + tagsinput: any; + typeahead: any; + accessKey: any; + tooltip: any; } diff --git a/public/app/core/directives/tags.ts b/public/app/core/directives/tags.ts index 33a2252a683..27bddfb1883 100644 --- a/public/app/core/directives/tags.ts +++ b/public/app/core/directives/tags.ts @@ -69,7 +69,7 @@ function bootstrapTagsinput() { }, }); - select.on('itemAdded', event => { + select.on('itemAdded', (event: any) => { if (scope.model.indexOf(event.item) === -1) { scope.model.push(event.item); if (scope.onTagsUpdated) { @@ -85,7 +85,7 @@ function bootstrapTagsinput() { setColor(event.item, tagElement); }); - select.on('itemRemoved', event => { + select.on('itemRemoved', (event: any) => { const idx = scope.model.indexOf(event.item); if (idx !== -1) { scope.model.splice(idx, 1); diff --git a/public/app/plugins/panel/graph/specs/graph.test.ts b/public/app/plugins/panel/graph/specs/graph.test.ts index be243587820..58a35ea2a5f 100644 --- a/public/app/plugins/panel/graph/specs/graph.test.ts +++ b/public/app/plugins/panel/graph/specs/graph.test.ts @@ -114,6 +114,7 @@ describe('grafanaGraph', () => { {} ); + // @ts-ignore $.plot = ctrl.plot = jest.fn(); scope.ctrl = ctrl; diff --git a/public/app/types/jquery.d.ts b/public/app/types/jquery.d.ts new file mode 100644 index 00000000000..4a6f60b6029 --- /dev/null +++ b/public/app/types/jquery.d.ts @@ -0,0 +1,17 @@ +interface JQueryPlot { + (element: HTMLElement | JQuery, data: any, options: any): void; + plugins: any[]; +} + +interface JQueryStatic { + plot: JQueryPlot; +} + +interface JQuery { + place_tt: any; + modal: any; + tagsinput: any; + typeahead: any; + accessKey: any; + tooltip: any; +} diff --git a/yarn.lock b/yarn.lock index 3d267ed3e1d..8066618bb41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1093,7 +1093,7 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@^16.1.0", "@types/react@^16.7.6": +"@types/react@*", "@types/react@16.7.6", "@types/react@^16.1.0", "@types/react@^16.7.6": version "16.7.6" resolved "https://registry.yarnpkg.com/@types/react/-/react-16.7.6.tgz#80e4bab0d0731ad3ae51f320c4b08bdca5f03040" integrity sha512-QBUfzftr/8eg/q3ZRgf/GaDP6rTYc7ZNem+g4oZM38C9vXyV8AWRWaTQuW5yCoZTsfHrN7b3DeEiUnqH9SrnpA== @@ -3163,7 +3163,7 @@ caniuse-api@^1.5.2: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639: +caniuse-db@1.0.30000772, caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639: version "1.0.30000772" resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000772.tgz#51aae891768286eade4a3d8319ea76d6a01b512b" integrity sha1-UarokXaChureSj2DGep21qAbUSs=