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

Update tsconfig file to include .tsx files #2457

Merged
merged 2 commits into from
Nov 26, 2020
Merged

Update tsconfig file to include .tsx files #2457

merged 2 commits into from
Nov 26, 2020

Conversation

nina-py
Copy link
Contributor

@nina-py nina-py commented Nov 18, 2020

Refs #3533

Doesn't really fix the umbrella issue but is related to it.

Changes proposed in this pull request:
Change tsconfig.json so that project-specific configuration is taken into account not just for .ts files but for .tsx files as well. Removing the file extension makes TS default to processing just .ts, .tsx, and .d.ts. files.

Confirmed

  • Frontend changes: tested on a local Flarum installation.

Required changes:

  • Related documentation PR: (Remove if irrelevant)
  • Related core extension PRs: (Remove if irrelevant)

@dsevillamartin
Copy link
Member

I edited the description so the issue isn't closed if we merge this PR.

js/tsconfig.json Outdated
@@ -1,5 +1,5 @@
{
"include": ["src/**/*.ts"],
"include": ["src/**/*"],
Copy link
Member

Choose a reason for hiding this comment

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

This feels quite broad, essentially saying any file in src. Couldn't this cause files unrelated to JS/TS/TSX to be recognized incorrectly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@askvortsov1, according to the official documentation, this will actually do what we want it to do - parse only TypeScript files:

If a glob pattern doesn’t include a file extension, then only files with supported extensions are included (e.g. .ts, .tsx, and .d.ts by default, with .js and .jsx if allowJs is set to true).
https://www.typescriptlang.org/tsconfig#include

Since allowJs is not explicitly set to true, this change will mean that TS will go from parsing just .ts files to .ts, .tsx, and d.ts, ignoring JS files and anything else that may be present in those directories.

@nina-py
Copy link
Contributor Author

nina-py commented Nov 24, 2020

Thanks for approving this @askvortsov1. I was thinking that perhaps it would be better to set the files to parse explicitly instead of following the TS docs - that way this config value would essentially become self-documenting:

"include": ["src/**/*.ts", "src/**/*.tsx"],

@askvortsov1
Copy link
Member

Ah yes that's even better!

@nina-py
Copy link
Contributor Author

nina-py commented Nov 26, 2020

@askvortsov1 done!

@askvortsov1 askvortsov1 merged commit 286d8de into flarum:master Nov 26, 2020
@askvortsov1 askvortsov1 added this to the 0.1.0-beta.15 milestone Nov 26, 2020
@nina-py nina-py deleted the update-tsconfig-to-include-tsx branch November 27, 2020 09:34
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