Skip to content

TypeScript error after upgrading postcss-preset-env from 9.3.0 to 9.4.0 #1295

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

Closed
2 of 3 tasks
doberkofler opened this issue Feb 20, 2024 · 6 comments
Closed
2 of 3 tasks

Comments

@doberkofler
Copy link

Reproduction link

No response

Bug description

scripts-ts/bundle.ts:25:30 - error TS7016: Could not find a declaration file for module 'postcss-preset-env'. '/Users/doberkofler/MyDev/ljs_app/trunk/periscope/node_modules/postcss-preset-env/dist/index.cjs' implicitly has an 'any' type.
Try npm i --save-dev @types/postcss-preset-env if it exists or add a new declaration (.d.ts) file containing declare module 'postcss-preset-env';

25 import postcssPresetEnv from 'postcss-preset-env';
~~~~~~~~~~~~~~~~~~~~

Actual Behavior

No response

Expected Behavior

No response

Can you reproduce it with npx @csstools/csstools-cli <plugin-name> minimal-example.css?

N/A

npx Output

No response

Extra config

No response

What plugin are you experiencing this issue on?

PostCSS Preset Env

Plugin version

9.4.0

What OS are you experiencing this on?

macOS

Node Version

20.11.0

Validations

  • Follow our Code of Conduct
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Would you like to open a PR for this bug?

  • I'm willing to open a PR
@romainmenke
Copy link
Member

romainmenke commented Feb 20, 2024

Hi @doberkofler,
Thank you for reaching out about this.

In the past we had an incorrect setup and config which made it so that types were broken for everyone but TypeScript silently ignored all this.
We fixed this by only providing types for es modules.

Since your project is commonjs you will get a warning that there aren't any types, which is correct since we don't provide any for commonjs.
You can add a @ts-expect-error directive or switch your config/project to es modules.

@romainmenke
Copy link
Member

For more context on this change : #1031 (comment)

@doberkofler
Copy link
Author

Thank you!

@johuhype
Copy link

johuhype commented Feb 26, 2024

Hello, i am specifying "type": "module" in my package.json and using
"import postcssPresetEnv from 'postcss-preset-env';" for the import.
But I am still getting the above mentioned error. Is there something else I need to do, to tell it that its ES modules?

@romainmenke
Copy link
Member

Hi @johuhype,

You should check your tsconfig.
You should use nodeNext or node16 for the module option.

https://www.typescriptlang.org/docs/handbook/modules/theory.html#the-module-output-format

There might be other issues or configs that are needed, but that is the most common source of issues that I know of.

@johuhype
Copy link

That was fast. Thanks for the information!

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