You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
declarefunctionreturnsPromise(): noignorePromise<void>foo(returnsPromise())// ok (1)returnsPromise().catch(...)// ok (2)awaitreturnsPromise()// ok (4)returnreturnsPromise()// ok (6)returnsPromise()// errorarray.splice(0,1)// okbar(array.slice(1))// ok (1)array.slice(1).forEach(...)// ok (2)array.slice(1).length// error, `.length` unusedbaz(array.slice(1).length)// weird but ok (3, 1)returnarray.slice(1).length// weird but ok (3, 6)yieldarray.slice(1)// ok (5)yield*array.slice(1)// ok (5)returnarray.slice(1)// ok (6)array.slice(1)// error
Checklist
My suggestion meets these guidelines:
This wouldn't be a breaking change in existing TypeScript/JavaScript code
This wouldn't change the runtime behavior of existing JavaScript code
This could be implemented without emitting different JS based on the types of the expressions
This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
In most cases unused return value should be considered as error or warning. For this reason make sense in opposite approach when we can specify that return value should be ignored:
returnsPromise();// must be error or warning, because return value is ignored_=returnsPromise();// OK
Activity
ikokostya commentedon May 3, 2020
In most cases unused return value should be considered as error or warning. For this reason make sense in opposite approach when we can specify that return value should be ignored:
See for example https://docs.microsoft.com/en-us/dotnet/csharp/discards
ikokostya commentedon May 3, 2020
Also related to #13376
RyanCavanaugh commentedon May 5, 2020
I don't think this covers any ground not already covered by existing issues.
typescript-bot commentedon May 7, 2020
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.