Skip to content

JSX Not validating when index signature is present #10265

Closed
@bezreyhan

Description

@bezreyhan

TypeScript Version: 2.0

Code

interface IProps {
  primaryText: string,
  [propName: string]: any
}

function VerticalNavMenuItem(props: IProps) {
  return <div>props.primaryText</div>
}

function VerticalNav() {
  return (
    <div>
      <SOME_JSX />
      <VerticalNavMenuItem primaryText={2} />
    </div>
  )
} 

Expected behavior:
In VerticalNav I have the child component: <VerticalNavMenuItem primaryText={2} />
This should throw a type error because primary text must be a string.

However, if I remove [propName: string]: any from IProps then the type error will be thrown.

Actual behavior:
No error is thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JSX/TSXRelates to the JSX parser and emitterFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions