Skip to content

Missing React/JSX props not working in strict mode #42

Closed
@davidroeca

Description

@davidroeca

First off, thanks for the library! This is a very simple/clean way to test typescript definition files. I've come across a strange bug with React/JSX, and tried my best to replicate the issue. It mostly has to do with testing for missing (but required) react props.

Here's the type definition, for example:

import * as React from 'react'

export interface MyProps {
  prop1: string
  prop2: number
}

export const MyComponent: React.ComponentType<MyProps>

The following tests fail but should work (they produce an error output, but it's different from what I guess tsd expects):

// This one's broken
expectError(<MyComponent prop1="hello" />)

// This one too
expectError(<MyComponent prop2={2} />)

Full reproduction, with tsconfig.json can be found here

Please let me know if I'm missing something/if there's a clear work-around. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions