Type mismatch for UnoCSS setup configuration
openscript opened this issue · 0 comments
openscript commented
deepMerge
setup configurations don't cover the case, where shortcuts aren't an array, even though the UnoCSS typing is allowing for such:
slidev/packages/slidev/node/plugins/setupNode.ts
Lines 9 to 14 in a6329a7
UserShortcuts
:
https://github.com/unocss/unocss/blob/62abf05fb29156b13456d02b0ae6ddca5916c356/packages/core/src/types.ts#L201
With a configuration like
import { defineUnoSetup } from '@slidev/types'
export default defineUnoSetup(() => ({
shortcuts: {
'bg-main': 'bg-white text-[#181818] dark:bg-[#121212] dark:text-[#ddd]',
},
}))
this leads to:
/workspaces/slidev-theme/node_modules/@slidev/cli/dist/chunk-KKGXM3XL.js:12
a[key] = [...a[key], ...b[key]];
^
TypeError: b[key] is not iterable
at /workspaces/slidev-theme/node_modules/@slidev/cli/dist/chunk-KKGXM3XL.js:12:32
at Array.forEach (<anonymous>)
at deepMerge (/workspaces/slidev-theme/node_modules/@slidev/cli/dist/chunk-KKGXM3XL.js:8:18)
at loadSetups (/workspaces/slidev-theme/node_modules/@slidev/cli/dist/chunk-KKGXM3XL.js:26:27)
at async Object.createUnocssPlugin (/workspaces/slidev-theme/node_modules/@slidev/cli/dist/unocss-2DU67QXG.js:31:12)
at async Promise.all (index 14)
at async ViteSlidevPlugin (/workspaces/slidev-theme/node_modules/@slidev/cli/dist/chunk-SEZW5DVB.js:1694:11)
at async createServer (/workspaces/slidev-theme/node_modules/@slidev/cli/dist/chunk-EFLHY5RE.js:2509:11)
at async initServer (/workspaces/slidev-theme/node_modules/@slidev/cli/dist/cli.js:120:16)
Node.js v20.5.0
Reproduction
- Clone openscript-ch/slidev-theme@cfce5da
- Open in devcontainer (optional)
- Install dependencies with yarn install
- Run yarn dev
Workaround
Define the configuration as an array:
import { defineUnoSetup } from '@slidev/types'
export default defineUnoSetup(() => ({
shortcuts: [
{'bg-main': 'bg-white text-[#181818] dark:bg-[#121212] dark:text-[#ddd]'}
]
}))