Skip to content

Commit

Permalink
fix(generator): remove export types from jsx when no jsxFramework con… (
Browse files Browse the repository at this point in the history
  • Loading branch information
erm1116 authored Oct 25, 2023
1 parent 56299cb commit 9382e68
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/hot-olives-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pandacss/generator': patch
---

remove export types from jsx when no jsxFramework configuration
2 changes: 1 addition & 1 deletion packages/generator/src/artifacts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function setupTypes(ctx: Context): Artifact {
const gen = getGeneratedTypes(ctx)
const conditions = generateConditions(ctx)
const jsx = generateJsxTypes(ctx)
const entry = generateTypesEntry(ctx)
const entry = generateTypesEntry(ctx, jsx != null)

return {
dir: ctx.paths.types,
Expand Down
37 changes: 21 additions & 16 deletions packages/generator/src/artifacts/types/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import { outdent } from 'outdent'
import type { Context } from '../../engines'

export const generateTypesEntry = (ctx: Context) => ({
global: outdent`
export const generateTypesEntry = (ctx: Context, isJsxRequired: boolean) => {
const indexExports = [
// We need to export types used in the global.d.ts here to avoid TS errors such as `The inferred type of 'xxx' cannot be named without a reference to 'yyy'`
`import '${ctx.file.extDts('./global')}'`,
ctx.file.exportTypeStar('./conditions'),
ctx.file.exportTypeStar('./pattern'),
ctx.file.exportTypeStar('./recipe'),
ctx.file.exportTypeStar('./system-types'),
isJsxRequired && ctx.file.exportTypeStar('./jsx'),
ctx.file.exportTypeStar('./style-props'),
].filter(Boolean)

return {
global: outdent`
// @ts-nocheck
import type * as Panda from '@pandacss/dev'
${ctx.file.importType('RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig', './recipe')}
Expand All @@ -22,18 +34,11 @@ export const generateTypesEntry = (ctx: Context) => ({
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>
}
`,
// We need to export types used in the global.d.ts here to avoid TS errors such as `The inferred type of 'xxx' cannot be named without a reference to 'yyy'`
index: outdent`
import '${ctx.file.extDts('./global')}'
${ctx.file.exportTypeStar('./conditions')}
${ctx.file.exportTypeStar('./pattern')}
${ctx.file.exportTypeStar('./recipe')}
${ctx.file.exportTypeStar('./system-types')}
${ctx.file.exportTypeStar('./jsx')}
${ctx.file.exportTypeStar('./style-props')}
index: outdent`
${indexExports.join('\n')}
`,
helpers: outdent`
export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
`,
helpers: outdent`
export type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
`,
})
}
}
2 changes: 1 addition & 1 deletion packages/studio/styled-system/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export * from './pattern';
export * from './recipe';
export * from './system-types';
export * from './jsx';
export * from './style-props';
export * from './style-props';

3 comments on commit 9382e68

@vercel
Copy link

@vercel vercel bot commented on 9382e68 Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 9382e68 Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

panda-docs – ./website

panda-docs.vercel.app
panda-docs-git-main-chakra-ui.vercel.app
panda-docs-chakra-ui.vercel.app
panda-css.com

@vercel
Copy link

@vercel vercel bot commented on 9382e68 Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

panda-studio – ./

panda-app.vercel.app
panda-studio-git-main-chakra-ui.vercel.app
panda-studio-chakra-ui.vercel.app

Please sign in to comment.