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

[types] Type '{ sassOptions: {}; }' is not assignable to type 'Options'. #9085

Closed
marcopixel opened this issue Mar 31, 2021 · 0 comments · Fixed by #9086
Closed

[types] Type '{ sassOptions: {}; }' is not assignable to type 'Options'. #9085

marcopixel opened this issue Mar 31, 2021 · 0 comments · Fixed by #9086

Comments

@marcopixel
Copy link

marcopixel commented Mar 31, 2021

While upgrading to the latest version of Nuxt, i've encountered a typings problem while customizing the loader options for SASS/SCSS.

TS2322: Type '{ sassOptions: { includePaths: string[]; }; }' is not assignable to type 'Options'.
  Object literal may only specify known properties, and 'sassOptions' does not exist in type 'Options'.
     8 |     loaders: {
     9 |       scss: {
  > 10 |         sassOptions: {
       |         ^^^^^^^^^^^^^^
  > 11 |           // include assets path as absolute path for scss imports
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 12 |           includePaths: [path.resolve(__dirname, "./src/assets")],
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  > 13 |         },
       | ^^^^^^^^^^
    14 |       },
    15 |     },
    16 |   },

SassOptions is referencing @types/sass directly and since build.scss.sassOptions is a property added by sass-loader, it doesn't exist in the interface and thus gives an error.

https://github.com/nuxt/nuxt.js/blob/558227f628cc5453be4cec16bf15dcb397baacae/packages/types/config/build.d.ts#L11
https://github.com/nuxt/nuxt.js/blob/558227f628cc5453be4cec16bf15dcb397baacae/packages/types/config/build.d.ts#L69-L70

There seems to be a change between @nuxt/types@2.14.12 and @nuxt/types@2.15.0 which caused the issue to plop up for me, since downgrading to 2.14.12 removed the error message for me.

It should be an easy fix though, since there are typings for sass-loader which has the correct typings for the loader and the required modules included.

Versions

  • nuxt: v2.15.3
  • node: v14.15.4

Reproduction

https://github.com/marcopixel/nuxt-sassoptions-repro

Steps to reproduce

  1. Clone repo
  2. npm install
  3. npm run dev

What is Expected?

The example should run without any errors caused by TS and should not show any errors in VSCode.

What is actually happening?

The example builds & runs fine, but shows the error while issue checking in the console & inside VSCode.

danielroe added a commit that referenced this issue Mar 31, 2021
* pins dependency in case of breaking change (-> webpack 5) in future

closes #9085
@pi0 pi0 closed this as completed in #9086 Mar 31, 2021
@pi0 pi0 mentioned this issue Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants