Skip to content

Visual Studio Code intellisense on React component using typescript with union types #27211

Closed as not planned

Description

@qwerty2k

3.0.3 also checked on 3.1.0-dev.20180919

typescript visual studio code union types intellisense

Code

interface IA { name: string }
interface IB extends IA { type: 'B'; myProp: string }
interface IC extends IA { type: 'C'; secondProp: string }

const MyComponent: React.SFC<IB | IC> = props => {
  return <span>test</span>
  }

class App extends React.Component {
  public render() {
    return (
      <MyComponent type='B' />
    );
  }
}

Expected behavior:
When rendering MyComponent if i set then i should get an autocomplete option for 'myProp'.

Actual behavior:

typescript_issue

no intellisense shown for 'myProp'. If i don't give a value for 'myProp' the compiler does error, but no intellisense autocomplete option is ever shown.

Related Issues:
i posted the issue generally on stackoverflow and a response was that it may be worth logging here and it may be related to bug: TypeScript issue #26004

Activity

  1. RyanCavanaugh commented on Oct 1, 2018

    @RyanCavanaugh
    Member

    Need to copy over/generalize the logic for completions of discriminated unions to the JSX props logic

  2. weswigham commented on Oct 1, 2018

    @weswigham
    Member

    #27408 maybe? Unless we also do something in services?

  3. RyanCavanaugh commented on Dec 3, 2025

    @RyanCavanaugh
    Member

    Closing language service bugs related to the 6.0 implementation. For more information, see #62827

  4. locked as resolved and limited conversation to collaborators on Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions