Skip to content

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

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

Open
qwerty2k opened this issue Sep 19, 2018 · 2 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@qwerty2k
Copy link

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

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Oct 1, 2018
@RyanCavanaugh RyanCavanaugh added this to the Future milestone Oct 1, 2018
@RyanCavanaugh
Copy link
Member

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

@weswigham
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants