https://www.typescriptlang.org/play/index.html?ssl=6&ssc=40&pln=6&pc=32#code/C4TwDgpgBAKgwgewHYDMCWBzKBeKBvAXwChRJYAxBAJwFsBDYACTqQBMAbCKgHhhygCuSANZIEAdyQA+fgAoAbnXYCIALlgAaKAGNk6DOvh7MAShwyYRIgHprUQCIggYRBAvCCAuEEBiIIA4QTw8B8IIAEQQB4QQAYQQCEQT39fQCYQYOdPQHkQIl0kAGdgKFYESloGQ2z6JhYOLjlFZQgtZP0zbBkAZWAqNCQMBSUVEyTkNIys6gKAJjz+hmY2TipS9oqdYwwamQA5ARoAIy428s6bO1JoAEEkEDHiydwYfNGiie40ppapK2SesAFgRFRMAEkkciR+bgAVSgEAAHsAIGwUhQRoVxlwpLIqphDB99JUlOxVnRtMJ1ICFlBZEQoFAyip1AAFOhUOg0CAQqgpXiXOGnKQAbQADABdIiE7SY7G4zYqSpzba2KChRyhKCAfhBIq5PIAWEEA0iAxQByIFBXL5nPZPIBmECgPiczi82vsARC4UiMTi8SggHEQUK+QCMIGqFb5ANwgvkAbCCeUKAGRAdXqDcaolBAOwgwUCatcsU8gFYQLqpdIoWEnCb8V7vOY-P6yPBQFIIenkNAQdisdQAIlrUAIWkyrMldk8gFEQKCBf1JuXOJOAQRBdd6g7qoB7gzsoHqfIrPHEQpq5VFB0mZyqFybpb5Qn717r9UatM5fNLPPKydNu725ZOQ-5glHnGrAqmehmcmyJgMc280d8vxIEWJZlhAFZVjWUD1o2zZ9F+AxtlAAB0qFWFKziONuMpyo4+4KpEg6uiag7yj6QZRtEYQhnh66Kr4yrqjEjquqO47khARCfgUWYbAAjFyglmFKfEaIJXJcZm1z8eJ4nCXYoniWJglEEAA
Можно попробовать перегрузками ну или поэкспериментировать с <T extends string | number>(value: T): T
https://www.typescriptlang.org/play/index.html#code/C4TwDgpgBAKgwgewHYDMCWBzKBeKBvAXwChRIoAxACRyjgEMAbBgIzoGMBrAHiQFcBbZhABOAGigBnYMLRIMAPgDcREuGgxyCYfzrBKdJABMGImvSatOPAULGTpsharIwAclp0M0ALwj6jJsJmjCzs3FIycuJ8giLyKqTQ5qFWAGriAEryNAAUAG6MvBAAXFDpUGzI6Bil8FWYAJQ42RnKRAD07VCAIiCAwiCAvCCAXCCAYiCAHCCjPYB8IIACIIA8IIAMIIBCIKPTk4BMIPP9o4DyIESVSFJQhgia2rq1pzp6BsamuPmFEOL71U3Y2QDKDnIPDEUNe2Qh2Ol10ACZau4zl5fP5bkF7gU-k8KvUMG9sq4bCJfv8VPtDmBeMBEKhMABJJDkJA0LjlLI5F6YWqk6rPEKWDilZKcumZeQYqA5IhQKBIoqlVJEQVsDlhXEopnolSdKCLXqLKCAfhBVoNRoAWEEA0iAbQByIFBBpN+t1RoBmECgEz6-TGZu6MwWy1WGy22yggHEQRaTQCMIIbtZNANwgk0AbCCjRaAGRBzZbrXa1lBAOwg81mhsGm1GgFYQQEHYBQFAeXRwwI0IkktGU6k5PCSBD8CDkNAQBiGUoAIi7UAI4hBpeAAI6XVGgFEQKCzKO5zX9XOAQRALWHYxaoMG46OoJaJjrRlsFibNWsF7nt-r9-a1ZNFpGzxarbbxP1JmrRlqxY8pzPNRv49N5lTfpDVmAtDhLM5rgCEQwUrYlWQpKkkHrRtm1bdtOygHs+wHE4hzBEdVQAOhIlUun6Xor3VTVejvbVVgXAN7QXLVw1jVN1iWeNaLPHVJj1I0Nh9AMVzXcUICICCrnLHEAEYAAZFKaVVZNERT5MkocZOEHIFPUpSoBUtTFOMjSgA я бы так сделал
Обсуждают сегодня