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

Fix AnyComponent with ComponentConstructor #1249

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/preact.d.ts
Expand Up @@ -69,7 +69,7 @@ declare namespace preact {
}

// Type alias for a component considered generally, whether stateless or stateful.
type AnyComponent<P = {}, S = {}> = FunctionalComponent<P> | Component<P, S>;
type AnyComponent<P = {}, S = {}> = FunctionalComponent<P> | ComponentConstructor<P, S>;

interface Component<P = {}, S = {}> {
componentWillMount?(): void;
Expand Down
4 changes: 4 additions & 0 deletions test/ts/VNode-test.tsx
Expand Up @@ -5,6 +5,7 @@ import {
Component,
FunctionalComponent,
ComponentConstructor,
AnyComponent
} from "../../src/preact";

class SimpleComponent extends Component<{}, {}> {
Expand All @@ -17,6 +18,9 @@ class SimpleComponent extends Component<{}, {}> {

const SimpleFunctionalComponent = () => <div />;

const a: AnyComponent = SimpleComponent;
const b: AnyComponent = SimpleFunctionalComponent;

describe("VNode", () => {
it("is returned by h", () => {
const actual = <div className="wow"/>;
Expand Down