Skip to content

Instantly share code, notes, and snippets.

@nirtamir2
Last active October 25, 2021 21:09
Show Gist options
  • Save nirtamir2/07b480595925f558c3fee4895a07f6c7 to your computer and use it in GitHub Desktop.
Save nirtamir2/07b480595925f558c3fee4895a07f6c7 to your computer and use it in GitHub Desktop.
yarn add -D typescript-plugin-css-modules

This allow using CSS modules with the noPropertyAccessFromIndexSignature option. If I won't add this, and won't generate TypeScript declerations from the css modules file - the TS will error about missing styles.someClassName because it's been accessed but not declared.

TODO

  • Remove types
  • Update jsx to the new react 17. BTW - it has seperated transformations for dev and prod builds.
  • incremental? for faster builds

TO-TRY

{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"strict": true,
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUncheckedIndexedAccess": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitOverride": true,
"exactOptionalPropertyTypes": true,
"useUnknownInCatchVariables": true,
"preserveValueImports": true, // TS 4.5+
"plugins": [{ "name": "typescript-plugin-css-modules" }]
},
"include": ["next-env.d.ts", "global.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment