-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Autocomplete/Intellisense Does Not Show All Options For Object Value #17127
Comments
Here's the tsserver completions response:
|
@mjbvz Got it. Thanks for confirming this is Typescript related. |
Unfortunately, this would be hard to fix in general. When we get completions for a string literal directly inside a call expression, we have specialized code to iterate over every possible overload and get all string literals. But when we get completions inside a string literal at an arbitrary location, we just call
To fix this in general would seem to require writing a |
@andy-ms Thanks for taking a look at this. If this isn't something that's going to be looked at in the near future is there an approach you could recommend as a work around? Right now I am having to choose between putting all the fruit types in the one |
@JonnyBoy333 I would recommend preferring correct types and no autocomplete over autocomplete and incorrect types, but that's just my opinion :P interface RoundFruit {
fruit: "apple" | "orange"
}
interface CurvedFruit {
fruit: "banana"
}
function getFruitColor(fruit: RoundFruit): string;
function getFruitColor(fruit: CurvedFruit): boolean;
const options: RoundFruit = { fruit: "/*completions!*/" };
getFruitColor(options); |
I think this belongs to the same problem @andy-ms described above:
And for this, you don't get any suggestions:
Do you have any suggestions how to fix this or do I have to live with that for now? |
@wehrstedt You should be getting syntax errors there. You probably meant |
Yep, sorry. I worte this piece of code in the comment field. But the issue is still the same. Any suggestions? |
It's working for me if |
unfortunately not.But I will try to complete the example: This is my dts file:
I found out something interesting:
and hit CTRL + Space between the quotation marks in a typescript file, the code completion works. When I try the same in a js file, the code completion doesn't work. This is probably the reason why the example above works for you. I'm developing javascript, not typescript. And for code completion I write some typescript definition files. Is this behaviour correct? |
@wehrstedt You probably don't have both files included in the same project. If I use this tsconfig.json: {
"compilerOptions": {
"module": "commonjs",
"noEmit": true,
"allowJs": true,
"checkJs": true
}
} then I can get types from a |
From @JonnyBoy333 on July 12, 2017 15:31
Autocomplete/intellisense is not showing all the options for an object that goes into a function parameter even though it is defined in a typescript interface.
Example:
It appears that only the first method's options object is getting indexed by VS autocomplete but not the second one.
Reproduces without extensions: Yes
Copied from original issue: microsoft/vscode#30526
The text was updated successfully, but these errors were encountered: