Skip to content

Single-character template literal inference consumes a full code point in tsgo vs one UTF-16 code unit in tsc #4137

Description

Steps to reproduce

main.ts:

type Heads<S> = S extends `${infer C}${infer R}` ? [C, R] : never;
type A = Heads<"😀abc">;
declare let a: A;
const chk: ["😀", "abc"] = a;
tsgo main.ts

Behavior with typescript@6.0

main.ts(4,7): error TS2322: Type '["�", "�abc"]' is not assignable to type '["😀", "abc"]'.
  Type at position 0 in source is not compatible with type at position 0 in target.
    Type '"�"' is not assignable to type '"😀"'.

Behavior with tsgo

No error.

Metadata

Metadata

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