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

Verify that files are .ts/.tsx before treating as Typescript files. #7955

Merged
merged 4 commits into from May 23, 2018

Conversation

loganfsmyth
Copy link
Member

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change? Y
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR
Any Dependency Changes?
License MIT

I think this is mergeable, but I'm also very interested to hear what people would think of this approach.

This PR makes means:

  • For preset-typescript, it needs to be used in a context where Babel is given a filename, so it will error if called without a filename.
    • BUT if there is no filename, the user could set allExtensions: true to force-enable TS parsing without extensions taken into account. Then they could set isTSX: true to parse with JSX.
  • For plugin-typescript, when enabled things will automatically be parsed as .ts, with the isTSX: true option to enable parsing as .tsx.

This essentially means that the preset tries to auto-configure the plugin based on the file path.

We could also consider making the preset always expect a filename (delete allExtensions), and just tell people to use the plugin if there is no filename.

@loganfsmyth loganfsmyth added the PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release label May 17, 2018
@loganfsmyth loganfsmyth force-pushed the typescript-filename-required branch from 55a9a39 to 762a687 Compare May 17, 2018 01:53
@babel-bot
Copy link
Collaborator

babel-bot commented May 17, 2018

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8122/

@loganfsmyth loganfsmyth force-pushed the typescript-filename-required branch from 762a687 to 43aa61d Compare May 22, 2018 01:39
throw new Error(".allExtensions must be a boolean, or undefined");
}
if (typeof isTSX !== "boolean") {
throw new Error(".allExtensions must be a boolean, or undefined");
Copy link
Member

Choose a reason for hiding this comment

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

typo 🙊

Copy link
Member

Choose a reason for hiding this comment

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

Has been changed 06e5c46

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants