Typescript: Always-false-condition in editorServices.ts

Created on 18 Aug 2017  路  6Comments  路  Source: microsoft/TypeScript

The condition on line 1663 in editorServices.ts:
https://github.com/Microsoft/TypeScript/blob/eef7d8bd3d974528464c7968deab78b747568c06/src/server/editorServices.ts#L1650-L1666

is always false as the called method closeExternalProject always returns void. That way the if-block with shouldRefreshInferredProjects = true; is never executed (for more information see the linter rule detecting this).

Bug Fixed help wanted

Most helpful comment

@mhegazy seems like using a void value in a truthiness position is hyper-sketchy - thoughts on making that an error in TS?

All 6 comments

See also https://palantir.github.io/tslint/rules/no-void-expression/ -- but this would require us to set up linting with type information.

thanks for the report. a PR would be appreciated.

@mhegazy seems like using a void value in a truthiness position is hyper-sketchy - thoughts on making that an error in TS?

thoughts on making that an error in TS?

i thought you had experimented with this a while back; I think it is a check worth adding, baring any breaks that we might find from RWC tests.

I had a test for always-truthy values that attempted to find bugs like if (x.f) (in lieu of if (x.f()) {) but the problem was that non-strictNullChecks .d.ts file gave tons of false positives. Checking for void values in control flow test positions should be a home run

i think the void check should only flag errors. seems like a low risk-high yield change to make.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wmaurer picture wmaurer  路  3Comments

blendsdk picture blendsdk  路  3Comments

Antony-Jones picture Antony-Jones  路  3Comments

CyrusNajmabadi picture CyrusNajmabadi  路  3Comments

uber5001 picture uber5001  路  3Comments