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

Allow 'verbatimModuleSyntax' with transpileModule #53240

Merged
merged 4 commits into from Mar 14, 2023

Conversation

rbuckton
Copy link
Member

Since --verbatimModuleSyntax implies --isolatedModules, it should be allowed in conjunction with transpileModule. However, when both options are specified an error is reported, and transpileModule always explicitly sets isolatedModules with no way to unset the option.

This changes transpileModule to skip any potential redudndant flags when setting defaults for transpileModule.

Fixes #53160

@fatcerberus
Copy link

However, when both options are specified an error is reported

I feel like the error should only be reported for verbatimModuleSyntax: true, isolatedModules: false. This error probably also breaks cases where a base config uses isolatedModules and then something extends it with verbatimModuleSyntax

@rbuckton
Copy link
Member Author

However, when both options are specified an error is reported

I feel like the error should only be reported for verbatimModuleSyntax: true, isolatedModules: false. This error probably also breaks cases where a base config uses isolatedModules and then something extends it with verbatimModuleSyntax

extends is related to tsconfig.json/tsc, so while your comment may be valid it might be better addressed in a separate issue. transpileModule is a language service API and has little to do with extends.

@fatcerberus
Copy link

Yeah, that second sentence was just me musing. The point was the first sentence. Having both verbatimModuleSyntax and isolatedModules set is not contradictory so probably shouldn't be an error at all (in which case this PR would be unnecessary).

@DanielRosenwasser
Copy link
Member

Yes, it feels like there's not exactly a ton of "harm" - you can set checkJs with allowJs too, though checkJs didn't also imply allowJS previously.

@DanielRosenwasser
Copy link
Member

Does anyone have any idea why we're getting all these target=ES3 issues in the tests?

@jakebailey
Copy link
Member

Probably some unit test default still set to ES3?

@jakebailey
Copy link
Member

Probably some unit test default still set to ES3?

Yep, in the test's transpilesCorrectly:

            if (transpileOptions.compilerOptions.target === undefined) {
                transpileOptions.compilerOptions.target = ts.ScriptTarget.ES3;
            }

That probably should have been changed when we changed the default, or something. Hard to say when some tests surely tested things about ES3 support, but, we're not going to change that.

Anyway, probably too late to change this as it'd break cherry-picks.

@DanielRosenwasser
Copy link
Member

I don't understand, why didn't all these tests break before?

@jakebailey
Copy link
Member

jakebailey commented Mar 14, 2023

They did, this PR just adds another column to the settings matrix: https://github.com/microsoft/TypeScript/pull/53240/files#diff-15a7ae1852c1cd6c50a9bf7a2453379ef7fce45691dabc656f157272069782b3R94

And then all of the tests below being updated to test that.

@DanielRosenwasser
Copy link
Member

@typescript-bot cherry-pick this to release-5.0 and LKG

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 14, 2023

Heya @DanielRosenwasser, I've started to run the task to cherry-pick this into release-5.0 on this PR at ff7b1de. You can monitor the build here.

Comment on lines +48 to +49
"preserveValueImports",
"importsNotUsedAsValues"
Copy link
Member

Choose a reason for hiding this comment

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

I don't think either of these can actually show up in transpileOptionValueCompilerOptions because neither explicitly set transpileOptionValue. But, I guess it's harmless if we want this PR in ASAP.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added them just to be on the safe side, since it would be fairly easy to miss if we made any changes in compilerOptions.

@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, I've opened #53253 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Mar 14, 2023
Component commits:
d83a0d7 Allow 'verbatimModuleSyntax' with transpileModule

ff7b1de Update src/services/transpile.ts
…rosoft/TypeScript into transpileModule-verbatimModuleSyntax
@DanielRosenwasser DanielRosenwasser merged commit ae1b3db into main Mar 14, 2023
19 checks passed
@DanielRosenwasser DanielRosenwasser deleted the transpileModule-verbatimModuleSyntax branch March 14, 2023 20:03
DanielRosenwasser added a commit that referenced this pull request Mar 14, 2023
…e-5.0 (#53253)

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
Co-authored-by: typescript-bot <typescript@microsoft.com>
drivron pushed a commit to scenari/typescript that referenced this pull request Sep 14, 2023
…to release-5.0 (microsoft#53253)

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
Co-authored-by: typescript-bot <typescript@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5.x.x: transpileModule fails with TS5104 error when verbatimModuleSyntax: true
6 participants