Skip to content

fix: set allowJs for checkJs - #218

Closed
TatsuyaYamamoto wants to merge 2 commits into
tsconfig:mainfrom
TatsuyaYamamoto:TatsuyaYamamoto-patch-1
Closed

TatsuyaYamamoto wants to merge 2 commits into
tsconfig:mainfrom
TatsuyaYamamoto:TatsuyaYamamoto-patch-1

Conversation

@TatsuyaYamamoto

Copy link
Copy Markdown
Contributor

Currently bases/strictest.json has checkJs: true, but doesn't have allowJs: true and checkJs doesn't work.

microsoft/TypeScript#21435 (comment)

--checkJs really means nothing without --allowJs

@orta

orta commented Sep 15, 2023

Copy link
Copy Markdown
Member

Yeah, I understand the tension here, but I think that including allowJs would be surprising for people.

Saying you want a stricter typescript environment shouldn't suddenly start expanding the scope of your project to include a bunch of files which are normally not included. I allowed checkJs because whenever you do choose to do that, by adding allowJs, you should have them checked

So thanks for the PR, but I'm afraid I'll politely decline

@orta orta closed this Sep 15, 2023
@TatsuyaYamamoto
TatsuyaYamamoto deleted the TatsuyaYamamoto-patch-1 branch January 20, 2024 14:23
@manbearwiz

manbearwiz commented Oct 16, 2025 •

Copy link
Copy Markdown
Contributor

Yeah, I understand the tension here, but I think that including allowJs would be surprising for people.

Saying you want a stricter typescript environment shouldn't suddenly start expanding the scope of your project to include a bunch of files which are normally not included. I allowed checkJs because whenever you do choose to do that, by adding allowJs, you should have them checked

@orta I agree that strictest shouldn't unexpectedly include JS files, but it looks like that's currently happening due to how TypeScript infers allowJs from checkJs.

When allowJs isn't explicitly set, it defaults to the value of checkJs. Since strictest enables checkJs and leaves allowJs undefined, it effectively sets allowJs: true.

I ran into this when using strictest with isolatedDeclarations: true, which throws:

Option 'allowJs' cannot be specified with option 'isolatedDeclarations'.

The relevant tsc code:

    allowJs: {
        dependencies: ["checkJs"],
        computeValue: compilerOptions => {
            return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs;
        },
    },

This behavior came from microsoft/TypeScript#40275, but it's only documented in the [4.1 release notes]((https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html#checkjs-implies-allowjs).

I plan to open a PR to remove checkJs from the strictest config and another in the TS repo to document this better.

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