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

πŸ›πŸ”§ Add "types" to "exports" #2803

Merged
merged 1 commit into from
Mar 17, 2022
Merged

Conversation

makeeno
Copy link
Contributor

@makeeno makeeno commented Mar 17, 2022

When trying to use fast-check with TypeScript where moduleResolution is set to Node12 or NodeNext we get the following error:

Could not find a declaration file for module 'fast-check'. '.../node_modules/fast-check/lib/esm/fast-check.js' implicitly has an 'any' type.
Try npm i --save-dev @types/fast-check if it exists or add a new declaration (.d.ts) file containing declare module 'fast-check';ts(7016)

This change fixes the issue.

I think this might be related: microsoft/TypeScript#46334

Category:

  • ✨ Introduce new features
  • πŸ“ Add or update documentation
  • βœ… Add or update tests
  • πŸ› Fix a bug
  • [] 🏷️ Add or update types
  • ⚑️ Improve performance
  • Other(s): ...

Potential impacts:

  • Generated values
  • Shrink values
  • Performance
  • Typings
  • Other(s): ...

When trying to use `fast-check` with TypeScript where  `moduleResolution` is set to `Node12` or `NodeNext` we get the following error:

> Could not find a declaration file for module 'fast-check'. '/home/makeen/q2web/Dev/openapi-codegen/node_modules/fast-check/lib/esm/fast-check.js' implicitly has an 'any' type.

> Try `npm i --save-dev @types/fast-check` if it exists or add a new declaration (.d.ts) file containing `declare module 'fast-check';`ts(7016)

This change fixes the issue.

I think this might be related: microsoft/TypeScript#46334
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 7010277:

Sandbox Source
Vanilla Configuration
fast-check-examples Configuration

@codecov
Copy link

codecov bot commented Mar 17, 2022

Codecov Report

Merging #2803 (7010277) into main (675e539) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #2803   +/-   ##
=======================================
  Coverage   95.08%   95.08%           
=======================================
  Files         214      214           
  Lines        5023     5023           
  Branches     1000     1000           
=======================================
  Hits         4776     4776           
  Misses        243      243           
  Partials        4        4           
Flag Coverage Ξ”
unit-tests 95.08% <ΓΈ> (ΓΈ)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update 675e539...7010277. Read the comment docs.

@dubzzz
Copy link
Owner

dubzzz commented Mar 17, 2022

Thank you so much for the fix @Osman-Sodefa! I'll probably need to cover it as I did for other esm-related stuff in https://github.com/dubzzz/fast-check/tree/main/test/esm.

Is there a specific version you need the fix in? I mean which version do you need to include the fix?

@dubzzz dubzzz merged commit e287bd2 into dubzzz:main Mar 17, 2022
@makeeno
Copy link
Contributor Author

makeeno commented Mar 17, 2022

Is there a specific version you need the fix in? I mean which version do you need to include the fix?

No specific version. I'm currently using the latest of fast-check. Thank you.

@dubzzz
Copy link
Owner

dubzzz commented Mar 17, 2022

2.23.1 is on its way πŸš€

You can track the deployment on https://github.com/dubzzz/fast-check/actions/runs/2000117810

@makeeno
Copy link
Contributor Author

makeeno commented Mar 17, 2022

I'll probably need to cover it as I did for other esm-related stuff in https://github.com/dubzzz/fast-check/tree/main/test/esm.

Though I think it's more TS related than ESM related.

@dubzzz
Copy link
Owner

dubzzz commented Mar 17, 2022

I mean I put all the environment related issues into this directory. It's probably not well labeled πŸ˜‚

@dubzzz
Copy link
Owner

dubzzz commented Mar 17, 2022

It will probably not work yet! I'll need to do the exact same fix for pure-rand πŸ€”

See the error I got when trying to add a dedicated test:

Error: node_modules/fast-check/lib/types/random/generator/PureRandom.d.ts(1,60): error TS7016: Could not find a declaration file for module 'pure-rand'. '/home/runner/work/fast-check/fast-check/test/type/node_modules/fast-check/node_modules/pure-rand/lib/pure-rand.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/pure-rand` if it exists or add a new declaration (.d.ts) file containing `declare module 'pure-rand';`
Error: Process completed with exit code 2.

dubzzz added a commit to dubzzz/pure-rand that referenced this pull request Mar 17, 2022
@makeeno
Copy link
Contributor Author

makeeno commented Mar 17, 2022

I have enabled skipLibCheck in my tsconfig.json; that's why I didn't get that error.

@dubzzz
Copy link
Owner

dubzzz commented Mar 17, 2022

I'll update it on my side so that the whole fast-check + pure-rand gets fixed! Thanks a lot for the report and the fix!

dubzzz added a commit to dubzzz/pure-rand that referenced this pull request Mar 17, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants