remove leading "this" type in global functions

This commit is contained in:
Jill 2021-11-04 13:15:57 +03:00
parent 2c579d8a41
commit f24f052c23
1 changed files with 1 additions and 0 deletions

View File

@ -86,6 +86,7 @@ function transpile(parsed, indent, prefix) {
classes[d.name] = contents;
return `---@class ${d.name}${d.extends ? ' : ' + d.extends : ''}${n}${contents.filter(e => e[0] === 'const').map(c => `---@field public ${c[1].name} ${transpileType(c[1].type)}${n}`).join('')}${global ? '' : '__class_'}${d.name} = {}${n}${contents.filter(e => e[0] !== 'const').map(c => transpile(c, indent, `${global ? '' : '__class_'}${d.name}`)).join(n)}\n`;
case 'function':
if (d.arguments[0] && d.arguments[0].type === 'void') d.arguments = d.arguments.slice(1);
return `${d.arguments.map(p => `---@param ${p.name.replace('?', '')} ${transpileType(p.type)}${n}`).join('')}---@return ${transpileType(d.returns)}${n}function ${prefix ? prefix + ':' : ''}${d.name}(${d.arguments.map(a => a.name.replace('?', '')).join(', ')}) end`;
case 'const':
return `---@type ${transpileType(d.type)}${n}${prefix ? prefix + '.' : ''}${d.name} = nil`;