-
-
Notifications
You must be signed in to change notification settings - Fork 163
Open
Description
Describe the bug
When trying to use P.instanceOf(Text) with isMatching, TypeScript raises a type error.
Minimal reproduction
import { isMatching, P } from 'ts-pattern';
isMatching(P.instanceOf(Text), document.createTextNode('123'));Error message
Argument of type 'Chainable<GuardP<unknown, Text>>' is not assignable to parameter of type 'KnownPattern<Text> & UnknownProperties'.
Type 'Chainable<GuardP<unknown, Text>>' is not assignable to type '{ readonly length?: KnownPattern<number> | undefined; readonly normalize?: KnownPattern<() => void> | undefined; readonly wholeText?: KnownPattern<string> | undefined; ... 62 more ...; readonly assignedSlot?: KnownPattern<...> | undefined; } & UnknownProperties'.
Type 'Chainable<GuardP<unknown, Text>>' is not assignable to type 'UnknownProperties'.
Index signature for type 'string' is missing in type 'Matcher<unknown, Text, "default", None, Text> & Omit<{ optional<input>(): Chainable<OptionalP<input, GuardP<unknown, Text>>, "optional">; and<input, const p2 extends Pattern<...>>(pattern: p2): Chainable<...>; or<input, const p2 extends Pattern<...>>(pattern: p2): Chainable<...>; select<input>(): Chainable<...>; sel...'.(2345)
Expected behavior
isMatching(P.instanceOf(Text), document.createTextNode('123')) should compile and return true.
TypeScript playground with a minimal reproduction case
Versions
- TypeScript version: 5.9.3
- ts-pattern version: 5.9.0
- environment: node 22.12.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels