Improve init types
This commit is contained in:
parent
8623680d2b
commit
4da84105a2
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user