#1506·type-fest

bug: Replace<> (when `${number}` is `Search`)

Author: salisbury-espinosaCreated Aug 18, 2026Updated Aug 18, 2026
Labelsbug

Bug description

typescript
import type {Replace} from 'type-fest';

'foo.(0|[1-9][0-9]*).bar.(0|[1-9][0-9]*).foo' satisfies Replace<
  `foo.${number}.bar.${number}.foo`,
  `${number}`,
  '(0|[1-9][0-9]*)',
  { all: true }
>;

==>

bash
Type '"foo.(0|[1-9][0-9]*).bar.(0|[1-9][0-9]*).foo"' does not satisfy the expected type '`foo.${number}.bar.${number}.foo`'.

Repro

https://www.typescriptlang.org/play/?ssl=8&ssc=3&pln=1&pc=1#code/JYWwDg9gTgLgBDAnmApnA3gJRWANgQwGMUBfOAMyghDgHIlUBaclAZxloG4BYAKD9rkIEAHQAKAAwAfANoBGRgE4AujIlLlAKgCUIgEb4o46fI1qNOkUIi04rfDGCtywNnGx4iKADx84cAANrEQASdAA7AFcQPRQoEn1DUIjo2PirYQCAGj9AsKiYuJJs3NpJWQUVcxUdWhzef3Q4fFxcAC4EKEi0Ej4APk4gA