Skip to content

Commit

Permalink
Merge pull request #34 from kirillzyusko/feature/strictly-typed-optim…
Browse files Browse the repository at this point in the history
…ize-component

[RNBS-024] - strictly typed `optimized` component
  • Loading branch information
kirillzyusko authored Feb 7, 2022
2 parents b0e3ee6 + 65d50a7 commit 8141ce0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as React from 'react';

import optimized from './optimized';
import { mapLoadable } from './bundler';
import { Component, EnhancedPreLoadable, PreLoadable } from './interface';
Expand All @@ -11,7 +13,7 @@ const defaultPreLoadable: EnhancedPreLoadable = {

let i = 0;

const register = (component: PreLoadable & Partial<EnhancedPreLoadable>) => {
const register = <P extends {}>(component: PreLoadable & Partial<EnhancedPreLoadable>) => {
const enhancedComponent: Component = {
name: `Component${i++}`,
...defaultPreLoadable,
Expand All @@ -25,7 +27,7 @@ const register = (component: PreLoadable & Partial<EnhancedPreLoadable>) => {

mapLoadable[name] = enhancedComponent;

return optimized(name);
return optimized(name) as React.ComponentClass<P>;
};

const component = (name: string) => getComponent(name);
Expand Down

0 comments on commit 8141ce0

Please sign in to comment.