typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

checkJs default has changed in tsgo

Open issacgerges opened this issue 7 months ago • 7 comments

In the TypeScript Go implementation, checkJs now defaults to true, whereas it previously defaulted to false.

https://github.com/microsoft/typescript-go/blob/4764672ab5f048554d3fe7134aee1cec6bd85e1c/internal/core/compileroptions.go#L218

Wanted to call it out as I was unsure if this change was intentional

issacgerges avatar May 23 '25 21:05 issacgerges

I don't think that's what that code means; CheckJs is a tristate between true, false, and unset. If it's unset, that will evaluate to false. Also, the linked code is GetAllowJS, so this is about how allowJs behaves.

jakebailey avatar May 23 '25 21:05 jakebailey

Did you confuse options.CheckJs == TSTrue for options.CheckJs = TSTrue, an assignment?

jakebailey avatar May 23 '25 21:05 jakebailey

Sorry, I attributed the wrong line of code. I have a minimal repro that shows the default has changed. Will send it momentarily

issacgerges avatar May 23 '25 21:05 issacgerges

https://github.com/issacgerges/tsgo-checkjs/tree/main

Image

issacgerges avatar May 23 '25 21:05 issacgerges

Can you paste the result of tsgo --showConfig?

jakebailey avatar May 23 '25 21:05 jakebailey

{
    "allowJs": true,
    "incremental": true,
    "module": 99,
    "moduleResolution": 100,
    "noImplicitAny": true,
    "outDir": "/Users/igerges/source/tsgo-checkjs/.ts-out",
    "rootDir": "/Users/igerges/source/tsgo-checkjs",
    "configFilePath": "/Users/igerges/source/tsgo-checkjs/tsconfig.json",
    "showConfig": true
}

issacgerges avatar May 23 '25 21:05 issacgerges

Thanks, this is a bug.

jakebailey avatar May 23 '25 22:05 jakebailey

I'm seeing this behaviour too - our repo has allowJs set globally, but checkJs set on a per-file basis via comments, and running tsgo lists errors in a lot of JS files.

Let me know if there's any more information needed

glenjamin avatar May 28 '25 07:05 glenjamin

What errors are you seeing specifically? I believe I'll have fixed this in #930 when merged. You could build from that PR and check, too.

jakebailey avatar May 28 '25 16:05 jakebailey