From f24f052c23c4b92a9bee487a11a12715edda3e17 Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Thu, 4 Nov 2021 13:15:57 +0300 Subject: [PATCH] remove leading "this" type in global functions --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index c709843..1637403 100644 --- a/index.js +++ b/index.js @@ -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`;