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

Error: "This rule requires the strictNullChecks compiler option to be turned on to function correctly @typescript-eslint/strict-boolean-expressions" #481

Closed
el-leonya opened this issue Nov 26, 2020 · 14 comments

Comments

@el-leonya
Copy link

Package version: 19.0.1
OS: Kubuntu 20:10; Node.js: 14.10.0; npm: 6.14.8

What happened?
I'm not sure if it's a bug, or if I might misunderstand something. This is minimal project to reproduce the problem.

git clone https://github.com/ljonya/ts-app.git
cd ts-app
npm i
npx eslint ./test.ts 

Prints out an error:

/home/leonid/ts-app/test.ts
  0:1  error  This rule requires the `strictNullChecks` compiler option to be turned on to function correctly  @typescript-eslint/strict-boolean-expressions

✖ 1 problem (1 error, 0 warnings)

Although in tsconfig.json the property strictNullChecks is true.

@jtalcantara
Copy link

Same here, :(

Node: v14.15.0; npm: 6.14.8

@theoludwig
Copy link
Contributor

theoludwig commented Dec 17, 2020

Same problem while working for https://github.com/standard/vscode-standardjs/.
Maybe related to this PR : typescript-eslint/typescript-eslint#2345

EDIT: I fixed it by explicitly setting strict: true, in the tsconfig.json of the root of the subfolders of typescript projects.
Example for the vscode extension there are 2 subfolders : client and server and at the root there is a tsconfig.json with strict: true, but it wasn't enough, I also needed to set it in the tsconfig.json of the client and the server folders. Hopefully I'm clear and it's helping to find out how to solve the issue.

@chantzlarge
Copy link

chantzlarge commented Jan 28, 2021

Found that defining the project explicity using:

ts-standard -p ./tsconfig.json

In my Angular project resolved this error for me.

@juliancioc
Copy link

try to close and open the vscode :)

@LucasMallmann
Copy link

LucasMallmann commented Mar 5, 2021

try to close and open the vscode :)

Always works :) (worked after setting the strictNullChecks in the tsconfig.json file).

@ghost
Copy link

ghost commented Mar 28, 2021

Add "strictNullChecks": true to the "compilerOptions" object in tsconfig.json did the trick

@HenriqueOmena
Copy link

don't forget to reload your VsCode when u change 'strictNullChecks' to true to not receive this error message anymore

@theoludwig
Copy link
Contributor

As others said, please enable strictNullChecks in tsconfig.json.
Will close the issue for now, but please reopen if you have any doubt or others issues. 😄

@VictorMeneghini
Copy link

try to close and open the vscode :)

Best solution... Always works hahaha

@geraldoam
Copy link

try to close and open the vscode :)

Thanks!

@JoanWilson
Copy link

try to close and open the vscode :)

Thank you!! Best Solution

@lenodeoliveira
Copy link

@LucasMallmann
Best solution!

@Vanilagy
Copy link

You don't need to reload/restart VS Code. Simply restarting the TS language server will suffice.
CTRL/CMD + SHIFT + P -> Typescript: Restart TS server

@JayDouglass
Copy link

Same problem while working for https://github.com/standard/vscode-standardjs/. Maybe related to this PR : typescript-eslint/typescript-eslint#2345

EDIT: I fixed it by explicitly setting strict: true, in the tsconfig.json of the root of the subfolders of typescript projects. Example for the vscode extension there are 2 subfolders : client and server and at the root there is a tsconfig.json with strict: true, but it wasn't enough, I also needed to set it in the tsconfig.json of the client and the server folders. Hopefully I'm clear and it's helping to find out how to solve the issue.

I had a similar problem in a new Vite/React/TS project. I had to set strict: true in tsconfig.node.json.

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

No branches or pull requests