Skip to content

Add @tsconfig/strictest - #88

Merged
orta merged 3 commits into
tsconfig:mainfrom
jonahsnider:strictest
Feb 4, 2022
Merged

orta merged 3 commits into
tsconfig:mainfrom
jonahsnider:strictest

Conversation

@jonahsnider

Copy link
Copy Markdown
Contributor

Closes #68


Not sure if noPropertyAccessFromIndexSignature, noEmitOnError, or checkJs should be included as they probably cause more problems than they solve.

@orta

orta commented Feb 3, 2022

Copy link
Copy Markdown
Member

Yeah, I think I'd drop noEmitOnError (in part because so many people don't use TS to emit, and it's probably not worth the hassle )

I think noPropertyAccessFromIndexSignature is worth keeping 👍🏻 its strictest even if pretty pedantic about how useful it really is

And lets keep checkJs - it still requires a user to opt in via allowJS

@jonahsnider

Copy link
Copy Markdown
Contributor Author

Yeah, I think I'd drop noEmitOnError (in part because so many people don't use TS to emit, and it's probably not worth the hassle )

That's a great point - I've removed noEmitOnError from the config.

@orta
orta merged commit 49b3f72 into tsconfig:main Feb 4, 2022
@jonahsnider
jonahsnider deleted the strictest branch February 4, 2022 08:26
@devinrhode2

devinrhode2 commented Feb 4, 2022 •

Copy link
Copy Markdown

Principles vs practicality

I think allowJs+checkJs: true is absolutely stricter.

I would imagine this config is not concerned with practicality - give me the strictest settings and I'll disable things as I go along. Same reasoning for noPropertyAccessFromIndexSignature I believe also applies to checkJs+allowJs

On a personal note, I've founds "jsdoc typescript" to be a wonderful learning experience. Good for low-level JavaScript, config files, node scripts

@devinrhode2

Copy link
Copy Markdown

Any chance of adding allowJs+checkJs: true to this??

@devinrhode2

devinrhode2 commented Apr 6, 2022 •

Copy link
Copy Markdown

If we want to be slightly less strict to improve DX, shouldn't we have allowJs: true, and then developers can opt-in on a file-by-file basis by adding // @ts-check to the top of their .js files?

(But really, is opting into type-checking on each js file the "strictest" config? no.)

@orta

orta commented Apr 6, 2022

Copy link
Copy Markdown
Member

No, I think it would be quite surprising to check type check JS files because you added a base which is about strictness

@devinrhode2

Copy link
Copy Markdown

Shouldn’t the options be flipped though, allowJs: true and checkJs undefined?

@devinrhode2

Copy link
Copy Markdown

That way devs can add // @ts-check to the js files they want to check

bear in mind, developers still need to tell typescript to take their js files into consideration via included or files config

@devinrhode2

devinrhode2 commented Apr 8, 2022 •

Copy link
Copy Markdown

Mostly unrelated bug... but I'm hacking on a node package, pino-applicationinsights, and allowJs: true in either my root tsconfig.json or in node_modules/@tsconfig/node16-strictest/tsconfig.json does nothing. I have to pass in the cli flag --allowJs, otherwise I get this error:

error TS6504: File 'src/**/*.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
  The file is in the program because:
    Root file specified for compilation

tsc v4.6.3 (latest stable)

Note: I'm doing npm run generate-type-defs with "scripts": "tsc --pretty --allowJs

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.

Add @tsconfig/strictest

3 participants