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

Fix ci due to floating deps #1450

Closed
wants to merge 1 commit into from
Closed

Conversation

NullVoxPopuli
Copy link
Sponsor Collaborator

@NullVoxPopuli NullVoxPopuli commented Jun 26, 2024

Unblocks: #1449
(takes a different approach from the above)

Resolves this problem on the main branch:

❯ yarn install --no-lockfile
❯ yarn lint:ts
yarn run v1.22.19
$ tsc --noEmit && tsc --noEmit --project type-tests
addon-test-support/@ember/test-helpers/dom/fill-in.ts:36:11 - error TS2345: Argument of type '() => Promise<HTMLInputElement | HTMLButtonElement | HTMLSelectElement | HTMLTextAreaElement> | Promise<...>' is not assignable to parameter of type '(value: void) => HTMLInputElement | HTMLButtonElement | HTMLSelectElement | HTMLTextAreaElement | PromiseLike<...>'.
  Type 'Promise<HTMLInputElement | HTMLButtonElement | HTMLSelectElement | HTMLTextAreaElement> | Promise<...>' is not assignable to type 'HTMLInputElement | HTMLButtonElement | HTMLSelectElement | HTMLTextAreaElement | PromiseLike<HTMLInputElement | HTMLButtonElement | HTMLSelectElement | HTMLTextAreaElement>'.
    Type 'Promise<HTMLElementContentEditable>' is not assignable to type 'HTMLInputElement | HTMLButtonElement | HTMLSelectElement | HTMLTextAreaElement | PromiseLike<HTMLInputElement | HTMLButtonElement | HTMLSelectElement | HTMLTextAreaElement>'.
      Type 'Promise<HTMLElementContentEditable>' is not assignable to type 'PromiseLike<HTMLInputElement | HTMLButtonElement | HTMLSelectElement | HTMLTextAreaElement>'.
        Types of property 'then' are incompatible.
          Type '<TResult1 = HTMLElementContentEditable, TResult2 = never>(onfulfilled?: ((value: HTMLElementContentEditable) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ... 1 more ... | undefined) => Promise<...>' is not assignable to type '<TResult1 = HTMLInputElement | HTMLButtonElement | HTMLSelectElement | HTMLTextAreaElement, TResult2 = never>(onfulfilled?: ((value: HTMLInputElement | ... 2 more ... | HTMLTextAreaElement) => TResult1 | PromiseLike<...>) | ... 1 more ... | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ......'.
            Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
              Types of parameters 'value' and 'value' are incompatible.
                Type 'HTMLElementContentEditable' is not assignable to type 'HTMLInputElement | HTMLButtonElement | HTMLSelectElement | HTMLTextAreaElement'.
                  Type 'HTMLElementContentEditable' is missing the following properties from type 'HTMLTextAreaElement': autocomplete, cols, defaultValue, dirName, and 26 more.

36     .then(() => {
             ~~~~~~~


Found 1 error in addon-test-support/@ember/test-helpers/dom/fill-in.ts:36

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

TS couldn't figure out how to type element with the promise chain, and fireEvent was being passed an element with invalid type -- with the refactor, it now narrows correctly, and element is appropriately narrowed for fireEvent

Copy link
Sponsor Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best viewed with these settings
image

@NullVoxPopuli
Copy link
Sponsor Collaborator Author

This is no longer needed, but at some point in the future, it may be worth swapping some promise chains for async/await as TS understands async/await a bit better

@NullVoxPopuli NullVoxPopuli deleted the fix-ci-due-to-floating-deps branch August 20, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants