I need to override an experiment property in Chrome and encounter this error.
if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual'; // type error
}
I found the answers at: http://stackoverflow.com/questions/18083389/ignore-typescript-errors-property-does-not-exist-on-value-of-type. But not sure which one is the right way to go.
(history as any).scrollRestoration = 'manual';
vs
history['scrollRestoration'] = 'manual';
It seems that TypeScript's docs / deep dive book doesn't mention about the squared brackets syntax.
I'd go with the first one. The second one works, but only if you compile without -noImplicitAny
.
Most helpful comment
I'd go with the first one. The second one works, but only if you compile without
-noImplicitAny
.