fix type transliteration
This commit is contained in:
parent
a43df3e28b
commit
84320e5aab
10
index.js
10
index.js
|
@ -14,6 +14,7 @@ let tsToLuaTypes = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function transpileType(type) {
|
function transpileType(type) {
|
||||||
|
if (!type) return 'what';
|
||||||
type = type.trim();
|
type = type.trim();
|
||||||
|
|
||||||
if (type.startsWith('(') && type.endsWith(')')) type = type.slice(1, -1);
|
if (type.startsWith('(') && type.endsWith(')')) type = type.slice(1, -1);
|
||||||
|
@ -30,10 +31,14 @@ function transpileType(type) {
|
||||||
return type.split('|').map(t => transpileType(t)).join(' | ');
|
return type.split('|').map(t => transpileType(t)).join(' | ');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.startsWith('Record<')) {
|
if (type.startsWith('"')) {
|
||||||
|
return 'string';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type.startsWith('Record<') && type.endsWith('>')) {
|
||||||
return 'table<' + transpileType(type.split(',')[0].replace('Record<','')) + ', ' + transpileType(type.split(',')[1].replace('>','')) + '>';
|
return 'table<' + transpileType(type.split(',')[0].replace('Record<','')) + ', ' + transpileType(type.split(',')[1].replace('>','')) + '>';
|
||||||
}
|
}
|
||||||
if (type.startsWith('LuaTable<')) {
|
if (type.startsWith('LuaTable<') && type.endsWith('>')) {
|
||||||
return 'table<' + transpileType(type.split(',')[0].replace('LuaTable<','')) + ', ' + transpileType(type.split(',')[1].replace('>','')) + '>';
|
return 'table<' + transpileType(type.split(',')[0].replace('LuaTable<','')) + ', ' + transpileType(type.split(',')[1].replace('>','')) + '>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,6 +241,7 @@ async function recursiveReaddir(rpath, p, fileNames) {
|
||||||
errorReason[f] = err;
|
errorReason[f] = err;
|
||||||
if (errored.length > files.length - i) {
|
if (errored.length > files.length - i) {
|
||||||
console.error(`${chalk.redBright('!')} failed resolving extends!`);
|
console.error(`${chalk.redBright('!')} failed resolving extends!`);
|
||||||
|
errored = [...new Set(errored)];
|
||||||
console.error(`${chalk.redBright('!')} abandoned ${chalk.magentaBright(errored.length)} files:`);
|
console.error(`${chalk.redBright('!')} abandoned ${chalk.magentaBright(errored.length)} files:`);
|
||||||
let longest = errored.reduce((a, b) => Math.max(a.length || a || 0, b.length));
|
let longest = errored.reduce((a, b) => Math.max(a.length || a || 0, b.length));
|
||||||
errored.forEach(e => console.error(` - ${chalk.cyanBright(e)}${' '.repeat(longest - e.length + 2)}${chalk.gray(' → ' + errorReason[e].message.replace('Class not found in class storage: ', ''))}`));
|
errored.forEach(e => console.error(` - ${chalk.cyanBright(e)}${' '.repeat(longest - e.length + 2)}${chalk.gray(' → ' + errorReason[e].message.replace('Class not found in class storage: ', ''))}`));
|
||||||
|
|
Loading…
Reference in New Issue