Skip to content

String.fromCharCodes() takes an u16[], but asc fails because of type mismatch #1609

Closed
@SebastianSpeitel

Description

@SebastianSpeitel

The typing for String.fromCharCodes() says:

static fromCharCodes(arr: u16[]): string;

and
static fromCharCodes(units: Array<i32>): String {

In VSCode the tooltip shows u16[], which is the one I would expect since strings are UTF-16.
But when trying to compile, it fails:

ERROR TS2322: Type '~lib/array/Array<u16>' is not assignable to type '~lib/array/Array<i32>'.

   return String.fromCharCodes(arr);
                               ~~~

Live example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions