Commit b6083d36 authored by Robert Knight's avatar Robert Knight

Typecheck sidebar/store/ with `noImplicitAny`

Add remaining missing types needed for src/sidebar/store/ to typecheck
with `noImplicitAny` and add this directory to tsconfig.no-any.json.
parent a010ea49
......@@ -65,13 +65,14 @@ export const ServiceContext = createContext(fallbackInjector);
* // Wrap `MyComponent` to inject "settings" service from context.
* export default withServices(MyComponent, ['settings']);
*
* @template Props
* @template {Record<string, unknown>} Props
* @template {string} ServiceName
* @param {ComponentType<Props>} Component
* @param {ServiceName[]} serviceNames - List of prop names that should be injected
* @return {ComponentType<Omit<Props,ServiceName>>}
*/
export function withServices(Component, serviceNames) {
/** @param {Omit<Props,ServiceName>} props */
function Wrapper(props) {
// Get the current dependency injector instance that is provided by a
// `ServiceContext.Provider` somewhere higher up the component tree.
......@@ -96,7 +97,9 @@ export function withServices(Component, serviceNames) {
services[service] = injector.get(service);
}
}
return <Component {...services} {...props} />;
const propsWithServices = /** @type {Props} */ ({ ...services, ...props });
return <Component {...propsWithServices} />;
}
// Set the name of the wrapper for use in debug tools and queries in Enzyme
......
/**
* @typedef {import('redux').Action} Action
* @typedef {import('redux').Store} Store
*/
/**
* A debug utility that prints information about internal application state
* changes to the console.
......@@ -8,14 +13,16 @@
* to the console, along with the application state before and after the action
* was handled.
*
* @param {import("redux").Store} store
* @param {Store} store
*/
export function debugMiddleware(store) {
/* eslint-disable no-console */
let serial = 0;
return function (next) {
return function (action) {
/** @param {(a: Action) => void} next */
return next => {
/** @param {Action} action */
return action => {
// @ts-ignore The window interface needs to be expanded to include this property
if (!window.debug) {
next(action);
......
......@@ -21,7 +21,7 @@ export function actionTypes(reducers) {
* which reads values from a Redux store, returns non-null.
*
* @template T
* @param {object} store - Redux store
* @param {import('redux').Store} store - Redux store
* @param {(s: Store) => T|null} selector - Function which returns a value from the
* store if the criteria is met or `null` otherwise.
* @return {Promise<T>}
......
......@@ -29,7 +29,7 @@
"shared/**/*.js",
"sidebar/config/*.js",
"sidebar/helpers/*.js",
"sidebar/store/create-store.js",
"sidebar/store/**/*.js",
"sidebar/util/*.js",
"types/*.d.ts"
],
......
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