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

chore: update typescript #23523

Merged
merged 5 commits into from
Aug 24, 2022
Merged

chore: update typescript #23523

merged 5 commits into from
Aug 24, 2022

Conversation

ZachJW34
Copy link
Contributor

User facing changelog

n/a

Additional details

Update to latest version of typescript. Had to bump ts-loader as @packages/extension was failing with the new version of TS.

Steps to test

Counting on CI here, everything worked well locally.

How has the user experience changed?

na

PR Tasks

  • [na] Have tests been added/updated?
  • [na] Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 23, 2022

Thanks for taking the time to open a PR!

@@ -61,11 +61,9 @@ function getBundlerDependency (bundler: WizardBundler['type'], projectPath: stri
}
}

export const WIZARD_MOUNT_MODULES = ['cypress/react', 'cypress/react18', 'cypress/vue', 'cypress/vue2', 'cypress/angular'] as const
export type WizardMountModule = Awaited<ReturnType<typeof WIZARD_FRAMEWORKS[number]['mountModule']>>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example using the new Awaited utility type.

Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

Copy link
Contributor

Choose a reason for hiding this comment

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

For fun, if you do "go to definition" on Awaited you can see how they built it:

type Awaited<T> =
    T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode
        T extends object & { then(onfulfilled: infer F): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
            F extends ((value: infer V, ...args: any) => any) ? // if the argument to `then` is callable, extracts the first argument
                Awaited<V> : // recursively unwrap the value
                never : // the argument to `then` was not callable
        T; // non-object or non-thenable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤯 would take me a whole day to try and cook up something like that from scratch

Copy link
Contributor

Choose a reason for hiding this comment

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

It's quite cool, notice they use Awaited in the definition? Recursive types!

This is actually a great type to study... you can learn

  • extends
  • conditionals
  • infer
  • recursive types
  • never (equivalent of throw Error('this is impossible') for types

@cypress
Copy link

cypress bot commented Aug 23, 2022



Test summary

38946 0 4016 0Flakiness 0


Run details

Project cypress
Status Passed
Commit 7f20040
Started Aug 24, 2022 8:46 PM
Ended Aug 24, 2022 9:01 PM
Duration 14:07 💡
OS Linux Debian - 11.3
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@ZachJW34 ZachJW34 marked this pull request as ready for review August 23, 2022 19:55
Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

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

Nice, couple of minor improvements, won't block though.

packages/driver/src/dom/elements/nativeProps.ts Outdated Show resolved Hide resolved
packages/driver/src/dom/elements/nativeProps.ts Outdated Show resolved Hide resolved
packages/driver/src/dom/elements/nativeProps.ts Outdated Show resolved Hide resolved
@@ -61,11 +61,9 @@ function getBundlerDependency (bundler: WizardBundler['type'], projectPath: stri
}
}

export const WIZARD_MOUNT_MODULES = ['cypress/react', 'cypress/react18', 'cypress/vue', 'cypress/vue2', 'cypress/angular'] as const
export type WizardMountModule = Awaited<ReturnType<typeof WIZARD_FRAMEWORKS[number]['mountModule']>>
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

@@ -61,11 +61,9 @@ function getBundlerDependency (bundler: WizardBundler['type'], projectPath: stri
}
}

export const WIZARD_MOUNT_MODULES = ['cypress/react', 'cypress/react18', 'cypress/vue', 'cypress/vue2', 'cypress/angular'] as const
export type WizardMountModule = Awaited<ReturnType<typeof WIZARD_FRAMEWORKS[number]['mountModule']>>
Copy link
Contributor

Choose a reason for hiding this comment

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

For fun, if you do "go to definition" on Awaited you can see how they built it:

type Awaited<T> =
    T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode
        T extends object & { then(onfulfilled: infer F): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
            F extends ((value: infer V, ...args: any) => any) ? // if the argument to `then` is callable, extracts the first argument
                Awaited<V> : // recursively unwrap the value
                never : // the argument to `then` was not callable
        T; // non-object or non-thenable

ZachJW34 and others added 3 commits August 24, 2022 09:38
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
@emilyrohrbough
Copy link
Member

Should we go ahead and update the typescript versions in our system tests?

@ZachJW34
Copy link
Contributor Author

@emilyrohrbough I wouldn't want to update the system-tests since they were created to represent a project in a given state. For example, angular-13 has "typescript": "~4.6.2" and might not work with a bump. There are probably a few I could update but not sure if there is any improvement in doing so.

@emilyrohrbough
Copy link
Member

Gottchya 👍🏻 is there a strategy on knowing when it's appropriate to bumping these system-test dependencies for component testings? or not really?
I had assumed they were the version used when added and we just haven't necessarily been bumping deps due to other work

@ZachJW34
Copy link
Contributor Author

We don't have a strategy, but for component testing I'd say it would make sense to simply remove system tests once we drop support for that version, so if we drop angular@13 support or nuxt@2 then they should be deleted.

@lmiller1990 lmiller1990 merged commit 7ddcc96 into develop Aug 24, 2022
@lmiller1990 lmiller1990 deleted the zachw/update-typescript branch August 24, 2022 23:31
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

Successfully merging this pull request may close these issues.

3 participants