Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 8a50d2f

Browse files
committed
fix: improve type resolution
1 parent 0fc3cb0 commit 8a50d2f

File tree

4 files changed

+38
-31
lines changed

4 files changed

+38
-31
lines changed

components.d.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,30 @@
66
*
77
* This is a generated file. Do not edit it's contents.
88
*
9-
* This file was generated on 2022-07-16T15:27:15.568Z
9+
* This file was generated on 2022-08-31T15:33:17.883Z
1010
*/
1111

1212
import { ChakraProps, chakra } from "@chakra-ui/vue-system"
13-
import { VNodeChild, HTMLAttributes } from "vue"
13+
import { VNodeChild, VNode, HTMLAttributes } from "vue"
1414

1515
export type JsxNode = VNodeChild | JSX.Element
1616

17+
declare global {
18+
namespace h.JSX {
19+
interface Element extends VNode {}
20+
interface ElementClass {
21+
$props: {}
22+
}
23+
interface ElementAttributesProperty {
24+
$props: {}
25+
}
26+
27+
interface IntrinsicAttributes
28+
extends Omit<HTMLAttributes, "color">,
29+
ChakraProps {}
30+
}
31+
}
32+
1733
type EventHandler = (...args: any[]) => void
1834

1935
export interface SlotDirective {
@@ -46,7 +62,6 @@ declare module "@vue/runtime-core" {
4662
/* Global component types for Volar auto-complete */
4763
export interface GlobalComponents {
4864
chakra: typeof import("@chakra-ui/vue-next")["chakra"]
49-
5065
CAccordion: typeof import("@chakra-ui/vue-next")["CAccordion"]
5166
CAccordionButton: typeof import("@chakra-ui/vue-next")["CAccordionButton"]
5267
CAccordionIcon: typeof import("@chakra-ui/vue-next")["CAccordionIcon"]

packages/c-accordion/src/accordion.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,7 @@ export const CAccordionPanel: ComponentWithProps<CAccordionPanelProps> =
256256
})
257257
return (
258258
<CCollapse isOpen={isOpen.value}>
259-
<chakra.div
260-
{...contentProps}
261-
__cs
262-
s={styles.value.panel}
263-
{...attrs}
264-
>
259+
<chakra.div {...contentProps} __css={styles.value.panel} {...attrs}>
265260
{getValidChildren(slots)}
266261
</chakra.div>
267262
</CCollapse>

scripts/generate-global-types.ts

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,7 @@ const ChakraComponents = require("@chakra-ui/vue-next")
1212
type ComponentsImport = typeof ChakraComponents
1313

1414
async function generateComponents() {
15-
let code = `
16-
import type { HTMLAttributes, VNode } from "vue";
17-
import type { ChakraProps } from "@chakra-ui/vue-system";
18-
19-
declare global {
20-
namespace h.JSX {
21-
interface Element extends VNode {}
22-
interface ElementClass {
23-
$props: {}
24-
}
25-
interface ElementAttributesProperty {
26-
$props: {}
27-
}
28-
29-
interface IntrinsicAttributes
30-
extends Omit<HTMLAttributes, "color">,
31-
ChakraProps {}
32-
}
33-
}
34-
`
15+
let code = ``
3516

3617
for (const component in ChakraComponents) {
3718
/**
@@ -65,9 +46,25 @@ async function generateComponents() {
6546
*/
6647
6748
import { ChakraProps, chakra } from '@chakra-ui/vue-system'
68-
import { VNodeChild, HTMLAttributes } from 'vue'
49+
import { VNodeChild, VNode, HTMLAttributes } from 'vue'
6950
7051
export type JsxNode = VNodeChild | JSX.Element
52+
53+
declare global {
54+
namespace h.JSX {
55+
interface Element extends VNode {}
56+
interface ElementClass {
57+
$props: {}
58+
}
59+
interface ElementAttributesProperty {
60+
$props: {}
61+
}
62+
63+
interface IntrinsicAttributes
64+
extends Omit<HTMLAttributes, "color">,
65+
ChakraProps {}
66+
}
67+
}
7168
7269
type EventHandler = (...args: any[]) => void;
7370

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"target": "es5",
55
"module": "esnext",
6-
"types": ["dom.iterable", "vue", "jest", "components.d.ts"],
6+
"types": ["node", "dom.iterable", "vue", "jest", "components.d.ts", "env.d.ts"],
77
"lib": ["dom", "esnext"],
88
"composite": true,
99
"declaration": true,

0 commit comments

Comments
 (0)