Merge pull request #16089 from grafana/no-implicit-any-fixes-p4

Fixed no implicit any for form dropdown & panel model
This commit is contained in:
Torkel Ödegaard 2019-03-20 07:01:14 +01:00 committed by GitHub
commit 0a2d69c794
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 75 additions and 92 deletions

View File

@ -33,6 +33,7 @@
"@types/react-select": "^2.0.4",
"@types/react-transition-group": "^2.0.15",
"@types/react-virtualized": "^9.18.12",
"@types/clipboard": "^2.0.1",
"angular-mocks": "1.6.6",
"autoprefixer": "^6.4.0",
"axios": "^0.17.1",
@ -107,7 +108,7 @@
"systemjs-plugin-css": "^0.1.36",
"ts-jest": "^23.10.4",
"ts-loader": "^5.1.0",
"ts-node": "^8.0.2",
"ts-node": "8.0.2",
"tslib": "^1.9.3",
"tslint": "^5.8.0",
"tslint-loader": "^3.5.3",
@ -176,7 +177,7 @@
"baron": "^3.0.3",
"brace": "^0.10.0",
"classnames": "^2.2.6",
"clipboard": "^1.7.1",
"clipboard": "^2.0.4",
"d3": "^4.11.0",
"d3-scale-chromatic": "^1.3.0",
"eventemitter3": "^2.0.3",

View File

