Summary
Not passing options, or passing options without minimum requirements, is an error (type error at runtime)
Expected vs. Actual Behavior
Expected:
Calling new MutationObserver(fn).observe(el) without a second options argument should show a type error because options are required.
Actual:
There is no type error. We discover the error at runtime.
Playground Link
https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAtiGBeGYCmB3GBZArlAQygEtwB5AIwjQCcA3WgCkYEpkA+GAbwF8WAofgHohMAAJQIAWjQAPAA5pgUGTRogaMKAAs0MaqDA0AJjAI0A5rjhowsYhBg00AR1zFnpgsFAniYCy1ECEVgADoYADkQWHkCCAh-QOJYHXUMRwIYABUAT0UAUTUNfgQwkCpaBkZjEGBrWygwihBjXJYgA
Browser Support
Have Tried The Latest Releases
Additional Context
From MDN docs:
An object providing options that describe which DOM mutations should be reported to mutationObserver's callback. At a minimum, one of childList, attributes, and/or characterData must be true when you call observe(). Otherwise, a TypeError exception will be thrown.
Summary
Not passing options, or passing options without minimum requirements, is an error (type error at runtime)
Expected vs. Actual Behavior
Expected:
Calling
new MutationObserver(fn).observe(el)without a second options argument should show a type error because options are required.Actual:
There is no type error. We discover the error at runtime.
Playground Link
https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAtiGBeGYCmB3GBZArlAQygEtwB5AIwjQCcA3WgCkYEpkA+GAbwF8WAofgHohMAAJQIAWjQAPAA5pgUGTRogaMKAAs0MaqDA0AJjAI0A5rjhowsYhBg00AR1zFnpgsFAniYCy1ECEVgADoYADkQWHkCCAh-QOJYHXUMRwIYABUAT0UAUTUNfgQwkCpaBkZjEGBrWygwihBjXJYgA
Browser Support
Have Tried The Latest Releases
@types/web.Additional Context
From MDN docs: