Skip to content

TSX's render function doesn't fail when generic component is without generic type #26898

Closed
@sztrzask

Description

@sztrzask

TypeScript Version: 3.0.1

Search Terms: TSX, generics, required, jsx, typescript
I also read the jsx section in documentation.

Code

.tsx

import * as React from "react";

class Generics<T> extends React.Component {
  render() {
    return <span>Generics is rendered even though it's T is not defined</span>;
  }
}

export default () => (
  <h1>
    This should fail as Generics does not have a default type. <Generics />
  </h1>
);

Expected behavior:
The above code should fail during compilation.

Actual behavior:
The above code passes the compilation, even though the generic type is not provided and not defaulted

Playground Link:
https://codesandbox.io/s/4q15l927x

Related Issues:
#3960

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions