diff --git a/zap/src/output/luau/client.rs b/zap/src/output/luau/client.rs index 2248a16e..a828c9cd 100644 --- a/zap/src/output/luau/client.rs +++ b/zap/src/output/luau/client.rs @@ -476,12 +476,10 @@ impl<'src> ClientOutput<'src> { if !self.config.fndecls.is_empty() { self.push_line("local function_call_id = 0"); - if !self.config.async_lib.is_empty() { - if self.config.typescript { - self.push_line(&format!("local Promise = {}.Promise", self.config.async_lib)) - } else { - self.push_line(&format!("local {} = {}", self.config.yield_type, self.config.async_lib)) - } + if self.config.typescript && self.config.yield_type == YieldType::Promise { + self.push_line("local Promise = _G[script].Promise") + } else if !self.config.async_lib.is_empty() { + self.push_line(&format!("local {} = {}", self.config.yield_type, self.config.async_lib)) } } diff --git a/zap/src/output/luau/mod.rs b/zap/src/output/luau/mod.rs index da6edb96..dc087097 100644 --- a/zap/src/output/luau/mod.rs +++ b/zap/src/output/luau/mod.rs @@ -191,7 +191,7 @@ pub trait Output { self.push_line("--!optimize 2"); self.push_line("--!nocheck"); self.push_line("--!nolint"); - self.push_line("--#selene: allow(unused_variable, incorrect_standard_library_use)"); + self.push_line("--#selene: allow(unused_variable, incorrect_standard_library_use, global_usage)"); self.push_line(&format!( "-- {scope} generated by Zap v{} (https://github.com/red-blox/zap)", diff --git a/zap/src/parser/convert.rs b/zap/src/parser/convert.rs index 8bdb8d40..832cfd69 100644 --- a/zap/src/parser/convert.rs +++ b/zap/src/parser/convert.rs @@ -96,7 +96,7 @@ impl<'src> Converter<'src> { let casing = self.casing_opt(&config.opts); let yield_type = self.yield_type_opt(typescript, &config.opts); - let async_lib = self.async_lib(yield_type, &config.opts); + let async_lib = self.async_lib(yield_type, &config.opts, typescript); let config = Config { tydecls, @@ -121,7 +121,7 @@ impl<'src> Converter<'src> { (config, self.reports) } - fn async_lib(&mut self, yield_type: YieldType, opts: &[SyntaxOpt<'src>]) -> &'src str { + fn async_lib(&mut self, yield_type: YieldType, opts: &[SyntaxOpt<'src>], typescript: bool) -> &'src str { let (async_lib, async_lib_span) = self.str_opt("async_lib", "", opts); if let Some(span) = async_lib_span { @@ -136,7 +136,7 @@ impl<'src> Converter<'src> { expected: "that `async_lib` cannot be defined when using a `yield_type` of `yield`", }); } - } else if async_lib.is_empty() && yield_type != YieldType::Yield { + } else if async_lib.is_empty() && yield_type != YieldType::Yield && !typescript { self.report(Report::AnalyzeMissingOptValue { expected: "`async_lib`", required_when: "`yield_type` is set to `promise` or `future`.",