Repository navigation
[api] Stop dropping dispose Promises in the async API #64584
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
Changes from all commits
b11cfba
18e401d
2936ffc
38866b5
0b21503
ae4c8ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6098,8 +6098,17 @@ func (c *Checker) checkVariableLikeDeclaration(node *ast.Node) { | |
| globalDisposableType := c.getGlobalDisposableType() | ||
| if globalDisposableType != c.emptyObjectType { | ||
| optionalDisposableType := c.getUnionType([]*Type{globalDisposableType, c.nullType, c.undefinedType}) | ||
| c.checkTypeAssignableTo(c.widenTypeForVariableLikeDeclaration(initializerType, node, false), optionalDisposableType, initializer, | ||
| diagnostics.The_initializer_of_a_using_declaration_must_be_either_an_object_with_a_Symbol_dispose_method_or_be_null_or_undefined) | ||
| widenedInitializerType := c.widenTypeForVariableLikeDeclaration(initializerType, node, false) | ||
| var diags []*ast.Diagnostic | ||
| if !c.checkTypeAssignableToEx(widenedInitializerType, optionalDisposableType, initializer, | ||
| diagnostics.The_initializer_of_a_using_declaration_must_be_either_an_object_with_a_Symbol_dispose_method_or_be_null_or_undefined, &diags) { | ||
| globalAsyncDisposableType := c.getGlobalAsyncDisposableType() | ||
| optionalAsyncDisposableType := c.getUnionType([]*Type{globalAsyncDisposableType, c.nullType, c.undefinedType}) | ||
| if globalAsyncDisposableType != c.emptyObjectType && c.isTypeAssignableTo(widenedInitializerType, optionalAsyncDisposableType) { | ||
| diags[0].AddMessageChain(ast.NewDiagnosticChain(nil, diagnostics.This_initializer_has_a_Symbol_asyncDispose_method_Did_you_mean_to_use_await_using)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to be checking if we're in an async function first? (This feels a bit lint-y in general though)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
IMO no, because if the first thing I do in a callback is
How so? To be clear, this code doesn't add any new errors. All it does is change the error message from "That doesn't support
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohhhh my bad 😄 |
||
| } | ||
| c.addDiagnostic(diags[0]) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.