Improve init types

This commit is contained in:
Daniel Lautzenheiser 2022-11-05 23:55:37 -04:00
parent 8623680d2b
commit 4da84105a2
No known key found for this signature in database
GPG Key ID: D2F75F7DD915527E
2 changed files with 7 additions and 4 deletions

View File

@ -20,7 +20,7 @@ import { store } from './store';
import type { AnyAction } from '@reduxjs/toolkit'; import type { AnyAction } from '@reduxjs/toolkit';
import type { ConnectedProps } from 'react-redux'; import type { ConnectedProps } from 'react-redux';
import type { Config } from './interface'; import type { BaseField, Config, UnknownField } from './interface';
import type { RootState } from './store'; import type { RootState } from './store';
const ROOT_ID = 'nc-root'; const ROOT_ID = 'nc-root';
@ -50,7 +50,10 @@ export type AppRootProps = ConnectedProps<typeof connector>;
const ConnectedTranslatedApp = connector(TranslatedApp); const ConnectedTranslatedApp = connector(TranslatedApp);
function bootstrap(opts?: { config?: Config; autoInitialize?: boolean }) { function bootstrap<F extends BaseField = UnknownField>(opts?: {
config?: Config<F>;
autoInitialize?: boolean;
}) {
const { config, autoInitialize = true } = opts ?? {}; const { config, autoInitialize = true } = opts ?? {};
/** /**
@ -86,7 +89,7 @@ function bootstrap(opts?: { config?: Config; autoInitialize?: boolean }) {
} }
store.dispatch( store.dispatch(
loadConfig(config, function onLoad(config) { loadConfig(config as Config | undefined, function onLoad(config) {
if (config.backend.name !== 'git-gateway') { if (config.backend.name !== 'git-gateway') {
store.dispatch(authenticateUser() as unknown as AnyAction); store.dispatch(authenticateUser() as unknown as AnyAction);
} }

View File

@ -478,7 +478,7 @@ export type AuthScope = 'repo' | 'public_repo';
export type SlugEncoding = 'unicode' | 'ascii'; export type SlugEncoding = 'unicode' | 'ascii';
export type RenderedField<T extends BaseField = UnknownField> = Omit<T, 'fields'> & { export type RenderedField<F extends BaseField = UnknownField> = Omit<F, 'fields'> & {
fields?: ReactNode[]; fields?: ReactNode[];
}; };