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

atom-families-2 - type errors #6

Open
ohaddahan opened this issue Jul 4, 2022 · 0 comments
Open

atom-families-2 - type errors #6

ohaddahan opened this issue Jul 4, 2022 · 0 comments

Comments

@ohaddahan
Copy link

Seems like recoil changes some API.

export const selectedElementProperties = selector<Element | undefined>({
    key: 'selectedElementProperties',
    get: ({get}) => {
        const selectedElementId = get(selectedElementState)
        if (!selectedElementId) return undefined;

        return get(elementState(selectedElementId));
    },
    set: ({get, set}, newElement) => {
        if (!newElement || newElement instanceof DefaultValue) return undefined;
        const selectedElementId = get(selectedElementState)
        if (!selectedElementId) return undefined;

        set(elementState(selectedElementId), newElement as Element);
    }
})

Error:

No overload matches this call.
  Overload 1 of 2, '(options: ReadWriteSelectorOptions<Element | undefined>): RecoilState<Element | undefined>', gave the following error.
    Type '({ get }: { get: GetRecoilValue; getCallback: GetCallback; }) => Element | undefined' is not assignable to type '(opts: { get: GetRecoilValue; getCallback: GetCallback; }) => Element | Promise<Element | undefined> | RecoilValueReadOnly<Element | undefined> | ... 5 more ... | undefined'.
      Type 'Element | undefined' is not assignable to type 'Element | Promise<Element | undefined> | RecoilValueReadOnly<Element | undefined> | RecoilState<Element | undefined> | ... 4 more ... | undefined'.
        Type 'Element' is not assignable to type 'Element | Promise<Element | undefined> | RecoilValueReadOnly<Element | undefined> | RecoilState<Element | undefined> | ... 4 more ... | undefined'.
          Property '[WrappedValue_OPAQUE]' is missing in type 'Element' but required in type 'WrappedValue<Element | undefined>'.
  Overload 2 of 2, '(options: ReadOnlySelectorOptions<Element | undefined>): RecoilValueReadOnly<Element | undefined>', gave the following error.
    Type '({ get }: { get: GetRecoilValue; getCallback: GetCallback; }) => Element | undefined' is not assignable to type '(opts: { get: GetRecoilValue; getCallback: GetCallback; }) => Element | Promise<Element | undefined> | RecoilValueReadOnly<Element | undefined> | ... 5 more ... | undefined'.  TS2769

     5 | export const selectedElementProperties = selector<Element | undefined>({
     6 |     key: 'selectedElementProperties',
  >  7 |     get: ({get}) => {
       |     ^
     8 |         const selectedElementId = get(selectedElementState)
     9 |         if (!selectedElementId) return undefined;
    10 |

Also error on the set(elementState(selectedElementId), newElement as Element);

image

Tried some online suggested solutions but none helped.

@ohaddahan ohaddahan changed the title https://learnrecoil.com/video/atom-families-2 atom-families-2 - type errors Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant