From 85542cac33c2cb2d50073e09783cddf274cc5598 Mon Sep 17 00:00:00 2001 From: Erik Vullings Date: Tue, 11 Aug 2026 08:42:46 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#75307=20[@type?= =?UTF-8?q?s/mithril]=20improve=20hyperscript=20diagnostics=20by=20@erikvu?= =?UTF-8?q?llings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Erik Vullings --- types/mithril/index.d.ts | 12 ++++++------ types/mithril/test/test-component.ts | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/types/mithril/index.d.ts b/types/mithril/index.d.ts index f9a08ee74de508..a899924798cd30 100644 --- a/types/mithril/index.d.ts +++ b/types/mithril/index.d.ts @@ -43,18 +43,18 @@ declare namespace Mithril { } interface Hyperscript { + /** Creates a virtual element (Vnode). */ + (selector: string, attributes: Attributes, ...children: Children[]): Vnode; + /** Creates a virtual element (Vnode). */ + (selector: string, ...children: Children[]): Vnode; + /** Creates a virtual element (Vnode). */ + (component: ComponentTypes, ...args: Children[]): Vnode; /** Creates a virtual element (Vnode). */ ( component: ComponentTypes, attributes: Attrs & CommonAttributes, ...args: Children[] ): Vnode; - /** Creates a virtual element (Vnode). */ - (selector: string, attributes: Attributes, ...children: Children[]): Vnode; - /** Creates a virtual element (Vnode). */ - (component: ComponentTypes, ...args: Children[]): Vnode; - /** Creates a virtual element (Vnode). */ - (selector: string, ...children: Children[]): Vnode; /** Creates a fragment virtual element (Vnode). */ fragment( attrs: CommonAttributes & { [key: string]: any }, diff --git a/types/mithril/test/test-component.ts b/types/mithril/test/test-component.ts index 360e113df67287..aa150202dccc34 100644 --- a/types/mithril/test/test-component.ts +++ b/types/mithril/test/test-component.ts @@ -51,6 +51,21 @@ m(comp2, { title: "", description: "" }); // Correct use with lifecycle method m(comp2, { title: "", description: "", oncreate: v => `${v.attrs.title}\n${v.attrs.description}` }); +// Component attribute diagnostics +interface NumberComponentAttrs { + min: number; +} + +const numberComponent: Component = { + view() { + return null; + }, +}; + +// Type 'string' is not assignable to type 'number'. +// @ts-expect-error +m(numberComponent, { min: "x" }); + // Properties missing // @ts-expect-error m(comp2, {}); From bbb4d3560b8db4a9591a3612d519c2cafd2fba01 Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Tue, 11 Aug 2026 09:22:43 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#75240=20[negot?= =?UTF-8?q?iator]=20allow=20readonly=20types=20as=20input=20by=20@cprecios?= =?UTF-8?q?o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/negotiator/index.d.ts | 18 +++++++++--------- types/negotiator/negotiator-tests.ts | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/types/negotiator/index.d.ts b/types/negotiator/index.d.ts index 5f00d701ee0785..8eec9f0aee7f4e 100644 --- a/types/negotiator/index.d.ts +++ b/types/negotiator/index.d.ts @@ -12,7 +12,7 @@ declare class Negotiator { * @param [availableMediaTypes] When provided, returns the most preferred media type * from a list of available media types. */ - mediaType(availableMediaTypes?: string[]): string | undefined; + mediaType(availableMediaTypes?: readonly string[]): string | undefined; /** * Returns an array of preferred media types ordered by the client preference @@ -20,7 +20,7 @@ declare class Negotiator { * @param [availableMediaTypes] When provided, returns an array of preferred media * types ordered by priority from a list of available media types. */ - mediaTypes(availableMediaTypes?: string[]): string[]; + mediaTypes(availableMediaTypes?: readonly string[]): string[]; /** * Returns the most preferred language from the client. @@ -28,7 +28,7 @@ declare class Negotiator { * @param [availableLanguages] When provided, returns the most preferred language * from a list of available languages. */ - language(availableLanguages?: string[]): string | undefined; + language(availableLanguages?: readonly string[]): string | undefined; /** * Returns an array of preferred languages ordered by the client preference. @@ -36,7 +36,7 @@ declare class Negotiator { * @param [availableLanguages] When provided, returns an array of preferred languages * ordered by priority from a list of available languages. */ - languages(availableLanguages?: string[]): string[]; + languages(availableLanguages?: readonly string[]): string[]; /** * Returns the most preferred charset from the client. @@ -44,7 +44,7 @@ declare class Negotiator { * @param [availableCharsets] When provided, returns the most preferred charset * from a list of available charsets. */ - charset(availableCharsets?: string[]): string | undefined; + charset(availableCharsets?: readonly string[]): string | undefined; /** * Returns an array of preferred charsets ordered by the client preference. @@ -52,7 +52,7 @@ declare class Negotiator { * @param [availableCharsets] When provided, returns an array of preferred charsets * ordered by priority from a list of available charsets. */ - charsets(availableCharsets?: string[]): string[]; + charsets(availableCharsets?: readonly string[]): string[]; /** * Returns the most preferred encoding from the client. @@ -60,7 +60,7 @@ declare class Negotiator { * @param [availableEncodings] When provided, returns the most preferred encoding * from a list of available encodings. */ - encoding(availableEncodings?: string[]): string | undefined; + encoding(availableEncodings?: readonly string[]): string | undefined; /** * Returns an array of preferred encodings ordered by the client preference. @@ -68,11 +68,11 @@ declare class Negotiator { * @param [availableEncodings] When provided, returns an array of preferred encodings * ordered by priority from a list of available encodings. */ - encodings(availableEncodings?: string[]): string[]; + encodings(availableEncodings?: readonly string[]): string[]; } declare namespace Negotiator { interface Headers { - [key: string]: string | string[] | undefined; + readonly [key: string]: string | (readonly string[]) | undefined; } } diff --git a/types/negotiator/negotiator-tests.ts b/types/negotiator/negotiator-tests.ts index 731505aebeaaf8..77cd4a8d44f76c 100644 --- a/types/negotiator/negotiator-tests.ts +++ b/types/negotiator/negotiator-tests.ts @@ -9,11 +9,11 @@ const request = { "Accept-Charset": "utf-8, iso-8859-1;q=0.8, utf-7;q=0.2", "Accept-Encoding": "gzip, compress;q=0.2, identity;q=0.5", }, -}; +} as const; const negotiator = new Negotiator(request); -const availableMediaTypes = ["text/html", "text/plain", "application/json"]; +const availableMediaTypes = ["text/html", "text/plain", "application/json"] as const; // $ExpectType string[] negotiator.mediaTypes(); negotiator.mediaTypes(availableMediaTypes); @@ -21,7 +21,7 @@ negotiator.mediaTypes(availableMediaTypes); negotiator.mediaType(); negotiator.mediaType(availableMediaTypes); -const availableLanguages = ["en", "es", "fr"]; +const availableLanguages = ["en", "es", "fr"] as const; // $ExpectType string[] negotiator.languages(); negotiator.languages(availableLanguages); @@ -29,7 +29,7 @@ negotiator.languages(availableLanguages); negotiator.language(); negotiator.language(availableLanguages); -const availableCharsets = ["utf-8", "iso-8859-1", "iso-8859-5"]; +const availableCharsets = ["utf-8", "iso-8859-1", "iso-8859-5"] as const; // $ExpectType string[] negotiator.charsets(); negotiator.charsets(availableCharsets); @@ -37,7 +37,7 @@ negotiator.charsets(availableCharsets); negotiator.charset(); negotiator.charset(availableCharsets); -const availableEncodings = ["identity", "gzip"]; +const availableEncodings = ["identity", "gzip"] as const; // $ExpectType string[] negotiator.encodings(); negotiator.encodings(availableEncodings);