@leobastiani/get-with-default
v1.0.0
Published
get from an object with a default value
Readme
@leobastiani/get-with-default
solves the error
Element implicitly has an 'any' type because expression of type 'string' can't be used to indexhttps://stackoverflow.com/questions/57086672/element-implicitly-has-an-any-type-because-expression-of-type-string-cant-b
https://stackoverflow.com/a/69198602
Install
npm install @leobastiani/get-with-defaultor
yarn add @leobastiani/get-with-defaultExample
import { getWithDefault } from "@leobastiani/get-with-default";
const obj = {
a: 1,
b: 2,
c: 3,
};
const value = getWithDefault(obj, string, obj.c);