From 1da2139684f142603a985e3174e473549c5b85bd Mon Sep 17 00:00:00 2001 From: Akihiro Okuno Date: Tue, 6 Jul 2021 18:33:46 +0900 Subject: [PATCH] Avoid `invalidConfigPath` for function values Pass `validateConfigPath` if a type of value equals to `function`. The purpose of this commit is to avoid unwanted warnings when we define theme values as functions in tailwind.config.js, which, for example, are required to define theme colors with opacity enabled. https://github.com/tailwindlabs/tailwindcss/discussions/2206#discussioncomment-60081 --- .../src/diagnostics/getInvalidConfigPathDiagnostics.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/tailwindcss-language-service/src/diagnostics/getInvalidConfigPathDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getInvalidConfigPathDiagnostics.ts index 7f8bb84..9a53db3 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/getInvalidConfigPathDiagnostics.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/getInvalidConfigPathDiagnostics.ts @@ -90,10 +90,11 @@ function validateConfigPath( typeof value === 'number' || value instanceof String || value instanceof Number || - Array.isArray(value) + Array.isArray(value) || + typeof value === 'function' ) ) { - let reason = `'${pathToString(path)}' was found but does not resolve to a string.` + let reason = `'${pathToString(path)}' was found but does not resolve to a string, number, array or function.` if (isObject(value)) { let validKeys = Object.keys(value).filter(