Skip to content

Commit

Permalink
Add type test for current behavoir (keys from bind excluded from fina…
Browse files Browse the repository at this point in the history
…l props)
  • Loading branch information
AlexandrHoroshih committed Feb 9, 2024
1 parent 60f5c02 commit 6389515
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions type-tests/types-reflect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,36 @@ import { expectType } from 'tsd';
expectType<React.FC>(AppFixed);
}

// reflect should exclude "binded" props from the final component props
{
const Input: React.FC<{
value: string;
onChange: (newValue: string) => void;
color: 'red';
}> = () => null;
const $value = createStore<string>('');
const changed = createEvent<string>();

const ReflectedInput = reflect({
view: Input,
bind: {
value: $value,
onChange: changed,
},
});

const App: React.FC = () => {
// @ts-expect-error
return <ReflectedInput value="kek" color="red" />;
};

const AppFixed: React.FC = () => {
return <ReflectedInput color="red" />;
};
expectType<React.FC>(App);
expectType<React.FC>(AppFixed);
}

// reflect should allow to pass EventCallable<void> as click event handler
{
const Button: React.FC<{
Expand Down

0 comments on commit 6389515

Please sign in to comment.