Typed variables pt6: Clean up and test variable type guards (take 2) (#54025)
* Add fixture-factories for all variable types * clean up variable guards * add tests for isMulti, hasCurrent, and hasOptions variable type guards * create VariableSupport type to try and work around ts wonkiness
This commit is contained in:
@@ -173,6 +173,13 @@ export interface DataSourceConstructor<
|
||||
new (instanceSettings: DataSourceInstanceSettings<TOptions>, ...args: any[]): DSType;
|
||||
}
|
||||
|
||||
// VariableSupport is hoisted up to its own type to fix the wonky intermittent
|
||||
// 'variables is references directly or indirectly' error
|
||||
type VariableSupport<TQuery extends DataQuery, TOptions extends DataSourceJsonData> =
|
||||
| StandardVariableSupport<DataSourceApi<TQuery, TOptions>>
|
||||
| CustomVariableSupport<DataSourceApi<TQuery, TOptions>>
|
||||
| DataSourceVariableSupport<DataSourceApi<TQuery, TOptions>>;
|
||||
|
||||
/**
|
||||
* The main data source abstraction interface, represents an instance of a data source
|
||||
*
|
||||
@@ -341,10 +348,7 @@ abstract class DataSourceApi<
|
||||
* Defines new variable support
|
||||
* @alpha -- experimental
|
||||
*/
|
||||
variables?:
|
||||
| StandardVariableSupport<DataSourceApi<TQuery, TOptions>>
|
||||
| CustomVariableSupport<DataSourceApi<TQuery, TOptions>>
|
||||
| DataSourceVariableSupport<DataSourceApi<TQuery, TOptions>>;
|
||||
variables?: VariableSupport<TQuery, TOptions>;
|
||||
|
||||
/*
|
||||
* Optionally, use this method to set default values for a query
|
||||
|
||||
Reference in New Issue
Block a user