resize-observer-polyfill icon indicating copy to clipboard operation
resize-observer-polyfill copied to clipboard

Cannot read property 'flags' of undefined when imported in a typescript file

Open marcellomontemagno opened this issue 4 years ago • 0 comments

Hi,

I will try to open the same issue on the typescript repo asap, I'm trying here first because my typescript configuration has been used for quite some time and this is the only dependency giving me this problem.

Adding the following line in a .tsx file

import ResizeObserver from 'resize-observer-polyfill';

causes the following error in [email protected]

ERROR in INTERNAL ERROR: Cannot read property 'flags' of undefined
stack trace:
TypeError: Cannot read property 'flags' of undefined
    at getFlowTypeOfReference (/Users/marcellomontemango/Cello/monorepo/fe/ui-kit/node_modules/typescript/lib/typescript.js:51978:80)
    at tryGetThisTypeAt (/Users/marcellomontemango/Cello/monorepo/fe/ui-kit/node_modules/typescript/lib/typescript.js:53380:32)
    at checkThisExpression (/Users/marcellomontemango/Cello/monorepo/fe/ui-kit/node_modules/typescript/lib/typescript.js:53348:24)
    at checkExpressionWorker (/Users/marcellomontemango/Cello/monorepo/fe/ui-kit/node_modules/typescript/lib/typescript.js:60075:28)
    at checkExpression (/Users/marcellomontemango/Cello/monorepo/fe/ui-kit/node_modules/typescript/lib/typescript.js:60023:38)
    at checkExpressionWithContextualType (/Users/marcellomontemango/Cello/monorepo/fe/ui-kit/node_modules/typescript/lib/typescript.js:59672:28)
    at getSignatureApplicabilityError (/Users/marcellomontemango/Cello/monorepo/fe/ui-kit/node_modules/typescript/lib/typescript.js:56491:35)
    at chooseOverload (/Users/marcellomontemango/Cello/monorepo/fe/ui-kit/node_modules/typescript/lib/typescript.js:56939:25)
    at resolveCall (/Users/marcellomontemango/Cello/monorepo/fe/ui-kit/node_modules/typescript/lib/typescript.js:56838:26)
    at resolveCallExpression (/Users/marcellomontemango/Cello/monorepo/fe/ui-kit/node_modules/typescript/lib/typescript.js:57215:20)

I wish there was more info in the stack trace, I know the cause of the issue is linked with the import because is the only line I added since the problem appeared, plus, if I remove it everything behaves normally.

Here my tsconfig

{
  "compilerOptions": {
    "jsx": "react",
    "allowJs": true,
    "esModuleInterop": true,
    "strict": true,
    "outDir": "./tsDist/"
  }
}

Any idea about what could be possibly causing this?

The version of resize-observer-polyfill I'm trying to use is "1.5.1".

Thank you for your time.

marcellomontemagno avatar May 05 '20 16:05 marcellomontemagno