diff options
author | bobzel <zzzman@gmail.com> | 2024-10-17 13:31:25 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-10-17 13:31:25 -0400 |
commit | 5e3f9d84da226e62ce109cc2c0b00ba76eb45189 (patch) | |
tree | 7516f80d96cb28088a49b1cba0edf7df78821c47 /src/client/util/Scripting.ts | |
parent | 14f412611299fc350f13b6f96be913d59533cfb3 (diff) | |
parent | 4a9330e996b9117fb27560b9898b6fc1dbb78f96 (diff) |
Merge branch 'master' into ajs-before-executable
Diffstat (limited to 'src/client/util/Scripting.ts')
-rw-r--r-- | src/client/util/Scripting.ts | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts index b1db0bf39..5d78c2fab 100644 --- a/src/client/util/Scripting.ts +++ b/src/client/util/Scripting.ts @@ -48,7 +48,7 @@ export function isCompileError(toBeDetermined: CompileResult): toBeDetermined is // eslint-disable-next-line no-use-before-define function Run(script: string | undefined, customParams: string[], diagnostics: ts.Diagnostic[], originalScript: string, options: ScriptOptions): CompileResult { - const errors = diagnostics.filter(diag => diag.category === ts.DiagnosticCategory.Error); + const errors = diagnostics.filter(diag => diag.category === ts.DiagnosticCategory.Error).filter(diag => diag.code !== 2304 && diag.code !== 2339); if ((options.typecheck !== false && errors.length) || !script) { return { compiled: false, errors }; } @@ -188,6 +188,7 @@ export function CompileScript(script: string, options: ScriptOptions = {}): Comp }, ''); const found = ScriptField.GetScriptFieldCache(script + ':' + signature); // if already compiled, found is the result; cache set below if (found) return found as CompiledScript; + options.typecheck = true; const { requiredType = '', addReturn = false, params = {}, capturedVariables = {}, typecheck = true } = options; if (options.params && !options.params.this) options.params.this = Doc.name; if (options.globals) { @@ -221,13 +222,10 @@ export function CompileScript(script: string, options: ScriptOptions = {}): Comp if ('this' in params || 'this' in capturedVariables) { paramNames.push('this'); } - for (const key in params) { - if (key !== 'this') { - paramNames.push(key); - } - } + paramNames.push(...Object.keys(params).filter(p => p!== 'this' && !Object.keys(capturedVariables).includes(p))); + const paramList = paramNames.map(key => { - const val = params[key]; + const val = typeof params[key] === "string" && params[key].length && !"\"'`".includes(params[key][0]) ? `"${params[key]}"` : params[key]; return `${key}: ${val}`; }); for (const key in capturedVariables) { |