Skip to content
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
4 changes: 2 additions & 2 deletions types/mithril/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ declare function mount(element: Element, component: null): void; // tslint:disab
/** Returns a shallow-cloned object with lifecycle attributes and any given custom attributes omitted. */
declare function censor<
O extends Record<string, any>,
E extends readonly string[],
>(object: O, extra: E): Omit<Mithril._NoLifecycle<O>, E[number]>;
E extends readonly string[] = readonly [],
>(object: O, extra?: E): Omit<Mithril._NoLifecycle<O>, E[number]>;

/** Makes an XHR request and returns a promise. */
declare function request<T>(options: Mithril.RequestOptions<T> & { url: string }): Promise<T>;
Expand Down
22 changes: 16 additions & 6 deletions types/mithril/test/test-misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ const params = parseQueryString("?id=123");

const qstr = buildQueryString({ id: 123 });

const censored = censor({ one: "two", enabled: false, oninit: () => {} }, ["enabled"] as const);
// @ts-expect-error
censored.enabled;
// @ts-expect-error
censored.oninit;
censored.one;
{
const censored = censor({ one: "two", enabled: false, oninit: () => {} }, ["enabled"] as const);
// @ts-expect-error
censored.enabled;
// @ts-expect-error
censored.oninit;
censored.one;
}

{
const censored = censor({ one: "two", enabled: false, oninit: () => {} });
censored.enabled;
// @ts-expect-error
censored.oninit;
censored.one;
}

render(document.body, "Hello");
render(document.body, h("h1", "Test"));
Expand Down