-
-
Notifications
You must be signed in to change notification settings - Fork 489
Fixing to work with more recent versions of TypeScript #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Without this change I get this error from TypeScript: ``` Module '"node_modules/css-element-queries/src/ResizeSensor"' has no default export. 24 import ResizeSensor from "css-element-queries/src/ResizeSensor"; ~~~~~~~~~~~~ ```
Thanks! |
I think this change might have broken something (or maybe it's my ignorance?). I can see that it does indeed enable imports along the lines of:
However, after the import, when I go to actually create a instantiate the class like this:
It compiles fine, but I get this error at runtime.
@Pauan - do you see the same problem? Is there some other way of creating a resize sensor that I should try instead of |
@astegmaier You might need to change your import to look like: import * as ResizeSensor from "css-element-queries/src/ResizeSensor"; |
@astegmaier How are you building your project? You have to bundle your project with Webpack or Parcel (it will handle the import logic correctly). |
Thanks for the suggestion @coalman It worked (sort of). When I change my imports to:
... and I look at my line where I'm instantiating the class (
However, if I ignore this error (by changing it to
...then VSCode stops complaining (even after removing the @Pauan I'm building using ts-loader for webpack, and my tsconfig.json file looks like this:
|
I'm not sure about that, but I can tell that I'll write on css-element-queries v2.0 which is written completely in TypeScript at the end of this month, so this issue will definitely go away then. |
@astegmaier You can't use Taking a look at your {
"compilerOptions": {
"module": "esnext",
"esModuleInterop": true,
}
} Basically, by using (As a bonus, this also allows Webpack to tree shake unused functions in your code; Webpack only does tree shaking with ES6 modules). |
Without this change I get this error from TypeScript: