TestUtils findRenderedComponentWithType fails to compile when Component defined
File package.json
:
"scripts":
"test": "tsc --project . --noEmit"
,
"dependencies":
"@types/react": "^16.7.6",
"@types/react-dom": "^16.0.9",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"typescript": "^3.1.6"
File tsconfig.json
:
"compilerOptions":
"lib": ["es2015", "dom"],
"target": "es2015",
"moduleResolution": "node",
"jsx": "react",
"strict": true
File test.tsx
:
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import * as TestUtils from 'react-dom/test-utils'
interface Props
a: number
class Component extends React.Component<Props>
render ()
return 'test'
const div = TestUtils.renderIntoDocument(
<div>
<Component a=1 />
</div>
) as React.Component
const component = TestUtils.findRenderedComponentWithType(div, Component)
Running tsc --project . --noEmit
results with the following error:
src/test.tsx:22:64 - error TS2345: Argument of type 'typeof Component' is not assignable to parameter of type 'ClassType<any, Component, ComponentClass<, any>>'.
Type 'typeof Component' is not assignable to type 'ComponentClass<, any>'.
Types of parameters 'props' and 'props' are incompatible.
Type '' is not assignable to type 'Readonly<Props>'.
Property 'a' is missing in type ''.
21 const component = TestUtils.findRenderedComponentWithType(div, Component)
~~~~~~~~~
Is this a bug? If I disable the --strict
option, or omit the <Props>
in Component<Props>
, it compiles successfully.
reactjs typescript typescript-typings react-tsx
add a comment |
File package.json
:
"scripts":
"test": "tsc --project . --noEmit"
,
"dependencies":
"@types/react": "^16.7.6",
"@types/react-dom": "^16.0.9",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"typescript": "^3.1.6"
File tsconfig.json
:
"compilerOptions":
"lib": ["es2015", "dom"],
"target": "es2015",
"moduleResolution": "node",
"jsx": "react",
"strict": true
File test.tsx
:
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import * as TestUtils from 'react-dom/test-utils'
interface Props
a: number
class Component extends React.Component<Props>
render ()
return 'test'
const div = TestUtils.renderIntoDocument(
<div>
<Component a=1 />
</div>
) as React.Component
const component = TestUtils.findRenderedComponentWithType(div, Component)
Running tsc --project . --noEmit
results with the following error:
src/test.tsx:22:64 - error TS2345: Argument of type 'typeof Component' is not assignable to parameter of type 'ClassType<any, Component, ComponentClass<, any>>'.
Type 'typeof Component' is not assignable to type 'ComponentClass<, any>'.
Types of parameters 'props' and 'props' are incompatible.
Type '' is not assignable to type 'Readonly<Props>'.
Property 'a' is missing in type ''.
21 const component = TestUtils.findRenderedComponentWithType(div, Component)
~~~~~~~~~
Is this a bug? If I disable the --strict
option, or omit the <Props>
in Component<Props>
, it compiles successfully.
reactjs typescript typescript-typings react-tsx
I'll call this a bug in thereact-dom
type declarations. I'm working on a fix.
– Matt McCutchen
Nov 14 '18 at 15:25
add a comment |
File package.json
:
"scripts":
"test": "tsc --project . --noEmit"
,
"dependencies":
"@types/react": "^16.7.6",
"@types/react-dom": "^16.0.9",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"typescript": "^3.1.6"
File tsconfig.json
:
"compilerOptions":
"lib": ["es2015", "dom"],
"target": "es2015",
"moduleResolution": "node",
"jsx": "react",
"strict": true
File test.tsx
:
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import * as TestUtils from 'react-dom/test-utils'
interface Props
a: number
class Component extends React.Component<Props>
render ()
return 'test'
const div = TestUtils.renderIntoDocument(
<div>
<Component a=1 />
</div>
) as React.Component
const component = TestUtils.findRenderedComponentWithType(div, Component)
Running tsc --project . --noEmit
results with the following error:
src/test.tsx:22:64 - error TS2345: Argument of type 'typeof Component' is not assignable to parameter of type 'ClassType<any, Component, ComponentClass<, any>>'.
Type 'typeof Component' is not assignable to type 'ComponentClass<, any>'.
Types of parameters 'props' and 'props' are incompatible.
Type '' is not assignable to type 'Readonly<Props>'.
Property 'a' is missing in type ''.
21 const component = TestUtils.findRenderedComponentWithType(div, Component)
~~~~~~~~~
Is this a bug? If I disable the --strict
option, or omit the <Props>
in Component<Props>
, it compiles successfully.
reactjs typescript typescript-typings react-tsx
File package.json
:
"scripts":
"test": "tsc --project . --noEmit"
,
"dependencies":
"@types/react": "^16.7.6",
"@types/react-dom": "^16.0.9",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"typescript": "^3.1.6"
File tsconfig.json
:
"compilerOptions":
"lib": ["es2015", "dom"],
"target": "es2015",
"moduleResolution": "node",
"jsx": "react",
"strict": true
File test.tsx
:
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import * as TestUtils from 'react-dom/test-utils'
interface Props
a: number
class Component extends React.Component<Props>
render ()
return 'test'
const div = TestUtils.renderIntoDocument(
<div>
<Component a=1 />
</div>
) as React.Component
const component = TestUtils.findRenderedComponentWithType(div, Component)
Running tsc --project . --noEmit
results with the following error:
src/test.tsx:22:64 - error TS2345: Argument of type 'typeof Component' is not assignable to parameter of type 'ClassType<any, Component, ComponentClass<, any>>'.
Type 'typeof Component' is not assignable to type 'ComponentClass<, any>'.
Types of parameters 'props' and 'props' are incompatible.
Type '' is not assignable to type 'Readonly<Props>'.
Property 'a' is missing in type ''.
21 const component = TestUtils.findRenderedComponentWithType(div, Component)
~~~~~~~~~
Is this a bug? If I disable the --strict
option, or omit the <Props>
in Component<Props>
, it compiles successfully.
reactjs typescript typescript-typings react-tsx
reactjs typescript typescript-typings react-tsx
asked Nov 14 '18 at 11:16
jeremijajeremija
1,3621121
1,3621121
I'll call this a bug in thereact-dom
type declarations. I'm working on a fix.
– Matt McCutchen
Nov 14 '18 at 15:25
add a comment |
I'll call this a bug in thereact-dom
type declarations. I'm working on a fix.
– Matt McCutchen
Nov 14 '18 at 15:25
I'll call this a bug in the
react-dom
type declarations. I'm working on a fix.– Matt McCutchen
Nov 14 '18 at 15:25
I'll call this a bug in the
react-dom
type declarations. I'm working on a fix.– Matt McCutchen
Nov 14 '18 at 15:25
add a comment |
1 Answer
1
active
oldest
votes
The react-dom
type declarations were not designed to work when the strictFunctionTypes
option is enabled. I have a change to fix the problem you saw and a few others related to strictFunctionTypes
. See this answer for the possible ways you can use my modified declarations until they get merged into DefinitelyTyped.
Appreciate your reply and good to know there will be a fix soon! Thanks!
– jeremija
Nov 15 '18 at 16:20
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298949%2ftestutils-findrenderedcomponentwithtype-fails-to-compile-when-componentprops-d%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The react-dom
type declarations were not designed to work when the strictFunctionTypes
option is enabled. I have a change to fix the problem you saw and a few others related to strictFunctionTypes
. See this answer for the possible ways you can use my modified declarations until they get merged into DefinitelyTyped.
Appreciate your reply and good to know there will be a fix soon! Thanks!
– jeremija
Nov 15 '18 at 16:20
add a comment |
The react-dom
type declarations were not designed to work when the strictFunctionTypes
option is enabled. I have a change to fix the problem you saw and a few others related to strictFunctionTypes
. See this answer for the possible ways you can use my modified declarations until they get merged into DefinitelyTyped.
Appreciate your reply and good to know there will be a fix soon! Thanks!
– jeremija
Nov 15 '18 at 16:20
add a comment |
The react-dom
type declarations were not designed to work when the strictFunctionTypes
option is enabled. I have a change to fix the problem you saw and a few others related to strictFunctionTypes
. See this answer for the possible ways you can use my modified declarations until they get merged into DefinitelyTyped.
The react-dom
type declarations were not designed to work when the strictFunctionTypes
option is enabled. I have a change to fix the problem you saw and a few others related to strictFunctionTypes
. See this answer for the possible ways you can use my modified declarations until they get merged into DefinitelyTyped.
edited Nov 22 '18 at 3:54
answered Nov 15 '18 at 2:39
Matt McCutchenMatt McCutchen
13.7k820
13.7k820
Appreciate your reply and good to know there will be a fix soon! Thanks!
– jeremija
Nov 15 '18 at 16:20
add a comment |
Appreciate your reply and good to know there will be a fix soon! Thanks!
– jeremija
Nov 15 '18 at 16:20
Appreciate your reply and good to know there will be a fix soon! Thanks!
– jeremija
Nov 15 '18 at 16:20
Appreciate your reply and good to know there will be a fix soon! Thanks!
– jeremija
Nov 15 '18 at 16:20
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53298949%2ftestutils-findrenderedcomponentwithtype-fails-to-compile-when-componentprops-d%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I'll call this a bug in the
react-dom
type declarations. I'm working on a fix.– Matt McCutchen
Nov 14 '18 at 15:25