pull/7324/head
Ivan Hofer 4 years ago
parent c2e05e1939
commit c5594717ab

@ -350,15 +350,9 @@ export function set_svg_attributes(node: Element & ElementCSSInlineStyle, attrib
}
}
export function set_custom_element_data_map(node, data_map: Record<string, unknown>) {
export function set_custom_element_data_map(node: Element, data_map: Record<string, unknown>) {
Object.keys(data_map).forEach((key) => {
set_custom_element_data(node, key, data_map[key]);
});
}
export function set_custom_element_data_map(node, data_map: Record<string, unknown>) {
Object.keys(data_map).forEach((key) => {
set_custom_element_data(node, key, data_map[key]);
set_custom_element_data(node, key, data_map[key] as TODO<string>);
});
}
@ -548,7 +542,8 @@ export function claim_html_tag(nodes: ChildNodeArray, is_svg: boolean) {
const start_index = find_comment(nodes, 'HTML_TAG_START', 0);
const end_index = find_comment(nodes, 'HTML_TAG_END', start_index);
if (start_index === end_index) {
return new HtmlTagHydration(undefined, is_svg);
// @ts-expect-error `HtmlTagHydration` does not expect a second parameter
return new HtmlTagHydration(undefined, is_svg);
}
init_claim_info(nodes);
@ -560,6 +555,7 @@ export function claim_html_tag(nodes: ChildNodeArray, is_svg: boolean) {
n.claim_order = (nodes.claim_info as TODO<ClaimInfo>).total_claimed;
(nodes.claim_info as TODO<ClaimInfo>).total_claimed += 1;
}
// @ts-expect-error `HtmlTagHydration` does not expect a second parameter
return new HtmlTagHydration(claimed_nodes, is_svg);
}
@ -779,8 +775,8 @@ export class HtmlTagHydration extends HtmlTag {
// hydration claimed nodes
l: ChildNode[] | void;
constructor(claimed_nodes?: ChildNode[], is_svg: boolean = false) {
super(is_svg);
constructor(claimed_nodes?: ChildNode[]) {
super();
this.e = this.n = null;
this.l = claimed_nodes;
}
@ -814,6 +810,6 @@ export function get_custom_elements_slots(element: HTMLElement) {
return result;
}
export function construct_svelte_component(component, props) {
export function construct_svelte_component(component: TODO, props: Record<string, unknown>) {
return new component(props);
}

@ -56,6 +56,10 @@ export function onDestroy(fn: () => any) {
get_current_component().$$.on_destroy.push(fn);
}
export interface DispatchOptions {
cancelable?: boolean;
}
/**
* Creates an event dispatcher that can be used to dispatch [component events](/docs#template-syntax-component-directives-on-eventname).
* Event dispatchers are functions that can take two arguments: `name` and `detail`.

@ -1,5 +1,5 @@
import { Readable, Subscriber, Invalidator, Writable } from 'svelte/store';
import { SvelteComponent } from '..';
import { SvelteComponent } from '../index.js';
export function noop() { }

@ -1,33 +1,35 @@
import { createEventDispatcher } from '$runtime/internal/lifecycle';
// TODO: enable those tests when #7224 got merged
const dispatch = createEventDispatcher<{
loaded: never
change: string
valid: boolean
optional: number | null
}>();
// import { createEventDispatcher } from '$runtime/internal/lifecycle';
// @ts-expect-error: dispatch invalid event
dispatch('some-event');
// const dispatch = createEventDispatcher<{
// loaded: never
// change: string
// valid: boolean
// optional: number | null
// }>();
dispatch('loaded');
// @ts-expect-error: no detail accepted
dispatch('loaded', 123);
// // @ts-expect-error: dispatch invalid event
// dispatch('some-event');
// @ts-expect-error: detail not provided
dispatch('change');
dispatch('change', 'string');
// @ts-expect-error: wrong type of detail
dispatch('change', 123);
// @ts-expect-error: wrong type of detail
dispatch('change', undefined);
// dispatch('loaded');
// // @ts-expect-error: no detail accepted
// dispatch('loaded', 123);
dispatch('valid', true);
// @ts-expect-error: wrong type of detail
dispatch('valid', 'string');
// // @ts-expect-error: detail not provided
// dispatch('change');
// dispatch('change', 'string');
// // @ts-expect-error: wrong type of detail
// dispatch('change', 123);
// // @ts-expect-error: wrong type of detail
// dispatch('change', undefined);
dispatch('optional');
dispatch('optional', 123);
dispatch('optional', null);
// @ts-expect-error: wrong type of optional detail
dispatch('optional', 'string');
// dispatch('valid', true);
// // @ts-expect-error: wrong type of detail
// dispatch('valid', 'string');
// dispatch('optional');
// dispatch('optional', 123);
// dispatch('optional', null);
// // @ts-expect-error: wrong type of optional detail
// dispatch('optional', 'string');

Loading…
Cancel
Save