diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9ba102c..f1cf6ada 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,10 @@ jobs: run: npm install - name: Check Types run: npm run test:types + - name: Check Types (TypeScript 5.x) + run: npm run test:types:5.x + - name: Check Types (TypeScript 5.3) + run: npm run test:types:5.3 are_the_types_wrong: name: Are the types wrong? runs-on: ubuntu-latest diff --git a/package.json b/package.json index 6e091e3a..abd51aa2 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,10 @@ "test": "mocha \"tests/**/*.test.js\"", "test:coverage": "c8 npm test", "test:jsr": "npx -y jsr@latest publish --dry-run", - "test:types": "npm run build && tsc -p tests/types/tsconfig.json" + "test:types": "npm run build && tsc -p tests/types/tsconfig.json", + "test:types:5.x": "npx -p typescript@5.x -y -- tsc -p tests/types/tsconfig.json", + "test:types:5.3": "npx -p typescript@5.3 -y -- tsc -p tests/types/tsconfig.json", + "test:types:all": "npm run test:types && npm run test:types:5.x && npm run test:types:5.3" }, "keywords": [ "eslint", @@ -89,7 +92,7 @@ "mocha": "^11.0.0", "prettier": "3.8.2", "tailwind-csstree": "^0.3.0", - "typescript": "^5.9.3", + "typescript": "^6.0.3", "web-features": "^3.23.1", "yorkie": "^2.0.0" }, diff --git a/src/index.js b/src/index.js index 23dac7c5..5624a513 100644 --- a/src/index.js +++ b/src/index.js @@ -34,10 +34,7 @@ const plugin = { }, }; -// eslint-disable-next-line no-lone-blocks -- The block syntax { ... } ensures that TypeScript does not get confused about the type of `plugin`. -{ - plugin.configs.recommended.plugins.css = plugin; -} +Object.assign(plugin.configs.recommended.plugins, { css: plugin }); export default plugin; export { CSSSourceCode }; diff --git a/src/util.js b/src/util.js index d87ba59d..df8b8b5f 100644 --- a/src/util.js +++ b/src/util.js @@ -17,18 +17,18 @@ /** * Determines if an error is a syntax match error. - * @param {Object} error The error object to check. + * @param {SyntaxMatchError | SyntaxReferenceError | Error} error The error object to check. * @returns {error is SyntaxMatchError} True if the error is a syntax match error, false if not. */ export function isSyntaxMatchError(error) { - return typeof error.syntax === "string"; + return "syntax" in error && typeof error.syntax === "string"; } /** * Determines if an error is a syntax reference error. - * @param {Object} error The error object to check. + * @param {SyntaxMatchError | SyntaxReferenceError | Error} error The error object to check. * @returns {error is SyntaxReferenceError} True if the error is a syntax reference error, false if not. */ export function isSyntaxReferenceError(error) { - return typeof error.reference === "string"; + return "reference" in error && typeof error.reference === "string"; } diff --git a/tests/types/tsconfig.json b/tests/types/tsconfig.json index 4d6f9c30..f669877d 100644 --- a/tests/types/tsconfig.json +++ b/tests/types/tsconfig.json @@ -1,9 +1,14 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "allowJs": false, + "checkJs": false, "noEmit": true, "rootDir": "../..", "strict": true, + "strictNullChecks": true, + "useUnknownInCatchVariables": true, + "noImplicitAny": true, "exactOptionalPropertyTypes": true }, "files": [], diff --git a/tsconfig.json b/tsconfig.json index 25070aa8..bbb7a9bf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,10 @@ "lib": ["ES2022"], "moduleResolution": "NodeNext", "module": "NodeNext", + "rootDir": "./src", + "strictNullChecks": false, + "useUnknownInCatchVariables": false, + "noImplicitAny": false, "types": [] } }