Typescript: start fixing 'strict' mode errors
This commit is contained in:
parent
8d8307adf2
commit
14ec40ee95
6 changed files with 24 additions and 13 deletions
|
@ -59,7 +59,7 @@ export function fetchInstance() {
|
|||
return api(getState).get('/api/v1/instance').then(({ data: instance }: { data: Record<string, any> }) => {
|
||||
dispatch({ type: INSTANCE_FETCH_SUCCESS, instance });
|
||||
if (needsNodeinfo(instance)) {
|
||||
dispatch(fetchNodeinfo()); // Pleroma < 2.1 backwards compatibility
|
||||
dispatch(fetchNodeinfo() as any); // Pleroma < 2.1 backwards compatibility
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
|
@ -73,8 +73,10 @@ export function loadInstance() {
|
|||
return (dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const host = getHost(getState());
|
||||
|
||||
return dispatch(rememberInstance(host)).finally(() => {
|
||||
return dispatch(fetchInstance());
|
||||
if (!host) return new Promise(r => r(null));
|
||||
|
||||
return dispatch(rememberInstance(host) as any).finally(() => {
|
||||
return dispatch(fetchInstance() as any);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ export const calculateStatus = (
|
|||
const emojiMap = makeEmojiMap(status.emojis);
|
||||
|
||||
return status.merge({
|
||||
search_index: domParser.parseFromString(searchContent, 'text/html').documentElement.textContent,
|
||||
search_index: domParser.parseFromString(searchContent, 'text/html').documentElement.textContent || undefined,
|
||||
contentHtml: stripCompatibilityFeatures(emojify(status.content, emojiMap)),
|
||||
spoilerHtml: emojify(escapeTextContentForBrowser(spoilerText), emojiMap),
|
||||
hidden: expandSpoilers ? false : spoilerText.length > 0 || status.sensitive,
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import localforage from 'localforage';
|
||||
|
||||
interface IKVStore extends LocalForage {
|
||||
getItemOrError?: (key: string) => Promise<any>,
|
||||
getItemOrError: (key: string) => Promise<any>,
|
||||
}
|
||||
|
||||
// localForage
|
||||
// https://localforage.github.io/localForage/#settings-api-config
|
||||
export const KVStore: IKVStore = localforage.createInstance({
|
||||
export const KVStore = localforage.createInstance({
|
||||
name: 'soapbox',
|
||||
description: 'Soapbox offline data store',
|
||||
driver: localforage.INDEXEDDB,
|
||||
storeName: 'keyvaluepairs',
|
||||
});
|
||||
}) as IKVStore;
|
||||
|
||||
// localForage returns 'null' when a key isn't found.
|
||||
// In the Redux action flow, we want it to fail harder.
|
||||
|
|
|
@ -13,7 +13,7 @@ const find = (
|
|||
configs: ImmutableList<Config>,
|
||||
group: string,
|
||||
key: string,
|
||||
): Config => {
|
||||
): Config | undefined => {
|
||||
return configs.find(config =>
|
||||
config.isSuperset(ImmutableMap({ group, key })),
|
||||
);
|
||||
|
|
|
@ -61,19 +61,28 @@ function hslToHex(color: Hsl): string {
|
|||
}
|
||||
|
||||
// Generate accent color from brand color
|
||||
export const generateAccent = (brandColor: string): string => {
|
||||
const { h } = rgbToHsl(hexToRgb(brandColor));
|
||||
export const generateAccent = (brandColor: string): string | null => {
|
||||
const rgb = hexToRgb(brandColor);
|
||||
if (!rgb) return null;
|
||||
|
||||
const { h } = rgbToHsl(rgb);
|
||||
return hslToHex({ h: h - 15, s: 86, l: 44 });
|
||||
};
|
||||
|
||||
const parseShades = (obj: Record<string, any>, color: string, shades: Record<string, any>) => {
|
||||
if (typeof shades === 'string') {
|
||||
const { r, g, b } = hexToRgb(shades);
|
||||
const rgb = hexToRgb(shades);
|
||||
if (!rgb) return obj;
|
||||
|
||||
const { r, g, b } = rgb;
|
||||
return obj[`--color-${color}`] = `${r} ${g} ${b}`;
|
||||
}
|
||||
|
||||
return Object.keys(shades).forEach(shade => {
|
||||
const { r, g, b } = hexToRgb(shades[shade]);
|
||||
const rgb = hexToRgb(shades[shade]);
|
||||
if (!rgb) return;
|
||||
|
||||
const { r, g, b } = rgb;
|
||||
obj[`--color-${color}-${shade}`] = `${r} ${g} ${b}`;
|
||||
});
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"compilerOptions": {
|
||||
"baseUrl": "app/",
|
||||
"sourceMap": true,
|
||||
"noImplicitAny": true,
|
||||
"strict": true,
|
||||
"module": "es6",
|
||||
"target": "es5",
|
||||
"jsx": "react",
|
||||
|
|
Loading…
Reference in a new issue