remove most uses of as any in typescript

- replaced many uses of `as any` with another more specific cast `as T`
- filled in missing typed for items that needed to be typed
  - new runtime code was added where necessary to satisfy the new types with comments
- added missing theme variable "sidebar-active" to the Theme variables
- forms using `react-hook-form` are now typechecked
- changed some instances of `target` into `currentTarget` while removing `as any` assertions
This commit is contained in:
bree
2021-07-04 07:09:39 -04:00
parent 504f491074
commit b341f5d166
31 changed files with 161 additions and 117 deletions

View File

@@ -34,9 +34,10 @@ export interface ClientOperations {
openDM: (user_id: string) => Promise<string>;
}
export const AppContext = createContext<Client>(undefined as any);
export const StatusContext = createContext<ClientStatus>(undefined as any);
export const OperationsContext = createContext<ClientOperations>(undefined as any);
// TODO: remove temporary non-null assertions and properly typecheck these as they aren't always immedietely initialized
export const AppContext = createContext<Client>(null!);
export const StatusContext = createContext<ClientStatus>(null!);
export const OperationsContext = createContext<ClientOperations>(null!);
type Props = WithDispatcher & {
auth: AuthState;
@@ -93,16 +94,14 @@ function Context({ auth, children, dispatcher }: Props) {
const login = () =>
dispatcher({
type: "LOGIN",
session: client.session as any
session: client.session! // TODO: verify that this null assertion is correct
});
if (onboarding) {
openScreen({
id: "onboarding",
callback: async (username: string) => {
await (onboarding as any)(username, true);
login();
}
callback: (username: string) =>
onboarding(username, true).then(login)
});
} else {
login();