From c482d9aba80f4319bff0253bb84550682d00c94f Mon Sep 17 00:00:00 2001 From: roydukkey Date: Wed, 6 Oct 2021 11:52:11 -0400 Subject: [PATCH] Add TypeScript support for Sass/SCSS modules --- README.md | 13 +++++++++++-- docusaurus-plugin-sass.d.ts | 19 +++++++++++++++++++ package.json | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 docusaurus-plugin-sass.d.ts diff --git a/README.md b/README.md index 3603921..50bb08c 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,16 @@ function MyComponent() { } ``` +### TypeScript support +To enable TypeScript support for Sass/SCSS modules, the TypeScript configuration should be updated to add the `docusaurus-plugin-sass` type definitions. This can be done in the `tsconfig.json` file: - - +```diff +{ + "extends": "@tsconfig/docusaurus/tsconfig.json", + "compilerOptions": { + ... ++ "types": ["docusaurus-plugin-sass"] + } +} +``` \ No newline at end of file diff --git a/docusaurus-plugin-sass.d.ts b/docusaurus-plugin-sass.d.ts new file mode 100644 index 0000000..4b64cd8 --- /dev/null +++ b/docusaurus-plugin-sass.d.ts @@ -0,0 +1,19 @@ +declare module '*.module.scss' { + const classes: { readonly [key: string]: string }; + export default classes; +} + +declare module '*.module.sass' { + const classes: { readonly [key: string]: string }; + export default classes; +} + +declare module '*.scss' { + const src: string; + export default src; +} + +declare module '*.sass' { + const src: string; + export default src; +} \ No newline at end of file diff --git a/package.json b/package.json index 88f3764..3ac42c0 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.2.1", "description": "Docusaurus plugin to provide support for SASS/SCSS", "main": "docusaurus-plugin-sass.js", + "types": "docusaurus-plugin-sass.d.ts", "dependencies": { "sass-loader": "^10.1.1" },