Hi I'm a complete beginner to TypeScript. I've had some success converting a basic site to TS but am stuck on this one last error.
interface Data {
data: Options;
}
interface Options {
name: string;
email: string;
message: string;
}
function encode(data: Data) {
return Object.keys(data)
.map(key => encodeURIComponent(key) + '=' + encodeURIComponent(data[key]))
.join('&');
}
data is an object with name: '' , email: '' and message: ''.
The following error occurs under data[key]:
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Data'. No index signature with a parameter of type 'string' was found on type 'Data'.
I've found many results about this particular error but am not able to apply one that will work in this context. Any help would be appreciated.