Skip to content

fix: Enable the CSS modules TypeScript plugin - #14735

Draft
amoore108 wants to merge 2 commits into
latestfrom
amoore108-fix-css-modules-plugin
Draft

amoore108 wants to merge 2 commits into
latestfrom
amoore108-fix-css-modules-plugin

Conversation

@amoore108

@amoore108 amoore108 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Resolves JIRA:

Summary

typescript-plugin-css-modules was installed but never loaded: its entry sat outside compilerOptions in tsconfig.json, and the Next.js tsconfig's own plugins list replaced it anyway. Once loaded, it also couldn't compile stylesheets that use @use '@scss/themeTokens', because @scss only existed as a webpack alias. This PR enables the plugin in both projects, so editors get typed class names (autocomplete and typo errors) for SCSS module imports. It's editor-only: tsc and the build ignore TypeScript plugins.

Before and after

Given a typo in a class name in AccountActionButtons:

import styles from './index.module.scss';

<span className={styles.accountIconn} />

Before: hovering styles shows a loose index signature, so styles. offers no suggestions and the typo goes unreported. At runtime className is undefined and the icon loses its styles.

const styles: {
    readonly [key: string]: string;
}

After: hovering styles shows the stylesheet's real classes, styles. autocompletes them, and the typo is flagged in the editor.

let styles: {
    accountIcon: string;
    separatorText: string;
    separatorTextOnLightBackground: string;
    callToActionLink: string;
    signInLink: string;
    registerLink: string;
    registerLinkOnLightBackground: string;
}
- Property 'accountIconn' does not exist on type '{ accountIcon: string; ... }'.
- Did you mean 'accountIcon'?

Code changes

  • Move the plugin into compilerOptions in the root tsconfig and add it alongside next in ws-nextjs-app/tsconfig.json.
  • Add an @scss/* path mapping to both tsconfigs, matching the webpack alias, so the plugin can resolve theme token imports.
  • Remove the unused #cypress/* alias, which pointed at a directory holding only untracked test output.

Testing

  1. In VS Code, run "TypeScript: Select TypeScript Version" and choose "Use Workspace Version".
  2. Open a component that imports a .module.scss file (e.g. src/app/components/Account/AccountActionButtons/index.tsx) and type styles.: the stylesheet's class names should be suggested.
  3. Change one to a name that doesn't exist and confirm it's flagged as an error.
  4. Repeat in a ws-nextjs-app/pages component (e.g. LiveElectionBanner).

Useful Links

The plugins entry sat outside compilerOptions in tsconfig.json, so
TypeScript never loaded it, and ws-nextjs-app's own plugins list replaced
it anyway. Move it into compilerOptions in both configs.

The plugin resolves Sass imports through tsconfig paths, so map @scss to
the directory the webpack alias points at. Editors now get typed class
names for SCSS module imports.
Nothing imports from #cypress, and the root cypress directory it points
at only holds untracked test output.
@amoore108 amoore108 self-assigned this Nov 29, 2026

This branch has not been deployed

No deployments
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.

1 participant