There is this library called 'resize-observer-polyfill' which declares that it has a default export:
declare var ResizeObserver: {
prototype: ResizeObserver;
new(callback: ResizeObserverCallback): ResizeObserver;
}
export default ResizeObserver;
But I cannot import this library because TS complains.
import ResizeObserver from 'resize-observer-polyfill'
// If I do this instead, TS is happy but ResizeObserver is undefined !!
import * as ResizeObserver from 'resize-observer-polyfill'
TS config extract:
, "compilerOptions":
{ "jsx": "react"
, "module": "commonjs"
, "noImplicitAny": true
, "outDir": "output/dist"
, "reactNamespace": "JSX"
, "sourceMap": true
, "strictNullChecks": true
, "target": "es6"
}
Using allowSyntheticDefaultImports makes types and runtime happy but then many imports fail in jest (using ts-jest) unless I set skipBabel to true.
Using the skipBabel option, this import fails in tests with an undefined value, I have to use the import * as ResizeObserver syntax in tests.
What is the proper way to do this ? Why is it such a mess anyway ?
import {ResizeObserver} from 'resize-observer-polyfill'