I have a config.json file:
{
"attribute": "value"
}
When I try importing it:
import data from './config.json'
class Service1 {
private config: Record<string, unknown> | undefined
initConfig(data: Record<string, unknown>) {
this.config = data
return this.config
}
getAttribute(){
const {attribute} = this.initConfig(data)
return attribute
}
}
I got the tslint error for the line const {attribute} = this.initConfig(data):
Argument of type '{}' is not assignable to parameter of type 'Record<string, unknown>'.
Index signature for type 'string' is missing in type '{}'.
Why typescript considers the data as an empty object?