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