-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorHelp WantedYou can do thisYou can do this
Milestone
Description
Using properties in tsx components whos typing is a literal string, number, or union, results in all of those values being added to the top of autocomplete suggestions.
Code sandbox example: https://codesandbox.io/s/tsx-props-union-type-autocomplete-bug-z740bd?file=/src/App.tsx
Code:
interface CompBProps {
name?: string;
propA?: "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
}
const CompB = (props: CompBProps) => <div />;
export default function CompA() {
return <CompB propA="1" />;
}Autocomplete works as expected if triggered before the prop:
If triggered after any props with literal types, all of those values are included in the autocomplete (and actually selecting any of these suggestions results in broken code).
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.78.0-insider and 1.77.3
- OS Version: OSX 13.1
Steps to Reproduce:
- Create a
.tsxfile (I have tested in react and solidjs projects, doesn't seem to matter) - Define a component (CompA) that accepts a prop (propA) that is a string or number literal (or union type)
- In a separate component (CompB), use (CompA). Note that before adding (propA), the autocomplete suggestions work as expected.
- Set (propA), note now how triggering autocomplete after (propA) includes all of the possible values from (propA). Triggering autocomplete before (propA) still works as expected.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorHelp WantedYou can do thisYou can do this

