Skip to content

[bug/jsx]: JSX missing intellisense for discriminant union props #25504

Closed
@Hotell

Description

@Hotell

TypeScript Version: 2.9.2. strict: true

Search Terms:
jsx discriminant unions, jsx unions

Following code works as expected, but intellisense won't work for additional union attributes ( foo / bar ) although if attribute is provided manually, intellisense works as expected (foo->blah OR wat )

Code

import React, { Component } from 'react'

type Props =
  | {
      type: 'foo'
      foo: 'blah' | 'wat'
    }
  | {
      type: 'bar'
      bar: string
    }
class Test extends Component<Props> {
  render() {
    return null
  }
}

const App = () => (
  <>
    {/* missing `foo` attribute intellisene, but works for literal values */}
    <Test type="foo" />;
    {/* missing `bar` attribute intellisene */}
    <Test type="bar" />
  </>
)

Expected behavior:

provide intellisense for supported union attributes

Actual behavior:

ts-jsx-discriminant-union-bug

Related Issues: #21427 #25503

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions