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); const emojiMap = makeEmojiMap(status.emojis);
return status.merge({ 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)), contentHtml: stripCompatibilityFeatures(emojify(status.content, emojiMap)),
spoilerHtml: emojify(escapeTextContentForBrowser(spoilerText), emojiMap), spoilerHtml: emojify(escapeTextContentForBrowser(spoilerText), emojiMap),
hidden: expandSpoilers ? false : spoilerText.length > 0 || status.sensitive, hidden: expandSpoilers ? false : spoilerText.length > 0 || status.sensitive,

@ -1,17 +1,17 @@
import localforage from 'localforage'; import localforage from 'localforage';
interface IKVStore extends LocalForage { interface IKVStore extends LocalForage {
getItemOrError?: (key: string) => Promise<any>, getItemOrError: (key: string) => Promise<any>,
} }
// localForage // localForage
// https://localforage.github.io/localForage/#settings-api-config // https://localforage.github.io/localForage/#settings-api-config
export const KVStore: IKVStore = localforage.createInstance({ export const KVStore = localforage.createInstance({
name: 'soapbox', name: 'soapbox',
description: 'Soapbox offline data store', description: 'Soapbox offline data store',
driver: localforage.INDEXEDDB, driver: localforage.INDEXEDDB,
storeName: 'keyvaluepairs', storeName: 'keyvaluepairs',
}); }) as IKVStore;
// localForage returns 'null' when a key isn't found. // localForage returns 'null' when a key isn't found.
// In the Redux action flow, we want it to fail harder. // In the Redux action flow, we want it to fail harder.

@ -13,7 +13,7 @@ const find = (
configs: ImmutableList<Config>, configs: ImmutableList<Config>,
group: string, group: string,
key: string, key: string,
): Config => { ): Config | undefined => {
return configs.find(config => return configs.find(config =>
config.isSuperset(ImmutableMap({ group, key })), config.isSuperset(ImmutableMap({ group, key })),
); );

@ -61,19 +61,28 @@ function hslToHex(color: Hsl): string {
} }
// Generate accent color from brand color // Generate accent color from brand color
export const generateAccent = (brandColor: string): string => { export const generateAccent = (brandColor: string): string | null => {
const { h } = rgbToHsl(hexToRgb(brandColor)); const rgb = hexToRgb(brandColor);
if (!rgb) return null;
const { h } = rgbToHsl(rgb);
return hslToHex({ h: h - 15, s: 86, l: 44 }); return hslToHex({ h: h - 15, s: 86, l: 44 });
}; };
const parseShades = (obj: Record<string, any>, color: string, shades: Record<string, any>) => { const parseShades = (obj: Record<string, any>, color: string, shades: Record<string, any>) => {
if (typeof shades === 'string') { 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 obj[`--color-${color}`] = `${r} ${g} ${b}`;
} }
return Object.keys(shades).forEach(shade => { 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}`; obj[`--color-${color}-${shade}`] = `${r} ${g} ${b}`;
}); });
}; };

@ -2,7 +2,14 @@
"compilerOptions": { "compilerOptions": {
"baseUrl": "app/", "baseUrl": "app/",
"sourceMap": true, "sourceMap": true,
"alwaysStrict": true,
"strictNullChecks": false,
"strictBindCallApply": true,
"strictFunctionTypes": false,
"strictPropertyInitialization": false,
"noImplicitAny": true, "noImplicitAny": true,
"noImplicitThis": true,
"useUnknownInCatchVariables": true,
"module": "es6", "module": "es6",
"target": "es5", "target": "es5",
"jsx": "react", "jsx": "react",

Loading…
Cancel
Save