I have a problem that I think can be boiled down to this code snippet
public a() {
return {a: 0};
}
public b() {
return this.a()[0];
}
A while back the a function returned an array, but got refactored into returning a single object.
It would have been great if I got an error on the b function, but as it stands right now it compiles happily and results in errors at runtime.
So even though I understand why it is valid code (accessing the zero key on the a object), I would like to have eslint or tsc warn me. But I have a hard time finding any rules/config that matches that. So is it at all possible?
Can add that this is the compilerOptions of my tsconfig
"compilerOptions": {
"skipLibCheck": true,
"strict": true,
"strictNullChecks": false,
"typeRoots": ["./node_modules/@types", "./Script/typings"],
"experimentalDecorators": true,
"useDefineForClassFields": false,
"esModuleInterop": true,
"noImplicitAny": false,
"module": "ES2020",
"target": "ES2020",
"lib": [
"ES2021",
"ES6",
"DOM",
"DOM.Iterable"
],
"allowJs": false,
"sourceMap": true,
"moduleResolution": "node",
"paths": {
"/": [
"./"
],
"/*": [
"./*"
]
},
"outDir": "build"
}
noImplicitAny: false, change it totrueand you will get an error.