@ -1,4 +1,4 @@
import React, { FC } from 'react';
import React, { FC, CSSProperties } from 'react';
import Transition, { ExitHandler } from 'react-transition-group/Transition';
interface Props {
@ -10,12 +10,12 @@ interface Props {
}
export const FadeIn: FC<Props> = props => {
const defaultStyle = {
const defaultStyle: CSSProperties = {
transition: `opacity ${props.duration}ms linear`,
opacity: 0,
};
const transitionStyles = {
const transitionStyles: { [str: string]: CSSProperties } = {
exited: { opacity: 0, display: 'none' },
entering: { opacity: 0 },
entered: { opacity: 1 },

View File

@ -1,4 +1,4 @@
import React from 'react';
import React, { CSSProperties, FC } from 'react';
import Transition from 'react-transition-group/Transition';
interface Style {
@ -16,11 +16,18 @@ export const defaultStyle: Style = {
overflow: 'hidden',
};
export default ({ children, in: inProp, maxHeight = defaultMaxHeight, style = defaultStyle }) => {
export interface Props {
children: React.ReactNode;
in: boolean;
maxHeight?: number;
style?: CSSProperties;
}
export const SlideDown: FC<Props> = ({ children, in: inProp, maxHeight = defaultMaxHeight, style = defaultStyle }) => {
// There are 4 main states a Transition can be in:
// ENTERING, ENTERED, EXITING, EXITED
// https://reactcommunity.org/react-transition-group/
const transitionStyles = {
// https://reactcommunity.or[g/react-transition-group/
const transitionStyles: { [str: string]: CSSProperties } = {
exited: { maxHeight: 0 },
entering: { maxHeight: maxHeight },
entered: { maxHeight: 'unset', overflow: 'visible' },
@ -34,6 +41,7 @@ export default ({ children, in: inProp, maxHeight = defaultMaxHeight, style = de
style={{
...style,
...transitionStyles[state],
inProp,
}}
>
{children}

View File

@ -11,10 +11,10 @@ interface Props {
}
export class CopyToClipboard extends PureComponent<Props> {
clipboardjs: any;
clipboardjs: ClipboardJS;
myRef: any;
constructor(props) {
constructor(props: Props) {
super(props);
this.myRef = React.createRef();
}

View File

@ -1,5 +1,5 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { shallow } from 'enzyme';
import EmptyListCTA from './EmptyListCTA';
const model = {
@ -16,7 +16,7 @@ const model = {
describe('EmptyListCTA', () => {
it('renders correctly', () => {
const tree = renderer.create(<EmptyListCTA model={model} />).toJSON();
const tree = shallow(<EmptyListCTA model={model} />);
expect(tree).toMatchSnapshot();
});
});

View File

@ -1,5 +1,4 @@
import React, { PureComponent, createRef } from 'react';
// import JSONFormatterJS, { JSONFormatterConfiguration } from 'json-formatter-js';
import { JsonExplorer } from 'app/core/core'; // We have made some monkey-patching of json-formatter-js so we can't switch right now
interface Props {

View File

@ -1,7 +1,8 @@
import _ from 'lodash';
import coreModule from '../../core_module';
import { ISCEService, IQService } from 'angular';
function typeaheadMatcher(this: any, item) {
function typeaheadMatcher(this: any, item: string) {
let str = this.query;
if (str === '') {
return true;
@ -16,8 +17,8 @@ function typeaheadMatcher(this: any, item) {
}
export class FormDropdownCtrl {
inputElement: any;
linkElement: any;
inputElement: JQLite;
linkElement: JQLite;
model: any;
display: any;
text: any;
@ -37,7 +38,13 @@ export class FormDropdownCtrl {
debounce: number;
/** @ngInject */
constructor(private $scope, $element, private $sce, private templateSrv, private $q) {
constructor(
private $scope: any,
$element: JQLite,
private $sce: ISCEService,
private templateSrv: any,
private $q: IQService
) {
this.inputElement = $element.find('input').first();
this.linkElement = $element.find('a').first();
this.linkMode = true;
@ -99,7 +106,7 @@ export class FormDropdownCtrl {
}
}
getOptionsInternal(query) {
getOptionsInternal(query: string) {
const result = this.getOptions({ $query: query });
if (this.isPromiseLike(result)) {
return result;
@ -107,7 +114,7 @@ export class FormDropdownCtrl {
return this.$q.when(result);
}
isPromiseLike(obj) {
isPromiseLike(obj: any) {
return obj && typeof obj.then === 'function';
}
@ -117,7 +124,7 @@ export class FormDropdownCtrl {
} else {
// if we have text use it
if (this.lookupText) {
this.getOptionsInternal('').then(options => {
this.getOptionsInternal('').then((options: any) => {
const item = _.find(options, { value: this.model });
this.updateDisplay(item ? item.text : this.model);
});
@ -127,12 +134,12 @@ export class FormDropdownCtrl {
}
}
typeaheadSource(query, callback) {
this.getOptionsInternal(query).then(options => {
typeaheadSource(query: string, callback: (res: any) => void) {
this.getOptionsInternal(query).then((options: any) => {
this.optionCache = options;
// extract texts
const optionTexts = _.map(options, op => {
const optionTexts = _.map(options, (op: any) => {
return _.escape(op.text);
});
@ -147,7 +154,7 @@ export class FormDropdownCtrl {
});
}
typeaheadUpdater(text) {
typeaheadUpdater(text: string) {
if (text === this.text) {
clearTimeout(this.cancelBlur);
this.inputElement.focus();
@ -159,7 +166,7 @@ export class FormDropdownCtrl {
return text;
}
switchToLink(fromClick) {
switchToLink(fromClick: boolean) {
if (this.linkMode && !fromClick) {
return;
}
@ -178,7 +185,7 @@ export class FormDropdownCtrl {
this.cancelBlur = setTimeout(this.switchToLink.bind(this), 200);
}
updateValue(text) {
updateValue(text: string) {
text = _.unescape(text);
if (text === '' || this.text === text) {
@ -214,7 +221,7 @@ export class FormDropdownCtrl {
});
}
updateDisplay(text) {
updateDisplay(text: string) {
this.text = text;
this.display = this.$sce.trustAsHtml(this.templateSrv.highlightVariablesAsHtml(text));
}

View File

@ -232,7 +232,7 @@ export class JsonExplorer {
// some pretty handling of number arrays
if (this.isNumberArray()) {
this.json.forEach((val, index) => {
this.json.forEach((val: any, index: number) => {
if (index > 0) {
arrayWrapperSpan.appendChild(createElement('span', 'array-comma', ','));
}

View File

@ -16,7 +16,7 @@ export class LayoutSelectorCtrl {
mode: string;
/** @ngInject */
constructor(private $rootScope) {
constructor(private $rootScope: any) {
this.mode = store.get('grafana.list.layout.mode') || 'grid';
}
@ -46,18 +46,18 @@ export function layoutSelector() {
}
/** @ngInject */
export function layoutMode($rootScope) {
export function layoutMode($rootScope: any) {
return {
restrict: 'A',
scope: {},
link: (scope, elem) => {
link: (scope: any, elem: any) => {
const layout = store.get('grafana.list.layout.mode') || 'grid';
let className = 'card-list-layout-' + layout;
elem.addClass(className);
$rootScope.onAppEvent(
'layout-mode-changed',
(evt, newLayout) => {
(evt: any, newLayout: any) => {
elem.removeClass(className);
className = 'card-list-layout-' + newLayout;
elem.addClass(className);

View File

@ -7,7 +7,7 @@ import { getNavModel } from 'app/core/selectors/navModel';
import { getApiKeys, getApiKeysCount } from './state/selectors';
import { loadApiKeys, deleteApiKey, setSearchQuery, addApiKey } from './state/actions';
import Page from 'app/core/components/Page/Page';
import SlideDown from 'app/core/components/Animations/SlideDown';
import { SlideDown } from 'app/core/components/Animations/SlideDown';
import ApiKeysAddedModal from './ApiKeysAddedModal';
import config from 'app/core/config';
import appEvents from 'app/core/app_events';

View File

@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import { Tooltip } from '@grafana/ui';
import SlideDown from 'app/core/components/Animations/SlideDown';
import { SlideDown } from 'app/core/components/Animations/SlideDown';
import { StoreState, FolderInfo } from 'app/types';
import { DashboardAcl, PermissionLevel, NewDashboardAclItem } from 'app/types/acl';
import {

View File

@ -111,12 +111,12 @@ export class PanelModel {
cachedPluginOptions?: any;
legend?: { show: boolean };
constructor(model) {
constructor(model: any) {
this.events = new Emitter();
// copy properties from persisted model
for (const property in model) {
this[property] = model[property];
(this as any)[property] = model[property];
}
// defaults
@ -150,7 +150,7 @@ export class PanelModel {
}
}
getOptions(panelDefaults) {
getOptions(panelDefaults: any) {
return _.defaultsDeep(this.options || {}, panelDefaults);
}
@ -227,7 +227,7 @@ export class PanelModel {
}
return {
...acc,
[property]: this[property],
[property]: (this as any)[property],
};
}, {});
}
@ -236,7 +236,7 @@ export class PanelModel {
const prevOptions = this.cachedPluginOptions[pluginId] || {};
Object.keys(prevOptions).map(property => {
this[property] = prevOptions[property];
(this as any)[property] = prevOptions[property];
});
}
@ -252,7 +252,7 @@ export class PanelModel {
continue;
}
delete this[key];
delete (this as any)[key];
}
this.cachedPluginOptions[oldPluginId] = oldOptions;

View File

@ -3,7 +3,7 @@ import { hot } from 'react-hot-loader';
import { connect } from 'react-redux';
import Page from 'app/core/components/Page/Page';
import { Tooltip } from '@grafana/ui';
import SlideDown from 'app/core/components/Animations/SlideDown';
import { SlideDown } from 'app/core/components/Animations/SlideDown';
import { getNavModel } from 'app/core/selectors/navModel';
import { NavModel, StoreState, FolderState } from 'app/types';
import { DashboardAcl, PermissionLevel, NewDashboardAclItem } from 'app/types/acl';

View File

@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import { connect } from 'react-redux';
import SlideDown from 'app/core/components/Animations/SlideDown';
import { SlideDown } from 'app/core/components/Animations/SlideDown';
import { Tooltip } from '@grafana/ui';
import { TeamGroup } from '../../types';
import { addTeamGroup, loadTeamGroups, removeTeamGroup } from './state/actions';

View File

@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import { connect } from 'react-redux';
import SlideDown from 'app/core/components/Animations/SlideDown';
import { SlideDown } from 'app/core/components/Animations/SlideDown';
import { UserPicker } from 'app/core/components/Select/UserPicker';
import { TagBadge } from 'app/core/components/TagFilter/TagBadge';
import { TeamMember, User } from 'app/types';

View File

@ -17,7 +17,6 @@ export const getSingleStatValues = (props: PanelProps<SingleStatBaseOptions>): D
decimals: valueOptions.decimals,
mappings: valueMappings,
thresholds: options.thresholds,
prefix: replaceVariables(valueOptions.prefix),
suffix: replaceVariables(valueOptions.suffix),
theme: config.theme,

View File

@ -27,7 +27,7 @@
"noUnusedLocals": true,
"baseUrl": "public",
"pretty": true,
"typeRoots": ["node_modules/@types", "types"],
"typeRoots": ["node_modules/@types", "public/app/types"],
"paths": {
"app": ["app"],
"sass": ["sass"]

View File

@ -1533,6 +1533,11 @@
resolved "https://registry.yarnpkg.com/@types/classnames/-/classnames-2.2.7.tgz#fb68cc9be8487e6ea5b13700e759bfbab7e0fefd"
integrity sha512-rzOhiQ55WzAiFgXRtitP/ZUT8iVNyllEpylJ5zHzR4vArUvMB39GTk+Zon/uAM0JxEFAWnwsxC2gH8s+tZ3Myg==
"@types/clipboard@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/clipboard/-/clipboard-2.0.1.tgz#75a74086c293d75b12bc93ff13bc7797fef05a40"
integrity sha512-gJJX9Jjdt3bIAePQRRjYWG20dIhAgEqonguyHxXuqALxsoDsDLimihqrSg8fXgVTJ4KZCzkfglKtwsh/8dLfbA==
"@types/commander@^2.12.2":
version "2.12.2"
resolved "https://registry.yarnpkg.com/@types/commander/-/commander-2.12.2.tgz#183041a23842d4281478fa5d23c5ca78e6fd08ae"
@ -1879,7 +1884,7 @@
"@types/prop-types" "*"
"@types/react" "*"
"@types/react@*", "@types/react@16.8.8", "@types/react@^16.7.6", "@types/react@^16.8.8":
"@types/react@*", "@types/react@16.8.8", "@types/react@^16.8.8":
version "16.8.8"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.8.8.tgz#4b60a469fd2469f7aa6eaa0f8cfbc51f6d76e662"
integrity sha512-xwEvyet96u7WnB96kqY0yY7qxx/pEpU51QeACkKFtrgjjXITQn0oO1iwPEraXVgh10ZFPix7gs1R4OJXF7P5sg==
@ -5044,16 +5049,7 @@ cli-width@^2.0.0:
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=
clipboard@^1.7.1:
version "1.7.1"
resolved "https://registry.yarnpkg.com/clipboard/-/clipboard-1.7.1.tgz#360d6d6946e99a7a1fef395e42ba92b5e9b5a16b"
integrity sha1-Ng1taUbpmnof7zleQrqStem1oWs=
dependencies:
good-listener "^1.2.2"
select "^1.1.2"
tiny-emitter "^2.0.0"
clipboard@^2.0.0:
clipboard@^2.0.0, clipboard@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/clipboard/-/clipboard-2.0.4.tgz#836dafd66cf0fea5d71ce5d5b0bf6e958009112d"
integrity sha512-Vw26VSLRpJfBofiVaFb/I8PVfdI1OxKcYShe6fm0sP/DtmiWQNCjhM/okTvdCo0G+lMMm1rMYbk4IK4x1X+kgQ==
@ -6310,7 +6306,7 @@ debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:
dependencies:
ms "^2.1.1"
debuglog@*, debuglog@^1.0.1:
debuglog@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
@ -9214,7 +9210,7 @@ import-local@^2.0.0:
pkg-dir "^3.0.0"
resolve-cwd "^2.0.0"
imurmurhash@*, imurmurhash@^0.1.4:
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
@ -10938,11 +10934,6 @@ lockfile@^1.0.4:
dependencies:
signal-exit "^3.0.2"
lodash._baseindexof@*:
version "3.1.0"
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=
lodash._baseuniq@~4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
@ -10951,29 +10942,12 @@ lodash._baseuniq@~4.6.0:
lodash._createset "~4.0.0"
lodash._root "~3.0.0"
lodash._bindcallback@*:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=
lodash._cacheindexof@*:
version "3.0.2"
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=
lodash._createcache@*:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
dependencies:
lodash._getnative "^3.0.0"
lodash._createset@~4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=
lodash._getnative@*, lodash._getnative@^3.0.0:
lodash._getnative@^3.0.0:
version "3.9.1"
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=
@ -11067,11 +11041,6 @@ lodash.mergewith@^4.6.0:
resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz#639057e726c3afbdb3e7d42741caa8d6e4335927"
integrity sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==
lodash.restparam@*:
version "3.6.1"
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=
lodash.some@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d"
@ -14722,7 +14691,7 @@ readable-stream@~1.1.10:
isarray "0.0.1"
string_decoder "~0.10.x"
readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0:
readdir-scoped-modules@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747"
integrity sha1-n6+jfShr5dksuuve4DDcm19AZ0c=
@ -17162,10 +17131,10 @@ ts-loader@^5.1.0:
micromatch "^3.1.4"
semver "^5.0.1"
ts-node@^8.0.2:
version "8.0.3"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.0.3.tgz#aa60b836a24dafd8bf21b54766841a232fdbc641"
integrity sha512-2qayBA4vdtVRuDo11DEFSsD/SFsBXQBRZZhbRGSIkmYmVkWjULn/GGMdG10KVqkaGndljfaTD8dKjWgcejO8YA==
ts-node@8.0.2:
version "8.0.2"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.0.2.tgz#9ecdf8d782a0ca4c80d1d641cbb236af4ac1b756"
integrity sha512-MosTrinKmaAcWgO8tqMjMJB22h+sp3Rd1i4fdoWY4mhBDekOwIAKI/bzmRi7IcbCmjquccYg2gcF6NBkLgr0Tw==
dependencies:
arg "^4.1.0"
diff "^3.1.0"