Skip to content

Less-than comparison raising error with JSX #11081

@pablonete

Description

@pablonete

TypeScript Version: 2.0.3

Code

// Next is line 241
export class ShortDetails extends React.Component<{ id: number }, {}> {
    public render(): JSX.Element {
        if (this.props.id < 1) {
            return (<div></div>);
        }
    }
}

Expected behavior:
It should compile well. Many variations to the code would avoid the errors, like:

  • Compact into <div/>
  • Replace < 1 by <= 0

Actual behavior:

Scripts/Components/Details.tsx(243,30): error TS1005: ',' expected.
Scripts/Components/Details.tsx(244,21): error TS1138: Parameter declaration expected.
Scripts/Components/Details.tsx(244,26): error TS1005: '(' expected.
Scripts/Components/Details.tsx(244,28): error TS1131: Property or signature expected.
Scripts/Components/Details.tsx(244,32): error TS1005: '(' expected.
Scripts/Components/Details.tsx(244,33): error TS1005: ')' expected.
Scripts/Components/Details.tsx(247,1): error TS1128: Declaration or statement expected.

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