Skip to content

Commit b71d1d0

Browse files
committed
fix(kit-headless): fix the TS2742 errors on dts generation
Fix the TS2742 errors by - adding a afterDiagnostic to make sure such errors break the build (vite.config.ts) - fixing the few outstanding instances of ts2742 manually (Toggle, Progress, Checkbox, Button, Radio, Toast, Toggle, useOrdinal) - remove redundant exports from index.ts - rename 3 instances of preventedKeys to fix error `Conflicting namespaces: "packages/kit-headless/src/index.ts" re-exports "_auto_preventedKeys" from one of the modules "packages/kit-headless/src/components/autocomplete/index.ts" and "packages/kit-headless/src/components/combobox/index.ts" (will be ignored)`
1 parent 2048395 commit b71d1d0

File tree

12 files changed

+50
-37
lines changed

12 files changed

+50
-37
lines changed

packages/kit-headless/src/components/autocomplete/autocomplete-listbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import AutocompleteContextId from './autocomplete-context-id';
1212

1313
import { KeyCode } from '../../utils/key-code.type';
1414

15-
const preventedKeys = [
15+
const listPreventedKeys = [
1616
KeyCode.Home,
1717
KeyCode.End,
1818
KeyCode.PageDown,
@@ -31,7 +31,7 @@ export const AutocompleteListbox = component$((props: ListboxProps) => {
3131

3232
useVisibleTask$(function preventDefaultTask({ cleanup }) {
3333
function keyHandler(e: KeyboardEvent) {
34-
if (preventedKeys.includes(e.key as KeyCode)) {
34+
if (listPreventedKeys.includes(e.key as KeyCode)) {
3535
e.preventDefault();
3636
}
3737
}

packages/kit-headless/src/components/checkbox/checkbox.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
Component,
23
PropFunction,
34
QwikChangeEvent,
45
QwikIntrinsicElements,
@@ -10,7 +11,7 @@ export type LabelProps = QwikIntrinsicElements['label'] & {
1011
htmlFor?: string;
1112
};
1213

13-
export const Label = component$(({ ...props }: LabelProps) => {
14+
export const Label: Component<LabelProps> = component$(({ ...props }: LabelProps) => {
1415
return (
1516
<label {...props}>
1617
<Slot />
@@ -31,7 +32,7 @@ export type CheckboxProps = QwikIntrinsicElements['input'] & {
3132
>;
3233
};
3334

34-
export const Root = component$(
35+
export const Root: Component<CheckboxProps> = component$(
3536
({
3637
checked,
3738
disabled,

packages/kit-headless/src/components/combobox/combobox-input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
getPrevEnabledOptionIndex,
1919
} from './utils';
2020

21-
const preventedKeys = [KeyCode.Home, KeyCode.End, KeyCode.PageDown, KeyCode.ArrowUp];
21+
const comboPreventedKeys = [KeyCode.Home, KeyCode.End, KeyCode.PageDown, KeyCode.ArrowUp];
2222

2323
export type ComboboxInputProps = {
2424
disableOnBlur?: boolean;
@@ -123,7 +123,7 @@ export const ComboboxInput = component$(
123123

124124
useVisibleTask$(function preventDefaultTask({ cleanup }) {
125125
function keyHandler(e: KeyboardEvent) {
126-
if (preventedKeys.includes(e.key as KeyCode)) {
126+
if (comboPreventedKeys.includes(e.key as KeyCode)) {
127127
e.preventDefault();
128128
}
129129
}

packages/kit-headless/src/components/tabs/tab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type TabProps = {
2727
/** @deprecated Internal use only */
2828
} & QwikIntrinsicElements['button'];
2929

30-
export const preventedKeys = [
30+
const tabPreventedKeys = [
3131
KeyCode.Home,
3232
KeyCode.End,
3333
KeyCode.PageDown,
@@ -57,7 +57,7 @@ export const Tab = component$(
5757

5858
useVisibleTask$(function preventDefaultOnKeysVisibleTask({ cleanup }) {
5959
function handler(event: KeyboardEvent) {
60-
if (preventedKeys.includes(event.key as KeyCode)) {
60+
if (tabPreventedKeys.includes(event.key as KeyCode)) {
6161
event.preventDefault();
6262
}
6363
contextService.onTabKeyDown$(event.key as KeyCode, tabId!);

packages/kit-headless/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ export * from './components/accordion/';
22
export * from './components/badge/badge';
33
export * from './components/button-group/button-group';
44
export * from './components/card';
5-
export * from './components/autocomplete/autocomplete-root';
6-
export * from './components/autocomplete/';
7-
export * from './components/combobox/';
5+
export * from './components/autocomplete';
6+
export * from './components/combobox';
87
export * as Carousel from './components/carousel/carousel';
98
export * from './components/carousel/use';
109
export * from './components/pagination/pagination';

packages/kit-headless/vite.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ export default defineConfig({
1515
tsconfigPaths({ root: '../../' }),
1616
dts({
1717
tsconfigPath: join(dirname(fileURLToPath(import.meta.url)), 'tsconfig.lib.json'),
18+
19+
afterDiagnostic(ds) {
20+
const nonPortableTypeErrors = ds.filter((d) => d.code === 2742);
21+
if (nonPortableTypeErrors.length > 0) {
22+
// stop the build - yes with an empty promise - that's what the func expects
23+
return Promise.reject(nonPortableTypeErrors);
24+
}
25+
26+
return;
27+
},
1828
}),
1929
],
2030
server: {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { QwikIntrinsicElements, JSXChildren } from '@builder.io/qwik';
2+
import { JSX } from '@builder.io/qwik/jsx-runtime';
23

34
export type ButtonProps = QwikIntrinsicElements['button'] & {
45
children: JSXChildren;
56
};
67

7-
export const Button = ({ children, ...props }: ButtonProps) => {
8+
export const Button = ({ children, ...props }: ButtonProps): JSX.Element => {
89
return <button {...props}>{children}</button>;
910
};
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import { QwikIntrinsicElements } from '@builder.io/qwik';
1+
import { ProgressHTMLAttributes, QwikIntrinsicElements } from '@builder.io/qwik';
2+
import { JSX } from '@builder.io/qwik/jsx-runtime';
3+
export type { ProgressHTMLAttributes } from '@builder.io/qwik/core';
24

35
export type ProgressProps = QwikIntrinsicElements['progress'];
46

5-
export const Progress = (props: ProgressProps) => {
7+
export const Progress: (
8+
props: ProgressHTMLAttributes<HTMLProgressElement>,
9+
) => JSX.Element = (props) => {
610
return <progress {...props} />;
711
};
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { QwikIntrinsicElements } from '@builder.io/qwik';
1+
import { InputHTMLAttributes, QwikIntrinsicElements } from '@builder.io/qwik';
2+
import { JSX } from '@builder.io/qwik/jsx-runtime';
23

34
export type RadioProps = QwikIntrinsicElements['input'];
45

5-
export const Radio = (props: RadioProps) => <input {...props} type="radio" />;
6+
export const Radio: (props: InputHTMLAttributes<HTMLInputElement>) => JSX.Element = (
7+
props,
8+
) => <input {...props} type="radio" />;

packages/primitives/src/lib/toast/toast.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { QwikIntrinsicElements } from '@builder.io/qwik';
2+
import { JSX } from '@builder.io/qwik/jsx-runtime';
23

34
export type ToastProps = QwikIntrinsicElements['div'] & {
45
label?: string;
56
};
67

7-
export const Toast = ({ label = 'New Message', ...toastProps }: ToastProps) => {
8+
export const Toast = ({
9+
label = 'New Message',
10+
...toastProps
11+
}: ToastProps): JSX.Element => {
812
return (
913
<div {...toastProps}>
1014
<span>{label}</span>

0 commit comments

Comments
 (0)