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

Bug: Types are not found wth nodenext module resolution #168

Closed
bramvbilsen opened this issue Feb 24, 2023 · 9 comments
Closed

Bug: Types are not found wth nodenext module resolution #168

bramvbilsen opened this issue Feb 24, 2023 · 9 comments

Comments

@bramvbilsen
Copy link

bramvbilsen commented Feb 24, 2023

The types for croner are not being found in my Typescript application. I installed the package as follows:

npm i croner

The specific errors:

'.../node_modules/croner/dist/croner.min.cjs' implicitly has an 'any' type.

I made sure to include all node_modules paths for types in my tsconfig.json file:

// tsconfig.json
{
    ...
    "moduleResolution": "nodenext",
    "typeRoots": [
        "./src/types/*",
        "./node_modules/*",
        "./node_modules/croner/types/*" // Added this for completeness sake
    ],
    ...
}

The issue appears to be with moduleResolution being nodenext. The import does not show any errors if I switch it to use node. But, unfortunately, this breaks compatibility for other packages and is not an option.

Any ideas?

@bramvbilsen bramvbilsen changed the title Types are not found Types are not found wth nodenext module resolution Feb 24, 2023
@Hexagon
Copy link
Owner

Hexagon commented Feb 24, 2023

Hmm, interesting! Will have a look at that later, which version of typescript do you use?

@bramvbilsen
Copy link
Author

Hmm, interesting! Will have a look at that later, which version of typescript do you use?

Wow, thanks for the quick reply!
Using Typescript version ^4.8.4

@Hexagon
Copy link
Owner

Hexagon commented Feb 24, 2023

Found some pointers here, microsoft/TypeScript#50466

Will fix this asap 👍

@Hexagon
Copy link
Owner

Hexagon commented Feb 24, 2023

@bramvbilsen Trying to set up a test environment to reproduce this behavior. Do you have "type": "module" or not in your package.json? How does your import statement look like?

@bramvbilsen
Copy link
Author

@Hexagon No the package.json is just the default "type": "commonjs"

@Hexagon
Copy link
Owner

Hexagon commented Feb 24, 2023

Oh, i see. Seems like croner need to export separate type definitions for commonjs (.d.cts)... Interesting stuff indeed!

@Hexagon Hexagon added the bug label Feb 26, 2023
@Hexagon Hexagon added this to the 6.0 milestone Feb 26, 2023
@Hexagon
Copy link
Owner

Hexagon commented Feb 26, 2023

@bramvbilsen Proposed fix released in 6.0.0-dev.1. Had to bump major version as it changes file structure of distributed files.

Please test by

npm install croner@dev

@Hexagon Hexagon changed the title Types are not found wth nodenext module resolution Bug: Types are not found wth nodenext module resolution Feb 26, 2023
@Hexagon
Copy link
Owner

Hexagon commented Feb 28, 2023

Released in 6.0.0. Please reopen if you still have problems with this.

@Hexagon Hexagon closed this as completed Feb 28, 2023
@bramvbilsen
Copy link
Author

My apologies for the late reply. Version 6.0.0 works perfectly, thank you!

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

No branches or pull requests

2 participants