-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: use import type
syntax
#17864
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
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 |
import type
syntax across entire repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@lmiller1990 Seems to be quite a bit of failures in this branch. Could you look into those? |
@jennifer-shehane actually just reporter is failing, I think the rest is flake -- gimme an hour. Thanks for the quick response. |
@jennifer-shehane 1 hour has passed, as promised we are all green ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great work, thanks for doing this @lmiller1990!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, let's merge as-is and revisit for any other packages it's missing on (reporter, ui-components, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL about import type
. Not sure what's up with semantic commit/percy checks...
import type
syntax across entire repoimport type
syntax
…p-gui-gql-stitching * unified-desktop-gui: fix: rename testApolloClient -> testUrqlClient, add apollo.config.js (#17948) feat(launchpad): detect if runner is set up and change UI accordingly (#17934) rebuild yarn lock chore: remove skipLibCheck, re-add vue-tsc, fix types (#17924) fix: ensure @headlessui/vue is bundled chore(graphql): make tsconfig more strict (#17909) run vite during watch fix: source maps while developing electron rebuild schema w/o JS files make constant more generic remove hanging tests allow larger artifacts comment out flaky test fix typing errors make graphql tsconfig more minimal chore: use `import type` syntax (#17864) remove browser-specific `beforeinput` checks (send in firefox) (#17820) fix(types): Update title method options type (#17781) fix(deps): update dependency @cypress/request to v2.88.6 🌟 (#17813)
User facing changelog
Additional details
I added the
importsNotUsedAsValues
rule to ourts/tsconfig.json
. This enforces than type-only imports be written using the newimport type
syntax. Read about that rule here.The reason this is useful is a lot of the newer ESM based build tools, like Vite, sometimes have problems trying to import types from TypeScript code designed to be used on the server. It will help future proof us.
For example in the unified feature branch ("launchpad"), which is developed using Vite, I may want to import an interface from
server/lib/project-base.ts
. That file also imports some Node.js only modules, likefs
. If you doimport { ProjectBase } from '@packages/server/lib/project-base.ts
, it will error out, since Vite attempts to import the entire file to the browser, including the Node.js-only modules, likefs
.`import type { ProjectBase } from '...' works correctly - Vite is able to extract the type, and ignore the actual implementation code. No side effects 😎
Another potential benefit is the TS compiler can likely do some optimizations if it just importing a file for type definitions, not actual runtime code.
There's no real downside to the new
import type
syntax, so I just went ahead and added it to the entire code base. VS Code can even automatically do the correct import for you, since we have the rule intsconfig.json
.How has the user experience changed?
N/A
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?