With "noImplicitAny": true
enabled in my tsconfig.json
, I encountered the
TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}'
error within my code space.
I attempted to disable this rule for a single line using the following code, but unfortunately, it didn't resolve the issue.
const mockElement = () => ({
mount: jest.fn(),
destroy: jest.fn(),
on: jest.fn(),
update: jest.fn(),
});
const mockElements = () => {
const elements = {};
return {
create: jest.fn((type) => {
// encountering error here
// tslint:disable-next-line: no-implicit-any
elements[type] = mockElement();
// also getting error here
// tslint:disable-next-line: no-implicit-any
return elements[type];
}),
getElement: jest.fn((type) => {
// another error occurs below
// tslint:disable-next-line: no-implicit-any
return elements[type] || null;
}),
};
};
Seeking suggestions on how to selectively disable the rule for only a single line? (altering the "noImplicitAny": false
setting in tsconfig.json may solve the problem but is not ideal as it turns off the rule entirely)