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 Types Incorrect #722
Comments
Yeah, definitely I did not ensure the published module would work, sorry for the inconvenience! As a temporary workaround, you can import the module from I'll be releasing a patched version asap, just I need to figure out what happened, thank you. 🙏🏽 |
@pmcelhaney I've pushed a fix for this on the develop branch, tests are passing and I ran a few integrations too both with cjs/esm files, can you help me to validate if types are still correct? Thank you! |
@pmcelhaney I had to force a push for the same branch, now also the IIFE/UMD tests are working! |
Looks good! import { default as jsf, JSONSchemaFaker } from "json-schema-faker";
// should be deprecated; it is
jsf();
// should not be callable; it's not
JSONSchemaFaker();
// should have autocomplete and type check; it does
JSONSchemaFaker.VERSION;
JSONSchemaFaker.generate({});
// ... @beardedtim thanks for the report and easy to follow test case! |
Wait, after that force push I don't think it's right |
Fine, I am publishing it right now, carefully to avoid mistakes again! 🍻 |
@beardedtim finally it's published and ready for your usage, so much thanks for your immediate feedback! |
Thank you so much for the quick turn around and fix @pateketrueke . Greatly appreciate the work and the repo! |
Looks like something reverted maybe? I'm experiencing this same issue at the moment, when upgrading to |
@yoeran can you describe your issue? thank you! |
After upgrading
to
Which shows no errors in VSCode, but in testing and pipeline I get the following error: TypeError: Cannot read properties of undefined (reading 'JSONSchemaFaker')
46 | });
47 |
> 48 | JSONSchemaFaker.format('dateRange', () =>
| ^ Notice, that it doesn't say "cannot read |
@yoeran I see, the thing is a two-steps check:
Can you tell us if (1) is working for you, and then if (2) doe not, what are you using as your pipeline? |
@pateketrueke I understand.
|
@yoeran ok, I don't know how that tooling works but it would be using a bundler under the hood, bundlers have settings for resolving modules. Probably is not resolving correctly the module version (which is preferred) of this package. Please make sure it understands the "exports" from the package.json definition. |
Issue
When I install
json-schema-faker
and try to use it in my code, the types seem to be different than the values exported. Specifically, the types say there is an object calledJSONSchemaFaker
that can be imported and has all of the available methods. However, when trying to use the values the JS runtime says it is undefined.Repro Steps
Below are the CLI commands ran before trying to execute the code
You can create two files and try to run them both to see the output
This prints
undefined
when I would expect somethingThis prints something when I would expect nothing
Screenshots
You can see that the Typescript types show that the import that prints undefined should have methods attached.
while importing the thing that prints something shows that the only thing that should be on the object is the exported
JSONSchemaFaker
Settings
Here are the node and npm versions currently being used
The text was updated successfully, but these errors were encountered: