Skip to content
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

TypeScript error TS2351 with validator.ts #1228

Closed
clayroach opened this issue Jan 15, 2019 · 9 comments
Closed

TypeScript error TS2351 with validator.ts #1228

clayroach opened this issue Jan 15, 2019 · 9 comments
Assignees
Milestone

Comments

@clayroach
Copy link
Contributor

jsonforms version 2.1.0
typescript 3.2.2
webpack 4.28.2
ERROR in [blah]/uiproject/node_modules/@jsonforms/core/src/util/validator.ts
ERROR in [blah]/uiproject/node_modules/@jsonforms/core/src/util/validator.ts(5,15):
TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.

To Reproduce
Compile project with webpack.

Expected behavior
No error

Proposed solution
Change import from:
import * as AJV from 'ajv';

To:
import Ajv from 'ajv';

@edgarmueller
Copy link
Contributor

Thanks for the report, I guess we should avoid wildcard imports altogether. We'll try to address this issue in the upcoming sprint.

@edgarmueller edgarmueller added this to the 2.2.0 milestone Jan 15, 2019
@clayroach
Copy link
Contributor Author

Weirdly... the issue went away once I blew away the package-lock.json so some other library was causing this issue to manifest itself.

@edgarmueller edgarmueller modified the milestones: 2.2.0, 2.3.0 Jan 23, 2019
@clayroach
Copy link
Contributor Author

@edgarmueller - Can you please consider getting this one fixed in the 2.2.0 version? It came back for no good reason whatsoever, and now it is breaking all our builds unless we all individually patching this file.

@edgarmueller edgarmueller modified the milestones: 2.3.0, 2.2.0 Jan 24, 2019
@edgarmueller
Copy link
Contributor

Alright we'll try to have a look.

@clayroach
Copy link
Contributor Author

Thanks @edgarmueller. Note that the following is what has resolved the issue, (capital AJV, not Ajv)

import AJV from 'ajv';

@edgarmueller
Copy link
Contributor

edgarmueller commented Jan 24, 2019

@clayroach Could the issue be related to different compiler settings, i.e. do you have allowSyntheticDefaultImports and/or esModuleInpterop set? We opened #1242 and updated our tsconfig (https://github.com/eclipsesource/jsonforms/pull/1242/files#diff-bd08939a7f74f60ccd2a7d92682b57be), which hopefully should then fix your issue.

@edgarmueller
Copy link
Contributor

We have released a pre-release 2.1.1-alpha.3, which contains #1242, i.e. the esModuleInterop flag is now set. Could you give it a try and let us know whether this solves your issue?

@clayroach
Copy link
Contributor Author

Yes, will do!

@clayroach
Copy link
Contributor Author

@edgarmueller Looks that resolved it! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants