-
-
Notifications
You must be signed in to change notification settings - Fork 379
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
Error with Angular 8 - 'allowSyntheticDefaultImports' flag #67
Comments
I just don't see any solution here. Moment is UMD and therefore doesn't work without synthetic default import. I'm open to suggestions though. |
This should help:
Or try setting the
|
Ok, so after testing I can confirm that adding any of |
Can the es6 export/import syntax be used in the moment type module file? @Thomaash
|
Hi @JKostov, no this doesn't work. In the end you are still importing UMD module and that just doesn't work without allowSyntheticDefaultImports. |
Bottom line, is there a way to use it with Angular8 without losing some of the Angular 8 benefits (by updating tsconfig)? |
What benefits do you lose by enabling synthetic default import? I thought Angular is bundled by Webpack which should handle this transparently without causing any issues. But if you really don't want to enable it the problem is only in the types (if you use the ESM bundle the code is already converted into ESM). You can convert /…/node_modules/moment/moment.d.ts into ESM format if you want (since I've never tried to do anything like this there's probably a better way to achieve the same result than editing a file that will be repeatedly overwritten by npm). |
Since this issue seems to occur only for |
I am having this problem and I have tried the solutions above but none worked for me. Any idea of what I am doing wrong. It's an angular 8 project.
Any sugestion can help, thanks. |
Hi @ricardomga, do you really need the legacy build? The peer and standalone builds don't reexport Moment at all. Maybe that would help. Also check that you set |
Hi @Thomaash thanks for the reply. The allowSyntheticDefaultImport didn't work for me. I am using the package ngx-vis in my angular app. I don't need the legacy build, but how can I ignore it? |
In case your using ngx-vis you should create an issue at https://github.com/visjs/ngx-vis/issues/new/choose. I don't have much of an insight into that. |
you have to add allowSyntheticDefaultImports "true" in the |
As of today, is this still an issue? I mean, if I have a // index.d.ts
import moment from "moment"; // Import moment typings
declare module "my-package" {
type Dictionary<K extends string, T> = { [P in K]?: T };
type Moment = moment.Moment; // Reference the Moment type from moment
// ...
} Is the only option I have to add Thank you! |
Hi @tonix-tuft and anybody else still tracking this, we're removing Moment from everything except Vis Timeline (where it's actually used, there were deprecation warning for quite a long time) right now, so this won't be necessary anymore (also, since Moment wasn't actually used at all, less bloat in the bundle). |
Its works. |
This helped us: Create some file moment.constant.ts and put this inside:
And then you can use through your app.
|
I just updated from
vis
tovis-network
(I only needvis-network
since I only use graph in my app) while updating to Angular 8. When I try and compile the app, I get an error:in ../node_modules/vis-network/dist/types/index.d.ts:18:25.
Complete error:
vis-network
version: 5.2.1Browser: Chrome 76.0.3809.100, Windows 10
My tsconfig.json:
My package.json (omitted Angular stuff):
The text was updated successfully, but these errors were encountered: