Chore: type improvements (#80464)

* type improvements

* some more fixes

* add TODOs to remove type assertions
This commit is contained in:
Ashley Harrison
2024-01-15 14:29:39 +00:00
committed by GitHub
parent b23ecaa3d1
commit d5db67a073
17 changed files with 78 additions and 237 deletions
@@ -46,8 +46,7 @@ export interface SystemConfigOverrideRule extends ConfigOverrideRule {
*/
export function isSystemOverrideWithRef<T extends SystemConfigOverrideRule>(ref: string) {
return (override: ConfigOverrideRule): override is T => {
const overrideAs = override as T;
return overrideAs.__systemRef === ref;
return '__systemRef' in override && override.__systemRef === ref;
};
}
@@ -58,7 +57,7 @@ export function isSystemOverrideWithRef<T extends SystemConfigOverrideRule>(ref:
* @internal
*/
export const isSystemOverride = (override: ConfigOverrideRule): override is SystemConfigOverrideRule => {
return typeof (override as SystemConfigOverrideRule)?.__systemRef === 'string';
return '__systemRef' in override && typeof override.__systemRef === 'string';
};
export interface FieldConfigSource<TOptions = any> {
@@ -69,7 +68,7 @@ export interface FieldConfigSource<TOptions = any> {
overrides: ConfigOverrideRule[];
}
export interface FieldOverrideContext extends StandardEditorContext<any, any> {
export interface FieldOverrideContext extends StandardEditorContext<any> {
field?: Field;
dataFrameIndex?: number; // The index for the selected field frame
}
+1 -1
View File
@@ -69,7 +69,7 @@ const assureBaseUrl = (url: string): string => {
* @param searchParamsToUpdate
* @returns
*/
const getUrlForPartial = (location: Location<any>, searchParamsToUpdate: UrlQueryMap) => {
const getUrlForPartial = (location: Location, searchParamsToUpdate: UrlQueryMap) => {
const searchParams = urlUtil.parseKeyValue(
location.search.startsWith('?') ? location.search.substring(1) : location.search
);
@@ -268,7 +268,7 @@ class DataSourceWithBackend<
* Apply template variables for explore
*/
interpolateVariablesInQueries(queries: TQuery[], scopedVars: ScopedVars, filters?: AdHocVariableFilter[]): TQuery[] {
return queries.map((q) => this.applyTemplateVariables(q, scopedVars, filters) as TQuery);
return queries.map((q) => this.applyTemplateVariables(q, scopedVars, filters));
}
/**
@@ -290,7 +290,7 @@ class DataSourceWithBackend<
*
* @virtual
*/
applyTemplateVariables(query: TQuery, scopedVars: ScopedVars, filters?: AdHocVariableFilter[]): Record<string, any> {
applyTemplateVariables(query: TQuery, scopedVars: ScopedVars, filters?: AdHocVariableFilter[]) {
return query;
}
@@ -323,7 +323,7 @@ class DataSourceWithBackend<
/**
* Send a POST request to the datasource resource path
*/
async postResource<T = any>(
async postResource<T = unknown>(
path: string,
data?: BackendSrvRequest['data'],
options?: Partial<BackendSrvRequest>