🔎 Search Terms
intersection template type never
🕗 Version & Regression Information
- I was unable to test this on prior versions than 4.5 because
// ^? does not work on typescript playground
I think this is bug since template literal type is introduced in 4.1.
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.8.0-dev.20241106#code/GYVwdgxgLglg9mABAQzATwBQEoBcL2IDeiUAFgE5wDuiYIANvQNyIC+AUOxAgM5QkBTPgFY8AAwC2MZCDIB6ACSE+5GGADmrORFICIAazGIAZIjFKVazXNgSB9NQKMBefJixN2cuYl++AegD8Xj5+ZDA8iDykcAwAJogARgK0AgBuAuRJsohxcEK0cFDsQA
💻 Code
functionany(): any{thrownull;}consttest5: `miauth/${string}/check` & `${string}/timeline` =any();// ^?// this should be never but does not🙁 Actual behavior
`miauth/${string}/check` & `${string}/timeline` will remain `miauth/${string}/check` & `${string}/timeline`
not coming never would cause problem with Indexed Access Types
functionany(): any{thrownull;}typeEndpoints={'test/timeline': 0,'test2/timeline': 0,'other endpoint': 2,[ep: `miauth/${string}/check`]: 1,// no error at test2 if comment}typeTimelineEndpoints=keyofEndpoints& `${string}/timeline`;consttest2: Endpoints[TimelineEndpoints]=any();consttest3: 0=test2;// This assignment should not have type errors,// but because `miauth/${string}/check` & `${string}/timeline` is not never,// test2 become 0|1 so we cannot assign test2 to test3.playground
🙂 Expected behavior
`miauth/${string}/check` & `${string}/timeline` should become never and Endpoints[TimelineEndpoints] in snippet above should become 0
Additional information about the issue
Of course, we cannot assign variable typed `miauth/${string}/check` to `${string}/timeline` and vice versa.
functionany(): any{thrownull;}consttest0: `miauth/${string}/check` =any();consttest1: `${string}/timeline` =test0;// error here, as expectedplayground
Real world case: misskey-dev/misskey#14885 (comment)
🔎 Search Terms
intersection template type never
🕗 Version & Regression Information
// ^?does not work on typescript playgroundI think this is bug since template literal type is introduced in 4.1.
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.8.0-dev.20241106#code/GYVwdgxgLglg9mABAQzATwBQEoBcL2IDeiUAFgE5wDuiYIANvQNyIC+AUOxAgM5QkBTPgFY8AAwC2MZCDIB6ACSE+5GGADmrORFICIAazGIAZIjFKVazXNgSB9NQKMBefJixN2cuYl++AegD8Xj5+ZDA8iDykcAwAJogARgK0AgBuAuRJsohxcEK0cFDsQA
💻 Code
🙁 Actual behavior
`miauth/${string}/check` & `${string}/timeline`will remain`miauth/${string}/check` & `${string}/timeline`not coming
neverwould cause problem with Indexed Access Typesplayground
🙂 Expected behavior
`miauth/${string}/check` & `${string}/timeline`should becomeneverandEndpoints[TimelineEndpoints]in snippet above should become 0Additional information about the issue
Of course, we cannot assign variable typed
`miauth/${string}/check`to`${string}/timeline`and vice versa.playground
Real world case: misskey-dev/misskey#14885 (comment)