Skip to content
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

When using allowJs, you are unable to use classes that do not extend a declared class without including its generic type arguments. #15087

Closed
joelday opened this issue Apr 8, 2017 · 2 comments

Comments

@joelday
Copy link
Contributor

joelday commented Apr 8, 2017

TypeScript Version: 2.2.2

In this specific scenario, allowJs is enabled and react.d.ts is available. The React typings declares Component<P, S>. In a JavaScript file, a class is defined that extends React.Component, but without the generic arguments.

Code
foo.js:

export class FooComponent extends React.Component {
  ...
}

bar.tsx:

import { FooComponent } from './foo'

...

<FooComponent />
or
const f = new FooComponent()

Expected behavior:
An ES6 class from './foo' that extends React.Component without generic arguments can be used in a .tsx file that imports it.

Actual behavior:
"[ts] Cannot use 'new' with an expression whose type lacks a call or construct signature." errors.

I think that this class should be automatically inferred to have extended React.Component<any, any>

@joelday joelday changed the title When using allowJs, you are unable to use classes that do not extend a class in compliance with the declared type. When using allowJs, you are unable to use classes that do not extend a declared class without including its generic type arguments. Apr 8, 2017
@jwbay
Copy link
Contributor

jwbay commented Apr 8, 2017

Seems like #14907 might resolve this

@joelday
Copy link
Contributor Author

joelday commented Apr 8, 2017

Dupe of #14881

@joelday joelday closed this as completed Apr 8, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants