From 46409d94cf75b3e862ae0b08a23f69ae49b3e597 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 31 Jan 2020 12:03:38 -0500 Subject: [PATCH 1/2] Add TypeScript Definitions for Sass --- lint-staged.config.js | 2 +- package.json | 4 ++-- packages/next/types/global.d.ts | 10 ++++++++++ .../typescript/components/hello.module.sass | 2 ++ .../typescript/components/hello.module.scss | 3 +++ test/integration/typescript/components/hello.ts | 4 ++++ 6 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 test/integration/typescript/components/hello.module.sass create mode 100644 test/integration/typescript/components/hello.module.scss diff --git a/lint-staged.config.js b/lint-staged.config.js index 5bea863be5cf505..22ca8c95bd1d201 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -14,7 +14,7 @@ module.exports = { `git add ${escapedFileNames}`, ] }, - '**/*.{json,md,mdx,css,html,yml,yaml,scss,sass}': filenames => { + '**/*.{json,md,mdx,css,html,yml,yaml,scss}': filenames => { const escapedFileNames = filenames .map(filename => `"${isWin ? filename : escape([filename])}"`) .join(' ') diff --git a/package.json b/package.json index c1866b0dc694cd8..18a274008231893 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "lint-eslint": "eslint . --ext js,jsx,ts,tsx --max-warnings=0", "lint": "run-p lint-typescript prettier-check lint-eslint", "lint-fix": "yarn prettier-fix && eslint . --ext js,jsx,ts,tsx --fix --max-warnings=0", - "prettier-check": "prettier --check \"**/*.{js,jsx,json,ts,tsx,md,mdx,css,html,yml,yaml,scss,sass}\"", - "prettier-fix": "prettier --write \"**/*.{js,jsx,json,ts,tsx,md,mdx,css,html,yml,yaml,scss,sass}\"", + "prettier-check": "prettier --check \"**/*.{js,jsx,json,ts,tsx,md,mdx,css,html,yml,yaml,scss}\"", + "prettier-fix": "prettier --write \"**/*.{js,jsx,json,ts,tsx,md,mdx,css,html,yml,yaml,scss}\"", "types": "lerna run types --stream", "typescript": "lerna run typescript", "prepublish": "lerna run prepublish", diff --git a/packages/next/types/global.d.ts b/packages/next/types/global.d.ts index 533398d22c95136..706b8a1dbd184d9 100644 --- a/packages/next/types/global.d.ts +++ b/packages/next/types/global.d.ts @@ -15,3 +15,13 @@ declare module '*.module.css' { const classes: { readonly [key: string]: string } export default classes } + +declare module '*.module.sass' { + const classes: { readonly [key: string]: string } + export default classes +} + +declare module '*.module.scss' { + const classes: { readonly [key: string]: string } + export default classes +} diff --git a/test/integration/typescript/components/hello.module.sass b/test/integration/typescript/components/hello.module.sass new file mode 100644 index 000000000000000..73ae7d767261ebb --- /dev/null +++ b/test/integration/typescript/components/hello.module.sass @@ -0,0 +1,2 @@ +.hello + content: 'hello' diff --git a/test/integration/typescript/components/hello.module.scss b/test/integration/typescript/components/hello.module.scss new file mode 100644 index 000000000000000..677d77ed34a61d7 --- /dev/null +++ b/test/integration/typescript/components/hello.module.scss @@ -0,0 +1,3 @@ +.hello { + content: 'hello'; +} diff --git a/test/integration/typescript/components/hello.ts b/test/integration/typescript/components/hello.ts index e4c1ace030fccc7..9b7c088a580a8ff 100644 --- a/test/integration/typescript/components/hello.ts +++ b/test/integration/typescript/components/hello.ts @@ -1,6 +1,10 @@ import helloStyles from './hello.module.css' +import helloStyles2 from './hello.module.scss' +import helloStyles3 from './hello.module.sass' export function hello(): string { console.log(helloStyles.hello) + console.log(helloStyles2.hello) + console.log(helloStyles3.hello) return 'Hello' } From ba5e352f9feea2cbf265a6ff176cffc24b9078ab Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sun, 2 Feb 2020 23:51:03 -0500 Subject: [PATCH 2/2] fix test --- test/integration/typescript/next.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/typescript/next.config.js b/test/integration/typescript/next.config.js index d085452639784fb..5adba078e31d095 100644 --- a/test/integration/typescript/next.config.js +++ b/test/integration/typescript/next.config.js @@ -3,5 +3,5 @@ module.exports = { // Make sure entries are not getting disposed. maxInactiveAge: 1000 * 60 * 60, }, - experimental: { css: true }, + experimental: { scss: true }, }