Skip to content

[js_interop] Compile-time error if type argument of isA is a extension type on JS primitive #61243

@sgrekhov

Description

@sgrekhov

It is a compile-time error if a type argument of isA is an extension type on JS primitive type. Is this expected?

extension type MyAny(JSAny _) implements JSAny {}

extension type MyNumber(JSNumber _) implements JSNumber {}

extension type MyString(JSString _) implements JSString {}

extension type MyBoolean(JSBoolean _) implements JSBoolean {}

extension type MyBigInt(JSBigInt _) implements JSBigInt {}

extension type MySymbol(JSSymbol _) implements JSSymbol {}

extension type MyObject(JSObject _) implements JSObject {}

test(JSAny v) {
  v.isA<MyAny>(); // Ok
  v.isA<MyObject>(); // Ok
  v.isA<JSNumber>(); // Ok
  v.isA<MyNumber>(); // Error: Type argument 'MyNumber' wraps primitive JS type 'JSNumber', which is specially handled using 'typeof'.
...
}

The same error occurs for all other extensions on JS primitive types (MyString, MyBoolean etc). Is this expected? Please note that there is no error for JSNumber but there is for MyNumber.

cc @srujzs

Dart SDK version: 3.10.0-edge.fc16a52f2d5b2a60cb6b98da6ce21b8e8ea1ae40 (main) (Thu Jul 31 18:03:22 2025 -0700) on "linux_x64"

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-questionA question about expected behavior or functionalityweb-js-interopIssues that impact all js interop

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions