Merge branch 'next-ts-strict' into 'next'

Next: Typescript: start fixing 'strict' mode errors

See merge request soapbox-pub/soapbox-fe!1138
virtualized-window
Alex Gleason 3 years ago
commit 29e434d31f

@ -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,14 @@
"compilerOptions": {
"baseUrl": "app/",
"sourceMap": true,
"alwaysStrict": true,
"strictNullChecks": false,
"strictBindCallApply": true,
"strictFunctionTypes": false,
"strictPropertyInitialization": false,
"noImplicitAny": true,
"noImplicitThis": true,
"useUnknownInCatchVariables": true,
"module": "es6",
"target": "es5",
"jsx": "react",

Loading…
Cancel
Save