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

React: ease extension of FmlComponentProps<Value> #16

Open
evanbb opened this issue Dec 31, 2022 · 0 comments
Open

React: ease extension of FmlComponentProps<Value> #16

evanbb opened this issue Dec 31, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@evanbb
Copy link
Owner

evanbb commented Dec 31, 2022

Types aren't defined to easily reflect how FmlComponent implementation configs can be extended.

As it stands right now, the extra props are mixed into props.config, like this:

declare module '@fml/core' {
  export interface FmlFieldControlRegistry<TValue>
    extends Record<string, FmlFieldControlRegistration<unknown>> {
    customImpl: [string | undefined, { stuff: boolean }];
  }
}

function CustomImpl(props) {
  console.log(props) // { config: { stuff: false, ...rest } }
}

but the interface makes it seem like it should add extra props to... well, y'know, the PROPS, like this:

interface CustomProps extends FmlComponentProps<string | undefined> {
  stuff: boolean;
}

function CustomImpl(props: CustomProps) {
  const {
    config,
    stuff // this doesn't actually exist, but the types make it seem like it ought to 😭 
  } = props
}

Let's add another generic argument for extra props to FmlComponentProps:

interface FmlComponentProps<Value, ExtraConfig extends never = never> {
  config: FmlConfiguration<TValue> & ExtraConfig;
}
@evanbb evanbb added documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed and removed documentation Improvements or additions to documentation labels Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant