Enabled @typescript-eslint/no-unsafe-return eslint rule again

This commit is contained in:
Alejandro Celaya
2021-02-28 18:48:36 +01:00
parent ad0a889548
commit ce0fc1094e
9 changed files with 14 additions and 13 deletions

View File

@@ -11,7 +11,7 @@ export default class ColorGenerator {
private readonly colors: Record<string, string>;
public constructor(private readonly storage: LocalStorage) {
this.colors = this.storage.get<Record<string, string>>('colors') || {};
this.colors = this.storage.get<Record<string, string>>('colors') ?? {};
}
public readonly getColorForKey = (key: string) => {

View File

@@ -4,10 +4,10 @@ const buildPath = (path: string) => `${PREFIX}.${path}`;
export default class LocalStorage {
public constructor(private readonly localStorage: Storage) {}
public readonly get = <T>(key: string): T => {
public readonly get = <T>(key: string): T | undefined => {
const item = this.localStorage.getItem(buildPath(key));
return item ? JSON.parse(item) : undefined;
return item ? JSON.parse(item) as T : undefined;
};
public readonly set = (key: string, value: any) => this.localStorage.setItem(buildPath(key), JSON.stringify(value));