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
Search Terms
no ignore noignore must use mustUse
Suggestion
Not using the returned value would be an error. Value can be used by:
await
ing it, if it's a Promise,yield
ing it,Inferred return type should be
mustUse
/noignore
.Use Cases
throws
clause and typed catch clause #13219),Examples
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: