Skip to content

Commit

Permalink
Merge pull request #1249 from scurker/typescript/any-component
Browse files Browse the repository at this point in the history
Fix AnyComponent with ComponentConstructor
  • Loading branch information
marvinhagemeister committed Nov 3, 2018
2 parents cd807ce + 42c92b6 commit b243a5e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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

0 comments on commit b243a5e

Please sign in to comment.