question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could you reconsider the "tsconfig.json" default value of "strict: false"?

See original GitHub issue

Feature request

I just noticed that next.js defaults to strict: false in the generated tsconfig.json.

The reasoning behind seems to be (quoting @Timer from ##7716):

Users who are testing out Next.js’ TypeScript support shouldn’t be stuck behind a failure to compile screen. This will allow advanced users to opt into strict: true when they’re ready.

I would ask you if it were possible to reconsider this.

Running tsc --init creates a tsconfig.json with strict: true since that option was introduced with TypeScript 2.3. An advanced user will probably not notice this for quite some time, because they assume that TypeScript offers it’s full (default-configuration) functionality out of the box, just wondering about unsound behaviour here and there until it piles up and finally going to strict: true has actually become a chore.

If there are any strict options that are not working well with next.js, it’s still an option, to default to strict: true in combination with strictThatHurts: false and mentioning to that in the documentation.

I have to admit that I’m not even a next.js user myself (athough it is in my list of stuff to check out!), but got a report by a user of our library (@reduxjs/toolkit) about strange behaviour - which we could attribute back to strictNullChecks being disabled. The user was quite irritated because they had assumed that strict would be enabled.

So I don’t really believe that you’re doing your users a service with this default 😦

As an alternative, if you could not commit to a strict: true default, maybe it might be an option to actively ask the user for feedback on it when the tsconfig.json would be filled with the default values - and let the user decide between “loose” and “strict” behaviour?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
tanvp112commented, May 15, 2020

User assumption is not the responsibility of the framework, I supposed. Note typescript is not perfect, the trans-piled code sometimes can cause unexpected behavior, too.

I think the default should stay as false. User can change to true anytime as they see fit. Or better, checkout https://github.com/facebook/prop-types

1reaction
filipesmedeiroscommented, Dec 16, 2021

hey team, love the work. since a flag --typescript / -ts was added for the next-app cli, is there any chance this config should be changed to match that one? (that currently enforces strict by default)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could you reconsider the "tsconfig.json" default value of "strict ...
I just noticed that next.js defaults to strict: false in the generated tsconfig.json . The reasoning behind seems to be (quoting @Timer from...
Read more >
TSConfig Reference - Docs on every TSConfig option
Without this flag enabled, there are three values which you can set ... TypeScript will look for files starting at the same folder...
Read more >
How to configure react-script so that it doesn't override tsconfig ...
Basically, I'm trying to set up paths in tsconfig.json by adding these to the default tsconfig.json generated by create-react-app: "baseUrl": ".
Read more >
ts-node - npm
If no tsconfig.json is loaded from disk, ts-node will use the newest recommended defaults from @tsconfig/bases compatible with your node and ...
Read more >
Configuration | Manual - Deno
Option Default Notes allowJs true This almost never needs to be changed allowUnreachableCode false allowUnusedLabels false
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found