Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Add more typescript option validation #52

Merged
merged 8 commits into from
May 21, 2020

Conversation

chrisbreiding
Copy link
Collaborator

Adds more validation for the typescript option.

If you pass the a non-string for the typescript option, you'll get the following error:

Error running @cypress/browserify-preprocessor:

The 'typescript' option must be a string. You passed: {}

If you pass the a path for the typescript option but nothing exists at that path, you'll get the following error:

Error running @cypress/browserify-preprocessor:

The 'typescript' option must be a valid path to your TypeScript installation. We could not find anything at the following path: /does/not/exist/typescript.js

If you try to preprocess a .ts or .tsx file, but don't have the typescript option set, you'll get the following error:

Error running @cypress/browserify-preprocessor:

You are attempting to preprocess a TypeScript file, but do not have TypeScript configured. Pass the 'typescript' option to enable TypeScript support.

The file: /path/to/cypress/integration/foo_spec.ts`

For the last one, I'm planning to add special handling in Cypress itself. Since we try to set the typescript option for the user, it's opaque when we can't find it but still carry on and try to run TypeScript specs. The user didn't set up the preprocessor themselves, so they can't exactly fix the issue themselves. Instead, when Cypress is handling the preprocessor and encounters this error, it will have a more tailored error message.

causes double formatting and certain rules to be applied incorrectly if the user’s ‘global’ vscode settings also have `formatOnSave` turned on
going to start using async/await, which requires Node.js 7.6+, so we’ll require the next stable version (8) or greater
Copy link
Contributor

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

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

Good, better errors are super nice

@chrisbreiding chrisbreiding merged commit 0b94fc5 into master May 21, 2020
@chrisbreiding
Copy link
Collaborator Author

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
2 participants