@@ -674,7 +674,6 @@ pub fn fold_program(
674674 proposal:: decorator_2022_03:: decorator_2022_03( ) ,
675675 options. use_decorators_proposal,
676676 ) ,
677- proposal:: explicit_resource_management:: explicit_resource_management( ) ,
678677 helpers:: inject_helpers( marks. top_level) ,
679678 // transform imports to var decls before doing the typescript pass
680679 // so that swc doesn't do any optimizations on the import declarations
@@ -983,105 +982,6 @@ export class A {
983982 assert ! ( transpiled_source. source_map. is_none( ) ) ;
984983 }
985984
986- #[ test]
987- fn test_explicit_resource_management ( ) {
988- let specifier =
989- ModuleSpecifier :: parse ( "https://deno.land/x/mod.ts" ) . unwrap ( ) ;
990- let source = "using data = create();\n console.log(data);" ;
991- let program = parse_program ( ParseParams {
992- specifier,
993- text : source. into ( ) ,
994- media_type : MediaType :: TypeScript ,
995- capture_tokens : false ,
996- maybe_syntax : None ,
997- scope_analysis : false ,
998- } )
999- . unwrap ( ) ;
1000- let transpiled_source = program
1001- . transpile (
1002- & TranspileOptions :: default ( ) ,
1003- & TranspileModuleOptions :: default ( ) ,
1004- & EmitOptions :: default ( ) ,
1005- )
1006- . unwrap ( )
1007- . into_source ( ) ;
1008- let expected_text = r#"function _using_ctx() {
1009- var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
1010- var err = new Error();
1011- err.name = "SuppressedError";
1012- err.suppressed = suppressed;
1013- err.error = error;
1014- return err;
1015- }, empty = {}, stack = [];
1016- function using(isAwait, value) {
1017- if (value != null) {
1018- if (Object(value) !== value) {
1019- throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
1020- }
1021- if (isAwait) {
1022- var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
1023- }
1024- if (dispose == null) {
1025- dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
1026- }
1027- if (typeof dispose !== "function") {
1028- throw new TypeError(`Property [Symbol.dispose] is not a function.`);
1029- }
1030- stack.push({
1031- v: value,
1032- d: dispose,
1033- a: isAwait
1034- });
1035- } else if (isAwait) {
1036- stack.push({
1037- d: value,
1038- a: isAwait
1039- });
1040- }
1041- return value;
1042- }
1043- return {
1044- e: empty,
1045- u: using.bind(null, false),
1046- a: using.bind(null, true),
1047- d: function() {
1048- var error = this.e;
1049- function next() {
1050- while(resource = stack.pop()){
1051- try {
1052- var resource, disposalResult = resource.d && resource.d.call(resource.v);
1053- if (resource.a) {
1054- return Promise.resolve(disposalResult).then(next, err);
1055- }
1056- } catch (e) {
1057- return err(e);
1058- }
1059- }
1060- if (error !== empty) throw error;
1061- }
1062- function err(e) {
1063- error = error !== empty ? new _disposeSuppressedError(error, e) : e;
1064- return next();
1065- }
1066- return next();
1067- }
1068- };
1069- }
1070- try {
1071- var _usingCtx = _using_ctx();
1072- var data = _usingCtx.u(create());
1073- console.log(data);
1074- } catch (_) {
1075- _usingCtx.e = _;
1076- } finally{
1077- _usingCtx.d();
1078- }"# ;
1079- assert_eq ! (
1080- & transpiled_source. text[ ..expected_text. len( ) ] ,
1081- expected_text
1082- ) ;
1083- }
1084-
1085985 #[ test]
1086986 fn test_transpile_tsx ( ) {
1087987 let specifier =
0 commit comments