-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing React/JSX props not working in strict mode #42
Comments
A work-around would be to declare import * as React from 'react'
export interface MyProps {
prop1: string
prop2: number
}
export const MyComponent: React.FC<MyProps> // This one's fine
expectError(MyComponent({ foo: "bar" }))
// This one's also fine
expectError(MyComponent({ prop1: 1, prop2: 2 }))
// This one's also fine
expectError(MyComponent({ prop1: "hey", prop2: 1234, iShouldNotBe: "here" }))
// fixed
expectError(MyComponent({ prop1: "hello" }))
// also fixed
expectError(MyComponent({ prop2: 2})) |
It seems the errors I care about are explicitly suppressed here: Particularly, line 20 |
Sorry for the late reply. I looked into this and it turns out we had a test for this use case import {Component} from 'react';
interface UnicornProps {
unicorn: number;
rainbow: string;
}
export class Unicorn extends Component<UnicornProps> {} But not when working with The code block you referenced, namely Will release in the coming days. |
Released as 0.13.1 |
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:
The following tests fail but should work (they produce an error output, but it's different from what I guess
tsd
expects):Full reproduction, with
tsconfig.json
can be found herePlease let me know if I'm missing something/if there's a clear work-around. Thanks!
The text was updated successfully, but these errors were encountered: