Welcome to the Coding Garden Frequently Asked Questions! If you are new here and you have a general question, it's very likely I've answered it already.
141
stars
14
forks
source link
Typescript - How to describe a formatFunctions Object #14
The following line is now problematic, but I don't know how to fix it quickly:
const partFormatters = parts.map((token: string) => formatFunctions[token]);
// Element implicitly has an 'any' type because expression of type 'string' can't be used to index type
// '{ d(date: Date): number; dd(date: Date): string; D(date: Date, locale: Locale): string | undefined;
// DD(date: Date, locale: Locale): string | undefined; ... 6 more ...; yyyy(date: Date): string; }'.
// No index signature with a parameter of type 'string' was found on type '{ d(date: Date): number;
// dd(date: Date): string; D(date: Date, locale: Locale): string | undefined; DD(date: Date, locale: Locale):
// string | undefined; ... 6 more ...; yyyy(date: Date): string; }'.ts(7053)
Example Object which contains functions, which are later accessed via
formatFunctions[key]
.The following line is now problematic, but I don't know how to fix it quickly: