tsconfig:
{
"compilerOptions": {
"target": "ESNext",
"lib": ["ESNext"],
"module": "commonjs",
"strict": true,
"baseUrl": ".",
"rootDir": "src",
"outDir": "dist",
"paths": {},
"plugins": [
{
"transform": "mtasa-lua-utils/transformer",
"after": false,
"externalImports": true,
"globalExports": false
}
],
"types": ["lua-types/5.1"],
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true
},
"tstl": {
"luaTarget": "5.1",
"noImplicitSelf": true,
"luaLibImport": "none",
"sourceMapTraceback": false,
"noHeader": true
},
"bundleEntryPoints": ["src/test.ts"]
}
- Just await not working
(async () => {
print('Start')
try {
let text = await new Promise((resolve) => { resolve("Success text") })
print(text)
} catch (e) {
print(`Somethings wrong global: ${e}`)
}
print('End')
})()
Result:
Start
Somethings wrong global: test\vendor\lualib_bundle.lua:538: attempt to yield across metamethod/C-call boundary
End
function __TS__Await(thing)
return coroutine.yield(thing)
end
Expected:
But then is working:
(async () => {
print('Start')
try {
new Promise((resolve) => { resolve("Success text") })
.then((text) => {
print(text)
})
} catch (e) {
print(`Somethings wrong global: ${e}`)
}
print('End')
})()
Result:
- Catch after then not working
(async () => {
print('Start')
try {
Promise.reject('Error text')
.then((result) => {
print(`Result: ${result}`)
})
.catch((e) => {
print(`Somethings wrong local: ${e}`)
})
} catch (e) {
print(`Somethings wrong global: ${e}`)
}
print('End')
})()
Result:
Expected:
Start
Somethings wrong local: Error text
End
But without .then, .catch working:
(async () => {
print('Start')
try {
Promise.reject('Error text')
.catch((e) => {
print(`Somethings wrong local: ${e}`)
})
} catch (e) {
print(`Somethings wrong global: ${e}`)
}
print('End')
})()
Result:
Start
Somethings wrong local: Error text
End
- Global catch not working
(async () => {
print('Start')
try {
await new Promise((resolve, reject) => {
reject('Error text')
})
} catch (e) {
print(`Somethings wrong global: ${e}`)
}
print('End')
})()
Result:
Expected:
Start
Somethings wrong global: Error text
End
tsconfig:
Result:
Expected:
But then is working:
Result:
Result:
Expected:
But without .then, .catch working:
Result:
Result:
Expected: