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

Docs: [prefer-optional-chain] improve the playground and examples for allowPotentiallyUnsafeFixesThatModifyTheReturnTypeIKnowWhatImDoing #8659

Closed
2 tasks done
kirkwaiblinger opened this issue Mar 13, 2024 · 1 comment · Fixed by #8685
Labels
accepting prs Go ahead, send a pull request that resolves this issue documentation Documentation ("docs") that needs adding/updating

Comments

@kirkwaiblinger
Copy link
Member

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

I have a hard time following all the words in the section on allowPotentiallyUnsafeFixesThatModifyTheReturnTypeIKnowWhatImDoing, so I tried using the "Open in Playground" button for this section. It... doesn't really work, though.

  1. There are no type errors! The playground opens with an empty tsconfig, so we don't have "strict"/"strictNullChecks" specified to true.
  2. I can't figure out how to trigger the report that's implied in the doc. Even after enabling strictNullChecks, there is no report in the snippet, so I copied the two code snippets I saw in writing (!foo || foo.bar and foo?.bar) into the playground and neither of them reports either.

Affected URL(s)

https://typescript-eslint.io/rules/prefer-optional-chain/#allowpotentiallyunsafefixesthatmodifythereturntypeiknowwhatimdoing

@kirkwaiblinger kirkwaiblinger added documentation Documentation ("docs") that needs adding/updating triage Waiting for maintainers to take a look labels Mar 13, 2024
@bradzacher
Copy link
Member

There are no type errors! The playground opens with an empty tsconfig, so we don't have "strict"/"strictNullChecks" specified to true.

That seems like a separate issue entirely because a blank playground always opens with the tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

I can't figure out how to trigger the report that's implied in the doc. Even after enabling strictNullChecks, there is no report in the snippet, so I copied the two code snippets I saw in writing (!foo || foo.bar and foo?.bar) into the playground and neither of them reports either.

The behaviour may have changed since the snippet was written.
We have an open issue that's being worked on to help us visualise and enforce that all of our snippets report the errors that we actually assume them to.

@bradzacher bradzacher added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Mar 13, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue documentation Documentation ("docs") that needs adding/updating
Projects
None yet
2 participants