Bug Report
Currently the polyfilled implementation for using performs the following check:
var__addDisposableResource=(this&&this.__addDisposableResource)||function(env,value,async){if(value!==null&&value!==void0){if(typeofvalue!=="object")thrownewTypeError("Object expected.");// ...In the spec, the value used with using needs to be an "Object type", but we know in JavaScript an Object type can have typeof value other than "object", for example, a function has typeof value === "function" while also being a valid JavaScript Object.
The implementation should use the check similar to underscore.js's isObject() check:
exportdefaultfunctionisObject(obj){vartype=typeofobj;returntype==='function'||(type==='object'&&!!obj);}⏯ Playground Link
functioncreateHandle(): Writer&Disposable{constwrite: Writer=(data)=>{};constclose=(): void=>{};returnObject.assign(write,{[Symbol.dispose]: close});}{
using write=createHandle();}typeWriter={(data: string): void;};Playground link with relevant code
Bug Report
Currently the polyfilled implementation for
usingperforms the following check:In the spec, the value used with
usingneeds to be an "Object type", but we know in JavaScript an Object type can havetypeofvalue other than"object", for example, a function hastypeof value === "function"while also being a valid JavaScript Object.The implementation should use the check similar to
underscore.js'sisObject()check:⏯ Playground Link
Playground link with relevant code