Skip to content

Commit

Permalink
fix: support "using" keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Oct 31, 2023
1 parent d40b3a5 commit a4afd70
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ docs/.vitepress/cache/deps/*.*
test/core/src/self
test/workspaces/results.json
test/reporters/fixtures/with-syntax-error.test.js
using-feature.test.ts
27 changes: 27 additions & 0 deletions test/core/test/using-feature.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test, expect } from 'vitest'

// @ts-expect-error - readonly symbol, but might not be assigned
Symbol.dispose ??= Symbol('dispose')

const resourceful = (resourceDefault: string) => {
let resource: string | null = resourceDefault
return {
get resource() {
return resource
},
[Symbol.dispose]: () => {
resource = null
},
}
}

test('new "using" feature', () => {
let getResource = (): any => {
throw new Error('don\'t call me')
}
{
using resource = resourceful('foo')

Check failure on line 23 in test/core/test/using-feature.test.ts

View workflow job for this annotation

GitHub Actions / typecheck

Unexpected keyword or identifier.

Check failure on line 23 in test/core/test/using-feature.test.ts

View workflow job for this annotation

GitHub Actions / typecheck

Unexpected keyword or identifier.
getResource = () => resource.resource
}
expect(getResource()).toBe(null)
})

0 comments on commit a4afd70

Please sign in to comment.