Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(writer): rename internal RestProps --> $RestProps #148

Merged
merged 3 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The generated definition extends the official `SvelteComponentTyped` interface e
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["button"];
type $RestProps = SvelteHTMLElements["button"];

type $Props = {
/**
Expand All @@ -57,7 +57,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type ButtonProps = Omit<RestProps, keyof $Props> & $Props;
export type ButtonProps = Omit<$RestProps, keyof $Props> & $Props;

export default class Button extends SvelteComponentTyped<
ButtonProps,
Expand Down Expand Up @@ -85,7 +85,7 @@ The accompanying JSDoc annotations would generate the following:
```ts
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["button"];
type $RestProps = SvelteHTMLElements["button"];

type $Props = {
/**
Expand All @@ -100,7 +100,7 @@ type $Props = {
primary?: boolean;
};

export type ButtonProps = Omit<RestProps, keyof $Props> & $Props;
export type ButtonProps = Omit<$RestProps, keyof $Props> & $Props;

export default class Button extends SvelteComponentTyped<
ButtonProps,
Expand Down
4 changes: 2 additions & 2 deletions src/writer/writer-ts-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ function genPropDef(def: Pick<ComponentDocApi, "props" | "rest_props" | "moduleN
const dataAttributes = "[key: `data-${string}`]: any;";

prop_def = `
${extend_tag_map ? `type RestProps = ${extend_tag_map};\n` : ""}
${extend_tag_map ? `type $RestProps = ${extend_tag_map};\n` : ""}
type $Props${genericsName} = {
${props}

${dataAttributes}
};

export type ${props_name}${genericsName} = Omit<RestProps, keyof $Props${genericsName}> & $Props${genericsName};
export type ${props_name}${genericsName} = Omit<$RestProps, keyof $Props${genericsName}> & $Props${genericsName};
`;
} else {
prop_def = `
Expand Down
20 changes: 10 additions & 10 deletions tests/__snapshots__/fixtures.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1326,13 +1326,13 @@ exports[`fixtures (TypeScript) "svg-props/input.svelte" 1`] = `
"import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["svg"];
type $RestProps = SvelteHTMLElements["svg"];

type $Props = {
[key: \`data-${string}\`]: any;
};

export type SvgPropsProps = Omit<RestProps, keyof $Props> & $Props;
export type SvgPropsProps = Omit<$RestProps, keyof $Props> & $Props;

export default class SvgProps extends SvelteComponentTyped<SvgPropsProps, Record<string, any>, {}> {}
"
Expand Down Expand Up @@ -1597,7 +1597,7 @@ export interface DataTableHeader<Row = DataTableRow> {
value: string;
}

type RestProps = SvelteHTMLElements["div"];
type $RestProps = SvelteHTMLElements["div"];

type $Props<Row> = {
/**
Expand All @@ -1613,7 +1613,7 @@ type $Props<Row> = {
[key: \`data-${string}\`]: any;
};

export type GenericsWithRestPropsProps<Row> = Omit<RestProps, keyof $Props<Row>> & $Props<Row>;
export type GenericsWithRestPropsProps<Row> = Omit<$RestProps, keyof $Props<Row>> & $Props<Row>;

export default class GenericsWithRestProps<Row extends DataTableRow = DataTableRow> extends SvelteComponentTyped<
GenericsWithRestPropsProps<Row>,
Expand Down Expand Up @@ -1822,7 +1822,7 @@ exports[`fixtures (TypeScript) "rest-props-multiple/input.svelte" 1`] = `
"import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["ul"] & SvelteHTMLElements["ol"];
type $RestProps = SvelteHTMLElements["ul"] & SvelteHTMLElements["ol"];

type $Props = {
/**
Expand All @@ -1833,7 +1833,7 @@ type $Props = {
[key: \`data-${string}\`]: any;
};

export type RestPropsMultipleProps = Omit<RestProps, keyof $Props> & $Props;
export type RestPropsMultipleProps = Omit<$RestProps, keyof $Props> & $Props;

export default class RestPropsMultiple extends SvelteComponentTyped<RestPropsMultipleProps, Record<string, any>, {}> {}
"
Expand Down Expand Up @@ -1921,13 +1921,13 @@ exports[`fixtures (TypeScript) "rest-props-simple/input.svelte" 1`] = `
"import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["h1"];
type $RestProps = SvelteHTMLElements["h1"];

type $Props = {
[key: \`data-${string}\`]: any;
};

export type RestPropsSimpleProps = Omit<RestProps, keyof $Props> & $Props;
export type RestPropsSimpleProps = Omit<$RestProps, keyof $Props> & $Props;

export default class RestPropsSimple extends SvelteComponentTyped<RestPropsSimpleProps, Record<string, any>, {}> {}
"
Expand All @@ -1937,13 +1937,13 @@ exports[`fixtures (TypeScript) "anchor-props/input.svelte" 1`] = `
"import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["a"];
type $RestProps = SvelteHTMLElements["a"];

type $Props = {
[key: \`data-${string}\`]: any;
};

export type AnchorPropsProps = Omit<RestProps, keyof $Props> & $Props;
export type AnchorPropsProps = Omit<$RestProps, keyof $Props> & $Props;

export default class AnchorProps extends SvelteComponentTyped<AnchorPropsProps, Record<string, any>, { default: {} }> {}
"
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/carbon/types/Accordion/AccordionItem.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["li"];
type $RestProps = SvelteHTMLElements["li"];

type $Props = {
/**
Expand Down Expand Up @@ -32,7 +32,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type AccordionItemProps = Omit<RestProps, keyof $Props> & $Props;
export type AccordionItemProps = Omit<$RestProps, keyof $Props> & $Props;

/** `AccordionItem` is slottable */
export default class AccordionItem extends SvelteComponentTyped<
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["ul"];
type $RestProps = SvelteHTMLElements["ul"];

type $Props = {
/**
Expand Down Expand Up @@ -31,7 +31,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type AccordionSkeletonProps = Omit<RestProps, keyof $Props> & $Props;
export type AccordionSkeletonProps = Omit<$RestProps, keyof $Props> & $Props;

export default class AccordionSkeleton extends SvelteComponentTyped<
AccordionSkeletonProps,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/carbon/types/AspectRatio/AspectRatio.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["div"];
type $RestProps = SvelteHTMLElements["div"];

type $Props = {
/**
Expand All @@ -13,7 +13,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type AspectRatioProps = Omit<RestProps, keyof $Props> & $Props;
export type AspectRatioProps = Omit<$RestProps, keyof $Props> & $Props;

export default class AspectRatio extends SvelteComponentTyped<
AspectRatioProps,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/carbon/types/Breadcrumb/BreadcrumbItem.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["li"];
type $RestProps = SvelteHTMLElements["li"];

type $Props = {
/**
Expand All @@ -19,7 +19,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type BreadcrumbItemProps = Omit<RestProps, keyof $Props> & $Props;
export type BreadcrumbItemProps = Omit<$RestProps, keyof $Props> & $Props;

export default class BreadcrumbItem extends SvelteComponentTyped<
BreadcrumbItemProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["div"];
type $RestProps = SvelteHTMLElements["div"];

type $Props = {
/**
Expand All @@ -19,7 +19,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type BreadcrumbSkeletonProps = Omit<RestProps, keyof $Props> & $Props;
export type BreadcrumbSkeletonProps = Omit<$RestProps, keyof $Props> & $Props;

export default class BreadcrumbSkeleton extends SvelteComponentTyped<
BreadcrumbSkeletonProps,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/carbon/types/Button/Button.svelte.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { SvelteHTMLElements } from "svelte/elements";

import type { ButtonSkeletonProps } from "./ButtonSkeleton.svelte";

type RestProps = SvelteHTMLElements["button"] &
type $RestProps = SvelteHTMLElements["button"] &
SvelteHTMLElements["a"] &
SvelteHTMLElements["div"];

Expand Down Expand Up @@ -105,7 +105,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type ButtonProps = Omit<RestProps, keyof $Props> & $Props;
export type ButtonProps = Omit<$RestProps, keyof $Props> & $Props;

export default class Button extends SvelteComponentTyped<
ButtonProps,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/carbon/types/Button/ButtonSet.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["div"];
type $RestProps = SvelteHTMLElements["div"];

type $Props = {
/**
Expand All @@ -13,7 +13,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type ButtonSetProps = Omit<RestProps, keyof $Props> & $Props;
export type ButtonSetProps = Omit<$RestProps, keyof $Props> & $Props;

export default class ButtonSet extends SvelteComponentTyped<
ButtonSetProps,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/carbon/types/Button/ButtonSkeleton.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["a"];
type $RestProps = SvelteHTMLElements["a"];

type $Props = {
/**
Expand All @@ -26,7 +26,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type ButtonSkeletonProps = Omit<RestProps, keyof $Props> & $Props;
export type ButtonSkeletonProps = Omit<$RestProps, keyof $Props> & $Props;

export default class ButtonSkeleton extends SvelteComponentTyped<
ButtonSkeletonProps,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/carbon/types/Checkbox/CheckboxSkeleton.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["div"];
type $RestProps = SvelteHTMLElements["div"];

type $Props = {
[key: `data-${string}`]: any;
};

export type CheckboxSkeletonProps = Omit<RestProps, keyof $Props> & $Props;
export type CheckboxSkeletonProps = Omit<$RestProps, keyof $Props> & $Props;

export default class CheckboxSkeleton extends SvelteComponentTyped<
CheckboxSkeletonProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["div"];
type $RestProps = SvelteHTMLElements["div"];

type $Props = {
/**
Expand All @@ -13,7 +13,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type CodeSnippetSkeletonProps = Omit<RestProps, keyof $Props> & $Props;
export type CodeSnippetSkeletonProps = Omit<$RestProps, keyof $Props> & $Props;

export default class CodeSnippetSkeleton extends SvelteComponentTyped<
CodeSnippetSkeletonProps,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/carbon/types/ComboBox/ComboBox.svelte.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface ComboBoxItem {
text: string;
}

type RestProps = SvelteHTMLElements["div"];
type $RestProps = SvelteHTMLElements["div"];

type $Props = {
/**
Expand Down Expand Up @@ -126,7 +126,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type ComboBoxProps = Omit<RestProps, keyof $Props> & $Props;
export type ComboBoxProps = Omit<$RestProps, keyof $Props> & $Props;

export default class ComboBox extends SvelteComponentTyped<
ComboBoxProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["div"];
type $RestProps = SvelteHTMLElements["div"];

type $Props = {
/**
Expand Down Expand Up @@ -49,7 +49,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type ComposedModalProps = Omit<RestProps, keyof $Props> & $Props;
export type ComposedModalProps = Omit<$RestProps, keyof $Props> & $Props;

export default class ComposedModal extends SvelteComponentTyped<
ComposedModalProps,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/carbon/types/ComposedModal/ModalBody.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["div"];
type $RestProps = SvelteHTMLElements["div"];

type $Props = {
/**
Expand All @@ -19,7 +19,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type ModalBodyProps = Omit<RestProps, keyof $Props> & $Props;
export type ModalBodyProps = Omit<$RestProps, keyof $Props> & $Props;

export default class ModalBody extends SvelteComponentTyped<
ModalBodyProps,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/carbon/types/ComposedModal/ModalFooter.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type RestProps = SvelteHTMLElements["div"];
type $RestProps = SvelteHTMLElements["div"];

type $Props = {
/**
Expand Down Expand Up @@ -43,7 +43,7 @@ type $Props = {
[key: `data-${string}`]: any;
};

export type ModalFooterProps = Omit<RestProps, keyof $Props> & $Props;
export type ModalFooterProps = Omit<$RestProps, keyof $Props> & $Props;

export default class ModalFooter extends SvelteComponentTyped<
ModalFooterProps,
Expand Down
Loading