TypeStrong / ts-loader

TypeScript loader for webpack
https://johnnyreilly.com/ts-loader-goes-webpack-5
MIT License
3.46k stars 431 forks source link

Error extending infered type in template string literal #1516

Closed nsz32 closed 2 years ago

nsz32 commented 2 years ago

First of all thanks for your great work.

Expected Behaviour

type IsKeyOfTarget<TARGET extends object, S extends string> = S extends `D-${infer K extends keyof TARGET & string}` ? K : null

This build well and works as intended with tsc and tslint.

Actual Behaviour

But it generates a build error with webpack (latest) & ts-node (latest) and without babel : TS1005: '?' expected error located at the end of the infer K extends keyof TARGET & string template block.

Note that this simplified version errors in the same manner :

type IsKeyOfTarget<TARGET extends object, S extends string> = S extends `D-${infer K extends string}` ? K : null

@ts-ignore nor @ts-nocheck does not seem to have any effect for this specific error.

Don't hesitate, if I can help.

nsz32 commented 2 years ago

options : ignoreDiagnostics helped me to keep my build process alive, so this is not blocking at the time, but it shows a deviation from tsc for shure.

nsz32 commented 2 years ago

My bad : i was using an old version of typescript in my project (package.json).