fix some type shenanigans

This commit is contained in:
Jill 2021-11-04 09:15:10 +03:00
parent 738bbdafb9
commit 89cbcd85a4
1 changed files with 5 additions and 1 deletions

View File

@ -28,6 +28,10 @@ function transpileType(type) {
return transpileType(type.slice(0, -2)) + '[]';
}
if (type.startsWith('LuaMultiReturn<[') && type.endsWith(']>')) {
return type.replace('LuaMultiReturn<[','').replace(']>','').split(',').map(t => transpileType(t.split(':')[1])).join(', ');
}
if (type.includes('|')) {
return type.split('|').map(t => transpileType(t)).join(' | ');
}
@ -139,7 +143,7 @@ function parse(code) {
// look for functions
let functionFreeCode = code;
const functions = /(function)?\s(\w+)\s*\(([^;]*)\)(\s*:\s*([\w\[\]\s|<>,]+))?/g; // wow this sucks
const functions = /(function)?\s(\w+)\s*\(([^;]*)\)(\s*:\s*([\w\[\]\s|<>,:]+))?/g; // wow this sucks
while ((match = functions.exec(code)) !== null) {
parsedElements++;
functionFreeCode = functionFreeCode.replace(match[0], '');