From b9bf0e20006f643f71a4f3d7d2b0b915e0edd0fc Mon Sep 17 00:00:00 2001 From: Jon Ambas Date: Tue, 9 Apr 2024 10:51:58 -0400 Subject: [PATCH] fix(transform): fix types (#22) --- README.md | 1 - src/__tests__/transformer.test.ts | 4 ---- src/transform.ts | 9 +++++++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1a17f2f..56ce7aa 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,6 @@ const nextConfig = { config.plugins.push( unplugin.webpack({ transform: transform(tokens), - optimizeJs: true, // Optional, this will replace other Panda runtime functions (css, cva, etc) }), ); return config; diff --git a/src/__tests__/transformer.test.ts b/src/__tests__/transformer.test.ts index 1ef5cc2..ff09558 100644 --- a/src/__tests__/transformer.test.ts +++ b/src/__tests__/transformer.test.ts @@ -9,7 +9,6 @@ describe('transform', () => { it('replaces ct', () => { expect( transform(tokens)({ - configure: () => {}, filePath: 'test.tsx', content: ` import { css, ct, cva } from '@/styled-system/css'; @@ -56,7 +55,6 @@ describe('transform', () => { it('skips without imports, expressions, content', () => { expect( transform(tokens)({ - configure: () => {}, filePath: 'test.tsx', content: `
`, }), @@ -64,7 +62,6 @@ describe('transform', () => { expect( transform(tokens)({ - configure: () => {}, filePath: 'test.tsx', content: `import { ct } from '@/styled-system/css`, }), @@ -72,7 +69,6 @@ describe('transform', () => { expect( transform(tokens)({ - configure: () => {}, filePath: 'test.tsx', content: ``, }), diff --git a/src/transform.ts b/src/transform.ts index 55d8f7a..b1969a6 100644 --- a/src/transform.ts +++ b/src/transform.ts @@ -3,6 +3,11 @@ import { createContext } from './context'; import type { ComponentTokens } from './types'; import { parser } from './parser'; +// TODO: This is what unplugin expects, but avoiding installing @pandacss/node bc of a type conflict +// Omit & Pick + +type TransformArgs = Omit; + /** * Transformer for @pandabox/unplugin. * Replaces JS runtime calls to `ct` with their resulting class names. @@ -12,10 +17,10 @@ import { parser } from './parser'; */ export const transform = (tokens: ComponentTokens) => { const context = createContext(tokens); - return (args: ParserResultBeforeHookArgs) => { + return (args: TransformArgs) => { // This doesn't have `args.configure` if (!args.content) return; - return parser(args, context); + return parser(args as ParserResultBeforeHookArgs, context); }; };