Skip to content

How to fix Astro 'property typeof import module.scss' error

Published:

This quick guide is for fixing the Property 'section' does not exist on type 'typeof import(\"*.module.scss\")' error on Astro. Let's assume this is your .astro file on your Astro component:

// Styles
import * as CSS from './ListOfArticles.module.scss';
---
<section class={CSS.section}>
<h1 class={CSS.heading}>Hello world</h1>
</section>

Everything looks good, but it gives the following error:

Property 'section' does not exist on type 'typeof import("*.module.scss")'

Well, the fix is a quick one! You can replace the * as CSS with simply CSS and it will work!

So here's the code that will not give the error / warning:

// Styles
import CSS from './ListOfArticles.module.scss';
---
<section class={CSS.section}>
<h1 class={CSS.heading}>Hello world</h1>
</section>