-
Notifications
You must be signed in to change notification settings - Fork 12.8k
autocomplete workaround for string literal inside template literal stopped working since v5.3.3
#57902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This one works today: type Foo = '/foo' | '/foo/:id' | (`/foo/${string}` & {})
const bar: Foo = '' It likely has changed in #56434 |
Would accept a (very) non-invasive/non-impactful PR to allow both workarounds to work |
What's the right tag for "PRs accepted but you'll likely have to be more clever than the entire TS team to figure it out"... |
cursed |
The |
I canβt get this to work in any version of TS. Hereβs the code in v5.7: Not only does it not appear in the list for auto complete - empty string is also not assignable to type |
It's not clear to me what your expected result is. Have you expected |
Sorry about that. I also just saw my expectation is a bit different from OPs, too. In my case, I have a list of strings (known api urls) that I would like to see in auto complete:
Currently, only |
You are looking for this then: #59794 |
I am in the exact same situation like Dom, my case looks a bit more like this though: type GlibGlob = {
[foo: `foo:${string}`]: string;
[barBaz: `bar:baz:${string}`]: string;
[barQux: `bar:qux:${string}`]: string;
} I know that this is a lame way to express hierarchal data, but unfortunately I don't get a choice. |
π Search Terms
string literal autocomplete template
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.3.3#code/C4TwDgpgBAYg9nKBeKByA9AMwaqAfNLBdALgEsATXAgAyLnQBIBvAZ2ACcyA7AcygBkUZgF8RNAFASAxnG7soAIwCGHEvEQpUqIA
π» Code
π Actual behavior
bar
only gives/foo
as a suggestion.π Expected behavior
bar
gives/foo
and/foo/:id
as a suggestion.Additional information about the issue
I understand that the autocomplete is a longer ongoing issue in combination with string literals. However there was a workaround described in (among other places): #29729
This workaround (
string & {}
) still works as long as it is not inside a template literal. But stopped working inside a template literal sincev5.3.3
.The text was updated successfully, but these errors were encountered: