Skip to content

Commit d5ade30

Browse files
committed
fix: many type issues
Fixes #527
1 parent 6550180 commit d5ade30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+231
-161
lines changed

packages/banner/src/Banner.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
'mdc-banner__graphic': true,
4747
})}
4848
role="img"
49-
alt=""
49+
{...altProp}
5050
{...prefixFilter($$restProps, 'graphic$')}
5151
>
5252
<slot name="icon" />
@@ -139,6 +139,10 @@
139139
let removeLayoutListener: RemoveLayoutListener | undefined;
140140
let width: number | undefined = undefined;
141141
142+
// This is for a div that uses the role of "img". TS doesn't like it directly
143+
// on the element.
144+
const altProp = { alt: '' };
145+
142146
setContext('SMUI:label:context', 'banner');
143147
setContext('SMUI:icon:context', 'banner');
144148
setContext('SMUI:button:context', 'banner');

packages/bottom-app-bar/src/AutoAdjust.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
</svelte:component>
1818

1919
<script lang="ts">
20-
import type { ComponentType, SvelteComponent } from 'svelte';
20+
import type { SvelteComponent } from 'svelte';
2121
import { get_current_component } from 'svelte/internal';
2222
import type { ActionArray } from '@smui/common/internal';
2323
import { forwardEventsBuilder, classMap } from '@smui/common/internal';
2424
import type { SmuiElementMap, SmuiAttrs, SmuiSvgAttrs } from '@smui/common';
2525
import { SmuiElement } from '@smui/common';
2626
2727
type TagName = $$Generic<keyof SmuiElementMap>;
28-
type Component = $$Generic<ComponentType<SvelteComponent>>;
28+
type Component = $$Generic<typeof SvelteComponent>;
2929
type OwnProps = {
3030
use?: ActionArray;
3131
class?: string;

packages/button/src/Button.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
>
5353

5454
<script lang="ts">
55-
import type { ComponentType, SvelteComponent } from 'svelte';
55+
import type { SvelteComponent } from 'svelte';
5656
import { setContext, getContext } from 'svelte';
5757
import { get_current_component } from 'svelte/internal';
5858
import type { ActionArray } from '@smui/common/internal';
@@ -66,7 +66,7 @@
6666
import { SmuiElement } from '@smui/common';
6767
6868
type TagName = $$Generic<keyof SmuiElementMap>;
69-
type Component = $$Generic<ComponentType<SvelteComponent>>;
69+
type Component = $$Generic<typeof SvelteComponent>;
7070
type OwnProps = {
7171
use?: ActionArray;
7272
class?: string;

packages/card/src/PrimaryAction.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
.concat([style])
2222
.join(' ')}
2323
{tabindex}
24+
role="button"
2425
{...$$restProps}
2526
>
2627
<div class="mdc-card__ripple" />

packages/chips/src/Chip.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
<script lang="ts">
6060
import { deprecated } from '@material/chips';
61-
import type { ComponentType, SvelteComponent } from 'svelte';
61+
import type { SvelteComponent } from 'svelte';
6262
import { onMount, setContext, getContext } from 'svelte';
6363
import { writable } from 'svelte/store';
6464
import { get_current_component } from 'svelte/internal';
@@ -79,7 +79,7 @@
7979
const { MDCChipFoundation } = deprecated;
8080
8181
type TagName = $$Generic<keyof SmuiElementMap>;
82-
type Component = $$Generic<ComponentType<SvelteComponent>>;
82+
type Component = $$Generic<typeof SvelteComponent>;
8383
type OwnProps = {
8484
use?: ActionArray;
8585
class?: string;

packages/chips/src/Text.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
[className]: true,
1717
'mdc-chip__primary-action': true,
1818
})}
19-
role={$filter ? 'checkbox' : $choice ? 'radio' : 'button'}
2019
{...$filter || $choice
2120
? { 'aria-selected': $isSelected ? 'true' : 'false' }
2221
: {}}
23-
{tabindex}
22+
{...roleProps}
2423
{...internalAttrs}
2524
{...$$restProps}><span class="mdc-chip__text"><slot /></span></span
2625
>
@@ -73,6 +72,11 @@
7372
'SMUI:chips:chip:isSelected'
7473
);
7574
75+
$: roleProps = {
76+
role: $filter ? 'checkbox' : $choice ? 'radio' : 'button',
77+
tabindex,
78+
};
79+
7680
onMount(() => {
7781
let accessor: SMUIChipsPrimaryActionAccessor = {
7882
focus,

packages/common/src/CommonIcon.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
>
2020

2121
<script lang="ts">
22-
import type { ComponentType, SvelteComponent } from 'svelte';
22+
import type { SvelteComponent } from 'svelte';
2323
import { getContext } from 'svelte';
2424
import { get_current_component } from 'svelte/internal';
2525
@@ -33,7 +33,7 @@
3333
import { SmuiElement, Svg } from './index.js';
3434
3535
type TagName = $$Generic<keyof SmuiElementMap>;
36-
type Component = $$Generic<ComponentType<SvelteComponent>>;
36+
type Component = $$Generic<typeof SvelteComponent>;
3737
type OwnProps = {
3838
use?: ActionArray;
3939
class?: string;

packages/common/src/CommonLabel.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
>
2424

2525
<script lang="ts">
26-
import type { ComponentType, SvelteComponent } from 'svelte';
26+
import type { SvelteComponent } from 'svelte';
2727
import { getContext } from 'svelte';
2828
import { get_current_component } from 'svelte/internal';
2929
@@ -37,7 +37,7 @@
3737
import { SmuiElement } from './index.js';
3838
3939
type TagName = $$Generic<keyof SmuiElementMap>;
40-
type Component = $$Generic<ComponentType<SvelteComponent>>;
40+
type Component = $$Generic<typeof SvelteComponent>;
4141
type OwnProps = {
4242
use?: ActionArray;
4343
class?: string;

packages/common/src/classadder/ClassAdder.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</script>
2828

2929
<script lang="ts">
30-
import type { ComponentType, SvelteComponent } from 'svelte';
30+
import type { SvelteComponent } from 'svelte';
3131
import { onDestroy, getContext, setContext } from 'svelte';
3232
import { get_current_component } from 'svelte/internal';
3333
@@ -37,7 +37,7 @@
3737
import { classMap } from '../internal/classMap.js';
3838
3939
type TagName = $$Generic<keyof SmuiElementMap>;
40-
type Component = $$Generic<ComponentType<SvelteComponent>>;
40+
type Component = $$Generic<typeof SvelteComponent>;
4141
type OwnProps = {
4242
use?: ActionArray;
4343
class?: string;

packages/common/src/classadder/ClassAdder.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { SmuiElementMap } from '../smui.types.js';
44

55
export type ClassAdderInternals<
66
T extends keyof SmuiElementMap = 'div',
7-
C extends ComponentType<SvelteComponent> = ComponentType<SvelteComponent>
7+
C extends typeof SvelteComponent = ComponentType<SvelteComponent>
88
> = {
99
component: C;
1010
tag: T;

0 commit comments

Comments
 (0)