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
Declarations of an instance of a local Disposable class generate the following errors:
LSP is broken (code completions does not work anymore)
Runtime throws error when calling Symbol.dispose/Symbol.asyncDispose
Calling Symbol.dispose result in error if there is more than one scope with using or when there is using in global scope with local class.
Examples
With Symbol.dispose
exportclassDisposable{[Symbol.dispose](){console.log('dispose')}}
using _f=awaitDeno.open('./demo.txt')console.log('ok')
$ deno run --allow-read=. ./src/example.ts
ok
With Symbol.dispose and global using
exportclassDisposable{[Symbol.dispose](){console.log('dispose')}}
using _disposable=newDisposable()console.log('ok')
$ deno run --allow-read=. ./src/example.ts
error: Uncaught (in promise) TypeError: Property [Symbol.dispose] is not a function.
Warning Couldn't format source line: Line 52 is out of bounds (source may have changed at runtime) at _using (file:///.../src/example.ts:52:11) at file:///.../src/example.ts:9:1
With Symbol.dispose and scoped using
exportclassDisposable{[Symbol.dispose](){console.log('dispose')}}{
using _disposable=newDisposable()}console.log('ok')
$ deno run --allow-read=. ./src/example.ts
dispose
ok
With Symbol.dispose scoped using and Deno using
exportclassDisposable{[Symbol.dispose](){console.log('dispose')}}
using _f=awaitDeno.open('./demo.txt'){
using _disposable=newDisposable()}console.log('ok')
$ deno run --allow-read=. ./src/example.ts
error: Uncaught (in promise) TypeError: Property [Symbol.dispose] is not a function.
Warning Couldn't format source line: Line 52 is out of bounds (source may have changed at runtime) at _using (file:///.../src/example.ts:52:11) at file:///.../src/example.ts:11:5 at eventLoopTick (ext:core/01_core.js:65:7)
With Symbol.dispose scoped using and scoped Deno using
exportclassDisposable{[Symbol.dispose](){console.log('dispose')}}{
using _f=awaitDeno.open('./demo.txt')
using _disposable=newDisposable()}console.log('ok')
$ deno run --allow-read=. ./src/example.ts
dispose
ok
With Symbol.AsyncDispose scoped using and scoped Deno using
exportclassDisposable{[Symbol.asyncDispose](){console.log('dispose')}}{
using _f=awaitDeno.open('./demo.txt')await using _asyncDisposable=newAsyncDisposable()}console.log('ok')
$ deno run --allow-read=. ./src/example.ts
dispose
ok
With Symbol.AsyncDispose scoped using and Deno using
exportclassDisposable{[Symbol.asyncDispose](){console.log('dispose')}}
using _f=awaitDeno.open('./demo.txt'){await using _asyncDisposable=newAsyncDisposable()}console.log('ok')
$ deno run --allow-read=. ./src/example.ts
dispose
ok
With Symbol.AsyncDispose scoped using and scoped Deno using
exportclassDisposable{async[Symbol.asyncDispose](){console.log('dispose')}}{
using _f=awaitDeno.open('./demo.txt')await using _asyncDisposable=newAsyncDisposable()}console.log('ok')
$ deno run --allow-read=. ./src/example.ts
dispose
ok
With Symbol.AsyncDispose scoped using and Deno using
exportclassDisposable{async[Symbol.asyncDispose](){console.log('dispose')}}
using _f=awaitDeno.open('./demo.txt'){await using _asyncDisposable=newAsyncDisposable()}console.log('ok')
$ deno run --allow-read=. ./src/example.ts
error: Uncaught (in promise) TypeError: Property [Symbol.dispose] is not a function.
Warning Couldn't format source line: Line 52 is out of bounds (source may have changed at runtime) at _using (file:///.../src/example.ts:52:11) at file:///.../src/example.ts:11:5 at eventLoopTick (ext:core/01_core.js:65:7)
The text was updated successfully, but these errors were encountered:
Hey, I tried using using as well recently but we get a TypeError: Property [Symbol.dispose] is not a function. error, we are only defining asyncDispose since it is a connection closing function.
Version: Deno 1.40.4
Summary
Declarations of an instance of a local Disposable class generate the following errors:
Symbol.dispose
/Symbol.asyncDispose
Calling
Symbol.dispose
result in error if there is more than one scope withusing
or when there isusing
in global scope with localclass
.Examples
With
Symbol.dispose
With
Symbol.dispose
and global usingWith
Symbol.dispose
and scopedusing
With
Symbol.dispose
scopedusing
and Denousing
With
Symbol.dispose
scopedusing
and scoped Denousing
With
Symbol.AsyncDispose
scopedusing
and scoped Denousing
With
Symbol.AsyncDispose
scopedusing
and Denousing
With
Symbol.AsyncDispose
scopedusing
and scoped Denousing
With
Symbol.AsyncDispose
scopedusing
and Denousing
The text was updated successfully, but these errors were encountered: