From c1985d64a1d2bdf01d6498a0f11a368911782c4b Mon Sep 17 00:00:00 2001 From: Ofek Date: Fri, 25 Oct 2024 12:19:04 +0300 Subject: [PATCH] Tsification binge #7 (#6974) --- lib/base-compiler.ts | 13 ++-- lib/buildenvsetup/ceconan.ts | 5 +- lib/cfg/cfg-parsers/base.ts | 5 +- lib/cfg/cfg-parsers/oat.ts | 3 +- lib/compilers/cerberus.ts | 5 +- lib/compilers/d8.ts | 4 +- lib/compilers/hook.ts | 10 +-- lib/compilers/java.ts | 4 +- lib/llvm-ir.ts | 4 +- lib/options-handler.ts | 5 +- lib/parsers/asm-parser-cpp.ts | 5 +- lib/parsers/asm-parser-spirv.ts | 3 +- lib/parsers/asm-parser.interfaces.ts | 3 +- package-lock.json | 8 +++ package.json | 1 + static/ansi-to-html.ts | 2 +- static/assert.ts | 2 +- static/compiler-service.ts | 6 +- static/compiler-shared.interfaces.ts | 2 +- static/components.ts | 4 +- static/download-service.ts | 4 +- static/event-map.ts | 4 +- static/graph-layout-core.ts | 10 +-- static/hub.ts | 80 ++++++++++++--------- static/lib-utils.ts | 3 +- static/line-colouring.ts | 3 +- static/local.ts | 2 +- static/modes/carbon-mode.ts | 2 + static/modes/cpp-for-opencl-mode.ts | 2 + static/modes/cppcircle-mode.ts | 2 + static/modes/cppfront-mode.ts | 15 +++- static/modes/cppp-mode.ts | 2 + static/modes/cppx-blue-mode.ts | 2 + static/modes/cuda-mode.ts | 2 + static/modes/glsl-mode.ts | 2 + static/modes/hlsl-mode.ts | 2 + static/modes/hylo-mode.ts | 2 + static/modes/ispc-mode.ts | 2 + static/modes/nc-mode.ts | 2 + static/modes/openclc-mode.ts | 2 + static/multifile-service.ts | 2 +- static/options.interfaces.ts | 2 +- static/options.ts | 2 +- static/panes/ast-view.ts | 5 +- static/panes/cfg-view.ts | 2 +- static/panes/clangir-view.ts | 5 +- static/panes/compiler.ts | 9 ++- static/panes/device-view.ts | 2 +- static/panes/diff.ts | 6 +- static/panes/editor.interfaces.ts | 4 +- static/panes/editor.ts | 12 ++-- static/panes/executor.ts | 4 +- static/panes/flags-view.ts | 2 +- static/panes/gccdump-view.ts | 32 +++++---- static/panes/gnatdebug-view.ts | 5 +- static/panes/gnatdebugtree-view.ts | 5 +- static/panes/haskellcmm-view.ts | 5 +- static/panes/haskellcore-view.ts | 5 +- static/panes/haskellstg-view.ts | 5 +- static/panes/ir-view.ts | 3 +- static/panes/opt-pipeline.ts | 5 +- static/panes/output.ts | 12 ++-- static/panes/pp-view.ts | 8 +-- static/panes/rusthir-view.ts | 5 +- static/panes/rustmacroexp-view.ts | 5 +- static/panes/rustmir-view.ts | 5 +- static/panes/stack-usage-view.ts | 2 +- static/panes/tool-input-view.ts | 21 +++--- static/panes/tool.ts | 4 +- static/panes/tree.ts | 7 +- static/print-view.ts | 2 +- static/rison.ts | 6 +- static/sentry.ts | 3 +- static/settings.ts | 4 +- static/sharing.ts | 13 ++-- static/tests/frontend-testing.interfaces.ts | 2 +- static/tests/motd.ts | 7 +- static/utils.ts | 6 +- static/widgets/alert.interfaces.ts | 2 +- static/widgets/compiler-picker.ts | 12 ++-- static/widgets/load-save.ts | 2 +- static/widgets/toggles.ts | 6 +- test/compilers/hook-tests.ts | 6 +- test/java-tests.ts | 4 +- types/compilation/cfg.interfaces.ts | 4 +- types/compilation/compilation.interfaces.ts | 12 ++-- types/compiler.interfaces.ts | 12 ++-- 87 files changed, 331 insertions(+), 202 deletions(-) diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts index 93cf05ed8..90a971f04 100644 --- a/lib/base-compiler.ts +++ b/lib/base-compiler.ts @@ -2342,7 +2342,7 @@ export class BaseCompiler implements ICompiler { !!this.compiler.removeEmptyGccDump, outputFilename, ) - : ''; + : null; const rustMirResult = makeRustMir ? await this.processRustMirOutput(outputFilename, asmResult) : undefined; const haskellCoreResult = makeHaskellCore @@ -3078,7 +3078,12 @@ export class BaseCompiler implements ICompiler { ); } - async processGccDumpOutput(opts: GccDumpOptions, result, removeEmptyPasses: boolean, outputFilename: string) { + async processGccDumpOutput( + opts: GccDumpOptions, + result, + removeEmptyPasses: boolean | undefined, + outputFilename: string, + ) { const rootDir = path.dirname(result.inputFilename); if (opts.treeDump === false && opts.rtlDump === false && opts.ipaDump === false) { @@ -3092,7 +3097,7 @@ export class BaseCompiler implements ICompiler { const output = { all: [] as any[], - selectedPass: opts.pass, + selectedPass: opts.pass ?? null, currentPassOutput: '', syntaxHighlight: false, }; @@ -3194,7 +3199,7 @@ but nothing was dumped. Possible causes are: return result; } - async execPostProcess(result, postProcesses, outputFilename: string, maxSize: number) { + async execPostProcess(result, postProcesses: string[], outputFilename: string, maxSize: number) { const postCommand = `cat "${outputFilename}" | ${postProcesses.join(' | ')}`; return this.handlePostProcessResult(result, await this.exec('bash', ['-c', postCommand], {maxOutput: maxSize})); } diff --git a/lib/buildenvsetup/ceconan.ts b/lib/buildenvsetup/ceconan.ts index 74682f6a4..e76570e7c 100644 --- a/lib/buildenvsetup/ceconan.ts +++ b/lib/buildenvsetup/ceconan.ts @@ -32,6 +32,7 @@ import _ from 'underscore'; import {CacheKey} from '../../types/compilation/compilation.interfaces.js'; import {CompilerInfo} from '../../types/compiler.interfaces.js'; +import {CompilationEnvironment} from '../compilation-env.js'; import {logger} from '../logger.js'; import {VersionInfo} from '../options-handler.js'; @@ -67,14 +68,12 @@ export class BuildEnvSetupCeConanDirect extends BuildEnvSetupBase { return 'ceconan'; } - constructor(compilerInfo: CompilerInfo, env) { + constructor(compilerInfo: CompilerInfo, env: CompilationEnvironment) { super(compilerInfo, env); this.host = compilerInfo.buildenvsetup!.props('host', ''); this.onlyonstaticliblink = compilerInfo.buildenvsetup!.props('onlyonstaticliblink', ''); this.extractAllToRoot = false; - - if (env.debug) request.debug = true; } async getAllPossibleBuilds(libid: string, version: string) { diff --git a/lib/cfg/cfg-parsers/base.ts b/lib/cfg/cfg-parsers/base.ts index 6a2fba4d4..dcaba3803 100644 --- a/lib/cfg/cfg-parsers/base.ts +++ b/lib/cfg/cfg-parsers/base.ts @@ -24,6 +24,7 @@ import _ from 'underscore'; +import {EdgeColor} from '../../../types/compilation/cfg.interfaces.js'; import type {ResultLineSource} from '../../../types/resultline/resultline.interfaces.js'; import {logger} from '../../logger.js'; import {BaseInstructionSetInfo, InstructionType} from '../instruction-sets/base.js'; @@ -55,7 +56,7 @@ export type Edge = { from: string; to: string; arrows: string; - color: string; + color: EdgeColor; }; export type AssemblyLine = { @@ -237,7 +238,7 @@ export class BaseCFGParser { protected makeEdges(asmArr: AssemblyLine[], arrOfCanonicalBasicBlock: CanonicalBB[]) { const edges: Edge[] = []; - const setEdge = (sourceNode: string, targetNode: string, color: string) => ({ + const setEdge = (sourceNode: string, targetNode: string, color: EdgeColor) => ({ from: sourceNode, to: targetNode, arrows: 'to', diff --git a/lib/cfg/cfg-parsers/oat.ts b/lib/cfg/cfg-parsers/oat.ts index 7c3563007..3bb6485ee 100644 --- a/lib/cfg/cfg-parsers/oat.ts +++ b/lib/cfg/cfg-parsers/oat.ts @@ -24,6 +24,7 @@ import _ from 'underscore'; +import {EdgeColor} from '../../../types/compilation/cfg.interfaces.js'; import {logger} from '../../logger.js'; import {BaseInstructionSetInfo, InstructionType} from '../instruction-sets/base.js'; @@ -249,7 +250,7 @@ export class OatCFGParser extends BaseCFGParser { override makeEdges(asmArr: AssemblyLine[], arrOfCanonicalBasicBlock: CanonicalBB[]) { const edges: Edge[] = []; - const setEdge = (sourceNode: string, targetNode: string, color: string) => ({ + const setEdge = (sourceNode: string, targetNode: string, color: EdgeColor) => ({ from: sourceNode, to: targetNode, arrows: 'to', diff --git a/lib/compilers/cerberus.ts b/lib/compilers/cerberus.ts index b73641e5d..6d9a51213 100644 --- a/lib/compilers/cerberus.ts +++ b/lib/compilers/cerberus.ts @@ -24,6 +24,7 @@ import path from 'path'; +import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces.js'; import {BypassCache, CacheKey, ExecutionOptions} from '../../types/compilation/compilation.interfaces.js'; import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import {ExecutableExecutionOptions} from '../../types/execution/execution.interfaces.js'; @@ -114,10 +115,10 @@ export class CerberusCompiler extends BaseCompiler { } } - override async processAsm(result) { + override async processAsm(result): Promise { // Handle "error" documents. if (!result.asm.includes('\n') && result.asm[0] === '<') { - return [{text: result.asm, source: null}]; + return {asm: [{text: result.asm, source: null}]}; } const lines = result.asm.split('\n'); diff --git a/lib/compilers/d8.ts b/lib/compilers/d8.ts index 4002f491f..69403abf9 100644 --- a/lib/compilers/d8.ts +++ b/lib/compilers/d8.ts @@ -220,9 +220,9 @@ export class D8Compiler extends BaseCompiler implements SimpleOutputFilenameComp } // Map line numbers to lines. - override async processAsm(result) { + override async processAsm(result): Promise { if (result.code !== 0) { - return [{text: result.asm, source: null}]; + return {asm: [{text: result.asm, source: null}]}; } const segments: ParsedAsmResultLine[] = []; const asm = result.asm[0].text; diff --git a/lib/compilers/hook.ts b/lib/compilers/hook.ts index 7ee14e128..4630e0766 100644 --- a/lib/compilers/hook.ts +++ b/lib/compilers/hook.ts @@ -86,12 +86,12 @@ export class HookCompiler extends BaseCompiler { const commentRegex = /^\s*;(.*)/; const instructionRegex = /^\s{2}(\d+)(.*)/; const asm = _result.asm; - let lastLineNo: number | undefined; + let lastLineNo: number | null = null; for (const item of asm) { const text = item.text; if (commentRegex.test(text)) { - item.source = {line: undefined, file: null}; - lastLineNo = undefined; + item.source = {line: null, file: null}; + lastLineNo = null; continue; } const match = text.match(instructionRegex); @@ -105,8 +105,8 @@ export class HookCompiler extends BaseCompiler { item.source = {line: lastLineNo, file: null}; continue; } - item.source = {line: undefined, file: null}; - lastLineNo = undefined; + item.source = {line: null, file: null}; + lastLineNo = null; } _result.asm = asm; return _result; diff --git a/lib/compilers/java.ts b/lib/compilers/java.ts index 9f590c456..92186a93b 100644 --- a/lib/compilers/java.ts +++ b/lib/compilers/java.ts @@ -248,10 +248,10 @@ export class JavaCompiler extends BaseCompiler implements SimpleOutputFilenameCo return this.filterUserOptionsWithArg(userOptions, oneArgForbiddenList); } - override async processAsm(result) { + override async processAsm(result): Promise { // Handle "error" documents. if (!result.asm.includes('\n') && result.asm[0] === '<') { - return [{text: result.asm, source: null}]; + return {asm: [{text: result.asm, source: null}]}; } // result.asm is an array of javap stdouts diff --git a/lib/llvm-ir.ts b/lib/llvm-ir.ts index 499c4ecba..6c4e7ee3b 100644 --- a/lib/llvm-ir.ts +++ b/lib/llvm-ir.ts @@ -23,7 +23,7 @@ // POSSIBILITY OF SUCH DAMAGE. import {isString} from '../shared/common-utils.js'; -import type {IRResultLine} from '../types/asmresult/asmresult.interfaces.js'; +import type {IRResultLine, ParsedAsmResult} from '../types/asmresult/asmresult.interfaces.js'; import {LLVMIrBackendOptions} from '../types/compilation/ir.interfaces.js'; import {ParseFiltersAndOutputOptions} from '../types/features/filters.interfaces.js'; @@ -264,7 +264,7 @@ export class LlvmIrParser { } } - async processFromFilters(ir: string, filters: ParseFiltersAndOutputOptions) { + async processFromFilters(ir: string, filters: ParseFiltersAndOutputOptions): Promise { if (isString(ir)) { return await this.processIr(ir, { filterDebugInfo: !!filters.debugCalls, diff --git a/lib/options-handler.ts b/lib/options-handler.ts index 03705fb8b..3a9fcc7aa 100755 --- a/lib/options-handler.ts +++ b/lib/options-handler.ts @@ -56,6 +56,7 @@ export type VersionInfo = { options: string[]; hidden: boolean; packagedheaders?: boolean; + $order?: number; }; export type OptionsHandlerLibrary = { name: string; @@ -439,7 +440,7 @@ export class ClientOptionsHandler { 'isSemVer', ]); const copiedCompilers = JSON.parse(JSON.stringify(compilers)) as CompilerInfo[]; - const semverGroups: Record = {}; + const semverGroups: Record[]> = {}; // Reset the supportsExecute flag in case critical compilers change for (const key of Object.keys(this.options.languages)) { @@ -462,7 +463,7 @@ export class ClientOptionsHandler { for (const propKey of Object.keys(compiler)) { if (forbiddenKeys.has(propKey)) { - delete copiedCompilers[compilersKey][propKey]; + delete copiedCompilers[compilersKey][propKey as keyof CompilerInfo]; } } } diff --git a/lib/parsers/asm-parser-cpp.ts b/lib/parsers/asm-parser-cpp.ts index 75c2d346f..bd173d15a 100644 --- a/lib/parsers/asm-parser-cpp.ts +++ b/lib/parsers/asm-parser-cpp.ts @@ -22,6 +22,7 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. +import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces.js'; import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; import * as utils from '../utils.js'; @@ -33,7 +34,7 @@ type Source = {file: string | null; line: number}; const lineRe = /^\s*#line\s+(?\d+)\s+"(?[^"]+)"/; export class AsmParserCpp implements IAsmParser { - process(asmResult: string, filters: ParseFiltersAndOutputOptions) { + process(asmResult: string, filters: ParseFiltersAndOutputOptions): ParsedAsmResult { const startTime = process.hrtime.bigint(); const asm: { @@ -69,7 +70,7 @@ export class AsmParserCpp implements IAsmParser { const endTime = process.hrtime.bigint(); return { asm: asm, - labelDefinitions: [], + labelDefinitions: {}, parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(), filteredCount: 0, }; diff --git a/lib/parsers/asm-parser-spirv.ts b/lib/parsers/asm-parser-spirv.ts index d4798dec5..209edf5ea 100644 --- a/lib/parsers/asm-parser-spirv.ts +++ b/lib/parsers/asm-parser-spirv.ts @@ -23,6 +23,7 @@ // POSSIBILITY OF SUCH DAMAGE. import {AsmResultLabel, ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces.js'; +import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; import * as utils from '../utils.js'; import {AsmParser} from './asm-parser.js'; @@ -84,7 +85,7 @@ export class SPIRVAsmParser extends AsmParser { return labelsInLine; } - override processAsm(asmResult, filters) { + override processAsm(asmResult, filters: ParseFiltersAndOutputOptions) { const startTime = process.hrtime.bigint(); const asm: ParsedAsmResultLine[] = []; diff --git a/lib/parsers/asm-parser.interfaces.ts b/lib/parsers/asm-parser.interfaces.ts index 4957a32e1..0b9885894 100644 --- a/lib/parsers/asm-parser.interfaces.ts +++ b/lib/parsers/asm-parser.interfaces.ts @@ -1,5 +1,6 @@ +import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces.js'; import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; export interface IAsmParser { - process(asm: string, filters: ParseFiltersAndOutputOptions); + process(asm: string, filters: ParseFiltersAndOutputOptions): ParsedAsmResult; } diff --git a/package-lock.json b/package-lock.json index e0892b397..0df1e4c47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -81,6 +81,7 @@ "@smithy/util-stream": "^3.1.9", "@types/body-parser": "^1.19.5", "@types/bootstrap": "^5.2.10", + "@types/chai": "^5.0.0", "@types/compression": "^1.7.5", "@types/express": "^4.17.21", "@types/file-saver": "^2.0.7", @@ -4100,6 +4101,13 @@ "integrity": "sha512-hWtVTC2q7hc7xZ/RLbxapMvDMgUnDvKvMOpKal4DrMyfGBUfB1oKaZlIRr6mJL+If3bAP6sV/QneGzF6tJjZDg==", "dev": true }, + "node_modules/@types/chai": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.0.0.tgz", + "integrity": "sha512-+DwhEHAaFPPdJ2ral3kNHFQXnTfscEEFsUxzD+d7nlcLrFK23JtNjH71RGasTcHb88b4vVi4mTyfpf8u2L8bdA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/compression": { "version": "1.7.5", "resolved": "https://registry.npmjs.org/@types/compression/-/compression-1.7.5.tgz", diff --git a/package.json b/package.json index 26666b462..2c3276b35 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ "@smithy/util-stream": "^3.1.9", "@types/body-parser": "^1.19.5", "@types/bootstrap": "^5.2.10", + "@types/chai": "^5.0.0", "@types/compression": "^1.7.5", "@types/express": "^4.17.21", "@types/file-saver": "^2.0.7", diff --git a/static/ansi-to-html.ts b/static/ansi-to-html.ts index 760e37253..dfad84cbc 100644 --- a/static/ansi-to-html.ts +++ b/static/ansi-to-html.ts @@ -323,7 +323,7 @@ function tokenize(text: string, options: AnsiToHtmlOptions, callback: TokenizeCa return ''; } - function rgb(m) { + function rgb(m: string) { callback('rgb', m); return ''; } diff --git a/static/assert.ts b/static/assert.ts index 82a2ff50a..d41465213 100644 --- a/static/assert.ts +++ b/static/assert.ts @@ -67,7 +67,7 @@ function fail(fail_message: string, user_message: string | undefined, args: any[ } } -export function assert(c: C, message?: string, ...extra_info: any[]): asserts c { +export function assert(c: unknown, message?: string, ...extra_info: any[]): asserts c { if (!c) { fail('Assertion failed', message, extra_info); } diff --git a/static/compiler-service.ts b/static/compiler-service.ts index 2d12e20fc..8afb470e8 100644 --- a/static/compiler-service.ts +++ b/static/compiler-service.ts @@ -38,6 +38,7 @@ import {CompilationResult, FiledataPair} from '../types/compilation/compilation. import {CompilationStatus} from './compiler-service.interfaces.js'; import {IncludeDownloads, SourceAndFiles} from './download-service.js'; import {SentryCapture} from './sentry.js'; +import {SiteSettings} from './settings.js'; const ASCII_COLORS_RE = new RegExp(/\x1B\[[\d;]*m(.\[K)?/g); @@ -61,7 +62,10 @@ export class CompilerService { this.compilersByLang[compiler.lang][compiler.id] = compiler; } - eventHub.on('settingsChange', newSettings => (this.allowStoreCodeDebug = newSettings.allowStoreCodeDebug)); + eventHub.on( + 'settingsChange', + (newSettings: SiteSettings) => (this.allowStoreCodeDebug = newSettings.allowStoreCodeDebug), + ); } private getDefaultCompilerForLang(langId: string) { diff --git a/static/compiler-shared.interfaces.ts b/static/compiler-shared.interfaces.ts index fbe4306fc..70e103182 100644 --- a/static/compiler-shared.interfaces.ts +++ b/static/compiler-shared.interfaces.ts @@ -28,7 +28,7 @@ import type {CompilerState} from './panes/compiler.interfaces.js'; import type {ExecutorState} from './panes/executor.interfaces.js'; export interface ICompilerShared { - updateState(state: CompilerState | ExecutorState); + updateState(state: CompilerState | ExecutorState): void; getOverrides(): ConfiguredOverrides | undefined; getRuntimeTools(): ConfiguredRuntimeTools | undefined; } diff --git a/static/components.ts b/static/components.ts index 0227ca942..827ab223d 100644 --- a/static/components.ts +++ b/static/components.ts @@ -186,8 +186,8 @@ export function getExecutorWith( editorId: number, lang: string, compilerId: string, - libraries: unknown, - compilerArgs, + libraries: {name: string; ver: string}[], + compilerArgs: string | undefined, treeId: number, overrides?: ConfiguredOverrides, runtimeTools?: ConfiguredRuntimeTools, diff --git a/static/download-service.ts b/static/download-service.ts index 913dd7589..376548e35 100644 --- a/static/download-service.ts +++ b/static/download-service.ts @@ -40,7 +40,7 @@ export class IncludeDownloads { private toDownload: FileToDownload[] = []; private downloadPromises: Promise[] = []; - private async doDownload(download): Promise { + private async doDownload(download: FileToDownload): Promise { try { const response = await fetch(download.url); if (response.status >= 400) { @@ -55,7 +55,7 @@ export class IncludeDownloads { return download; } - private async startDownload(download) { + private async startDownload(download: FileToDownload) { this.downloadPromises.push(this.doDownload(download)); } diff --git a/static/event-map.ts b/static/event-map.ts index 841818d99..c42bc4562 100644 --- a/static/event-map.ts +++ b/static/event-map.ts @@ -156,10 +156,10 @@ export type EventMap = { // TODO: There are no emitters for this event selectLine: (editorId: number, lineNumber: number) => void; settingsChange: (newSettings: SiteSettings) => void; - setToolInput: (compilerId: number, toolId: string, string: string) => void; + setToolInput: (compilerId: number, toolId: string, value: string) => void; shown: () => void; themeChange: (newTheme: Theme | null) => void; - toolClosed: (compilerId: number, toolState: unknown) => void; + toolClosed: (compilerId: number, toolState: ToolState) => void; toolInputChange: (compilerId: number, toolId: string, input: string) => void; toolInputViewClosed: (compilerId: number, toolId: string, input: string) => void; toolInputViewCloseRequest: (compilerId: number, toolId: string) => void; diff --git a/static/graph-layout-core.ts b/static/graph-layout-core.ts index cb5875120..3709a0b74 100644 --- a/static/graph-layout-core.ts +++ b/static/graph-layout-core.ts @@ -22,7 +22,7 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -import {AnnotatedCfgDescriptor, AnnotatedNodeDescriptor} from '../types/compilation/cfg.interfaces.js'; +import {AnnotatedCfgDescriptor, AnnotatedNodeDescriptor, EdgeColor} from '../types/compilation/cfg.interfaces.js'; import IntervalTree from '@flatten-js/interval-tree'; @@ -70,7 +70,7 @@ type EdgeSegment = { }; type Edge = { - color: string; + color: EdgeColor; dest: number; mainColumn: number; path: EdgeSegment[]; @@ -214,7 +214,7 @@ export class GraphLayoutCore { return order.reverse(); } - assignRows(topologicalOrder) { + assignRows(topologicalOrder: number[]) { for (const i of topologicalOrder) { const block = this.blocks[i]; //console.log(block); @@ -225,7 +225,7 @@ export class GraphLayoutCore { } } - computeTree(topologicalOrder) { + computeTree(topologicalOrder: number[]) { // DAG is reduced to a tree based on what's vertically adjacent // // For something like @@ -317,7 +317,7 @@ export class GraphLayoutCore { } } - assignColumns(topologicalOrder) { + assignColumns(topologicalOrder: number[]) { // Note: Currently not taking shape into account like Cutter does. // Post DFS order means we compute all children before their parents for (const i of topologicalOrder.slice().reverse()) { diff --git a/static/hub.ts b/static/hub.ts index 621ec783a..5f200acef 100644 --- a/static/hub.ts +++ b/static/hub.ts @@ -23,6 +23,7 @@ // POSSIBILITY OF SUCH DAMAGE. import GoldenLayout, {ContentItem} from 'golden-layout'; +type GLC = GoldenLayout.Container; import {CompilerService} from './compiler-service.js'; import { @@ -87,6 +88,7 @@ import {GnatDebugTree as GnatDebugTreeView} from './panes/gnatdebugtree-view.js' import {RustMacroExp as RustMacroExpView} from './panes/rustmacroexp-view.js'; import {IdentifierSet} from './identifier-set.js'; import {EventMap} from './event-map.js'; +import {LanguageKey} from './languages.interfaces.js'; type EventDescriptorMap = { [E in keyof EventMap]: [E, ...Parameters]; @@ -107,50 +109,60 @@ export class Hub { public deferred = true; public deferredEmissions: EventDescriptor[] = []; - public lastOpenedLangId: string | null; + public lastOpenedLangId: LanguageKey | null; public subdomainLangId: string | undefined; - public defaultLangId: string; + public defaultLangId: LanguageKey; public constructor( public readonly layout: GoldenLayout, subLangId: string | undefined, - defaultLangId: string, + defaultLangId: LanguageKey, ) { this.lastOpenedLangId = null; this.subdomainLangId = subLangId; this.defaultLangId = defaultLangId; this.compilerService = new CompilerService(this.layout.eventHub); - layout.registerComponent(EDITOR_COMPONENT_NAME, (c, s) => this.codeEditorFactory(c, s)); - layout.registerComponent(COMPILER_COMPONENT_NAME, (c, s) => this.compilerFactory(c, s)); - layout.registerComponent(TREE_COMPONENT_NAME, (c, s) => this.treeFactory(c, s)); - layout.registerComponent(EXECUTOR_COMPONENT_NAME, (c, s) => this.executorFactory(c, s)); - layout.registerComponent(OUTPUT_COMPONENT_NAME, (c, s) => this.outputFactory(c, s)); - layout.registerComponent(TOOL_COMPONENT_NAME, (c, s) => this.toolFactory(c, s)); - layout.registerComponent(TOOL_INPUT_VIEW_COMPONENT_NAME, (c, s) => this.toolInputViewFactory(c, s)); - layout.registerComponent(DIFF_VIEW_COMPONENT_NAME, (c, s) => this.diffFactory(c, s)); - layout.registerComponent(OPT_VIEW_COMPONENT_NAME, (c, s) => this.optViewFactory(c, s)); - layout.registerComponent(STACK_USAGE_VIEW_COMPONENT_NAME, (c, s) => this.stackUsageViewFactory(c, s)); - layout.registerComponent(FLAGS_VIEW_COMPONENT_NAME, (c, s) => this.flagsViewFactory(c, s)); - layout.registerComponent(PP_VIEW_COMPONENT_NAME, (c, s) => this.ppViewFactory(c, s)); - layout.registerComponent(AST_VIEW_COMPONENT_NAME, (c, s) => this.astViewFactory(c, s)); - layout.registerComponent(IR_VIEW_COMPONENT_NAME, (c, s) => this.irViewFactory(c, s)); - layout.registerComponent(CLANGIR_VIEW_COMPONENT_NAME, (c, s) => this.clangirViewFactory(c, s)); - layout.registerComponent(OPT_PIPELINE_VIEW_COMPONENT_NAME, (c, s) => this.optPipelineFactory(c, s)); + layout.registerComponent(EDITOR_COMPONENT_NAME, (c: GLC, s: any) => this.codeEditorFactory(c, s)); + layout.registerComponent(COMPILER_COMPONENT_NAME, (c: GLC, s: any) => this.compilerFactory(c, s)); + layout.registerComponent(TREE_COMPONENT_NAME, (c: GLC, s: any) => this.treeFactory(c, s)); + layout.registerComponent(EXECUTOR_COMPONENT_NAME, (c: GLC, s: any) => this.executorFactory(c, s)); + layout.registerComponent(OUTPUT_COMPONENT_NAME, (c: GLC, s: any) => this.outputFactory(c, s)); + layout.registerComponent(TOOL_COMPONENT_NAME, (c: GLC, s: any) => this.toolFactory(c, s)); + layout.registerComponent(TOOL_INPUT_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.toolInputViewFactory(c, s)); + layout.registerComponent(DIFF_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.diffFactory(c, s)); + layout.registerComponent(OPT_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.optViewFactory(c, s)); + layout.registerComponent(STACK_USAGE_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.stackUsageViewFactory(c, s)); + layout.registerComponent(FLAGS_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.flagsViewFactory(c, s)); + layout.registerComponent(PP_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.ppViewFactory(c, s)); + layout.registerComponent(AST_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.astViewFactory(c, s)); + layout.registerComponent(IR_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.irViewFactory(c, s)); + layout.registerComponent(CLANGIR_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.clangirViewFactory(c, s)); + layout.registerComponent(OPT_PIPELINE_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.optPipelineFactory(c, s)); // Historical LLVM-specific name preserved to keep old links working - layout.registerComponent(LLVM_OPT_PIPELINE_VIEW_COMPONENT_NAME, (c, s) => this.optPipelineFactory(c, s)); - layout.registerComponent(DEVICE_VIEW_COMPONENT_NAME, (c, s) => this.deviceViewFactory(c, s)); - layout.registerComponent(RUST_MIR_VIEW_COMPONENT_NAME, (c, s) => this.rustMirViewFactory(c, s)); - layout.registerComponent(HASKELL_CORE_VIEW_COMPONENT_NAME, (c, s) => this.haskellCoreViewFactory(c, s)); - layout.registerComponent(HASKELL_STG_VIEW_COMPONENT_NAME, (c, s) => this.haskellStgViewFactory(c, s)); - layout.registerComponent(HASKELL_CMM_VIEW_COMPONENT_NAME, (c, s) => this.haskellCmmViewFactory(c, s)); - layout.registerComponent(GNAT_DEBUG_TREE_VIEW_COMPONENT_NAME, (c, s) => this.gnatDebugTreeViewFactory(c, s)); - layout.registerComponent(GNAT_DEBUG_VIEW_COMPONENT_NAME, (c, s) => this.gnatDebugViewFactory(c, s)); - layout.registerComponent(RUST_MACRO_EXP_VIEW_COMPONENT_NAME, (c, s) => this.rustMacroExpViewFactory(c, s)); - layout.registerComponent(RUST_HIR_VIEW_COMPONENT_NAME, (c, s) => this.rustHirViewFactory(c, s)); - layout.registerComponent(GCC_DUMP_VIEW_COMPONENT_NAME, (c, s) => this.gccDumpViewFactory(c, s)); - layout.registerComponent(CFG_VIEW_COMPONENT_NAME, (c, s) => this.cfgViewFactory(c, s)); - layout.registerComponent(CONFORMANCE_VIEW_COMPONENT_NAME, (c, s) => this.conformanceViewFactory(c, s)); + layout.registerComponent(LLVM_OPT_PIPELINE_VIEW_COMPONENT_NAME, (c: GLC, s: any) => + this.optPipelineFactory(c, s), + ); + layout.registerComponent(DEVICE_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.deviceViewFactory(c, s)); + layout.registerComponent(RUST_MIR_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.rustMirViewFactory(c, s)); + layout.registerComponent(HASKELL_CORE_VIEW_COMPONENT_NAME, (c: GLC, s: any) => + this.haskellCoreViewFactory(c, s), + ); + layout.registerComponent(HASKELL_STG_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.haskellStgViewFactory(c, s)); + layout.registerComponent(HASKELL_CMM_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.haskellCmmViewFactory(c, s)); + layout.registerComponent(GNAT_DEBUG_TREE_VIEW_COMPONENT_NAME, (c: GLC, s: any) => + this.gnatDebugTreeViewFactory(c, s), + ); + layout.registerComponent(GNAT_DEBUG_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.gnatDebugViewFactory(c, s)); + layout.registerComponent(RUST_MACRO_EXP_VIEW_COMPONENT_NAME, (c: GLC, s: any) => + this.rustMacroExpViewFactory(c, s), + ); + layout.registerComponent(RUST_HIR_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.rustHirViewFactory(c, s)); + layout.registerComponent(GCC_DUMP_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.gccDumpViewFactory(c, s)); + layout.registerComponent(CFG_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.cfgViewFactory(c, s)); + layout.registerComponent(CONFORMANCE_VIEW_COMPONENT_NAME, (c: GLC, s: any) => + this.conformanceViewFactory(c, s), + ); layout.eventHub.on( 'editorOpen', @@ -210,7 +222,7 @@ export class Hub { ); layout.eventHub.on( 'languageChange', - function (this: Hub, editorId: number, langId: string) { + function (this: Hub, editorId: number, langId: LanguageKey) { this.lastOpenedLangId = langId; }, this, @@ -385,7 +397,7 @@ export class Hub { } } - public activateTabForContainer(container?: GoldenLayout.Container) { + public activateTabForContainer(container?: GLC) { if (container && (container.tab as typeof container.tab | null)) { container.tab.header.parent.setActiveContentItem(container.tab.contentItem); } diff --git a/static/lib-utils.ts b/static/lib-utils.ts index efe162713..093de7f88 100644 --- a/static/lib-utils.ts +++ b/static/lib-utils.ts @@ -24,6 +24,7 @@ import {options} from './options.js'; import {LanguageLibs, Library} from './options.interfaces.js'; +import {Remote} from './compiler.interfaces.js'; const LIB_MATCH_RE = /([\w-]*)\.([\w-]*)/i; @@ -68,7 +69,7 @@ function copyAndFilterLibraries(allLibraries: LanguageLibs, filter: string[]) { export function getSupportedLibraries( supportedLibrariesArr: string[] | undefined, langId: string, - remote, + remote?: Remote, ): LanguageLibs { if (!remote) { const allLibs = options.libs[langId]; diff --git a/static/line-colouring.ts b/static/line-colouring.ts index eaca95e3a..7a2491b57 100644 --- a/static/line-colouring.ts +++ b/static/line-colouring.ts @@ -24,6 +24,7 @@ import _ from 'underscore'; import {MultifileService} from './multifile-service.js'; +import {ResultLine} from './resultline/resultline.interfaces.js'; interface ColouredSourcelineInfo { sourceLine: number; @@ -50,7 +51,7 @@ export class LineColouring { this.linesAndColourByEditor = {}; } - public addFromAssembly(compilerId, asm) { + public addFromAssembly(compilerId: number, asm: ResultLine[]) { let asmLineIdx = 0; for (const asmLine of asm) { if (asmLine.source && asmLine.source.line > 0) { diff --git a/static/local.ts b/static/local.ts index c3a11870f..a74e9580f 100644 --- a/static/local.ts +++ b/static/local.ts @@ -31,7 +31,7 @@ export interface Storage { set(key: string, value: string): boolean; - remove(key: string); + remove(key: string): void; } class LocalOnlyStorage implements Storage { diff --git a/static/modes/carbon-mode.ts b/static/modes/carbon-mode.ts index 0b6cf01a1..59e8b5f9e 100644 --- a/static/modes/carbon-mode.ts +++ b/static/modes/carbon-mode.ts @@ -23,6 +23,8 @@ // POSSIBILITY OF SUCH DAMAGE. import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; function definition(): monaco.languages.IMonarchLanguage { diff --git a/static/modes/cpp-for-opencl-mode.ts b/static/modes/cpp-for-opencl-mode.ts index 596d5e4ca..398757d95 100644 --- a/static/modes/cpp-for-opencl-mode.ts +++ b/static/modes/cpp-for-opencl-mode.ts @@ -25,6 +25,8 @@ import $ from 'jquery'; import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cppp from './cppp-mode.js'; diff --git a/static/modes/cppcircle-mode.ts b/static/modes/cppcircle-mode.ts index 68c66d365..270d6a7f7 100644 --- a/static/modes/cppcircle-mode.ts +++ b/static/modes/cppcircle-mode.ts @@ -25,6 +25,8 @@ import $ from 'jquery'; import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cppp from './cppp-mode.js'; diff --git a/static/modes/cppfront-mode.ts b/static/modes/cppfront-mode.ts index be3909d7e..50f65dad4 100644 --- a/static/modes/cppfront-mode.ts +++ b/static/modes/cppfront-mode.ts @@ -25,6 +25,8 @@ import $ from 'jquery'; import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cppp from './cppp-mode.js'; @@ -52,7 +54,7 @@ function definition(): monaco.languages.IMonarchLanguage { // Generic parsers. - function parseCpp2Balanced(delimiters, delimiter, opener, closer) { + function parseCpp2Balanced(delimiters: string, delimiter: string, opener: RegExp, closer: RegExp) { return (cppfront.tokenizer['parse_cpp2_balanced_' + delimiters] = [ {include: '@whitespace'}, [opener, 'delimiter.' + delimiter, '$S2.$S3.$S4'], @@ -91,7 +93,14 @@ function definition(): monaco.languages.IMonarchLanguage { } function setupLiteralParsers() { - cppfront.at_cpp2_interpolation = /\([^"]+\)\$/; + function balancedParenthesesRegex(max_nesting: number) { + const front = String.raw`\((?:[^\\()]*|`; + const back = String.raw`)*\)`; + return front.repeat(max_nesting + 1) + back.repeat(max_nesting + 1); + } + cppfront.at_cpp2_balanced_parentheses = balancedParenthesesRegex(5); + + cppfront.at_cpp2_interpolation = /@at_cpp2_balanced_parentheses\$/; cppfront.tokenizer.parse_cpp2_interpolation = [ [/(\()(.)/, ['delimiter.parenthesis', {token: '@rematch', next: 'parse_cpp2_expression'}]], [/:[^)]*/, 'string'], @@ -107,7 +116,7 @@ function definition(): monaco.languages.IMonarchLanguage { [/@encoding?"/, {token: 'string', switchTo: '@string..cpp2'}], ]; - function parseCpp2Interpolation(state, prefix_token_regex, token_class) { + function parseCpp2Interpolation(state: string, prefix_token_regex: RegExp, token_class: string) { cppfront.tokenizer[state].unshift([ prefix_token_regex.source + /(@at_cpp2_interpolation)/.source, { diff --git a/static/modes/cppp-mode.ts b/static/modes/cppp-mode.ts index b2615e40d..d3535dfd7 100644 --- a/static/modes/cppp-mode.ts +++ b/static/modes/cppp-mode.ts @@ -25,6 +25,8 @@ import $ from 'jquery'; import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; // We need to create a new definition for cpp so we can remove invalid keywords diff --git a/static/modes/cppx-blue-mode.ts b/static/modes/cppx-blue-mode.ts index 4b50ee0d0..d83ddce13 100644 --- a/static/modes/cppx-blue-mode.ts +++ b/static/modes/cppx-blue-mode.ts @@ -25,6 +25,8 @@ import $ from 'jquery'; import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cppp from './cppp-mode.js'; diff --git a/static/modes/cuda-mode.ts b/static/modes/cuda-mode.ts index 1a87ed423..c07d3ef88 100644 --- a/static/modes/cuda-mode.ts +++ b/static/modes/cuda-mode.ts @@ -25,6 +25,8 @@ import $ from 'jquery'; import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cppp from './cppp-mode.js'; diff --git a/static/modes/glsl-mode.ts b/static/modes/glsl-mode.ts index 93c41c2ae..68861f23c 100644 --- a/static/modes/glsl-mode.ts +++ b/static/modes/glsl-mode.ts @@ -25,6 +25,8 @@ import $ from 'jquery'; import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; function definition(): monaco.languages.IMonarchLanguage { diff --git a/static/modes/hlsl-mode.ts b/static/modes/hlsl-mode.ts index 26e3918dd..0f2ff76bc 100644 --- a/static/modes/hlsl-mode.ts +++ b/static/modes/hlsl-mode.ts @@ -25,6 +25,8 @@ import $ from 'jquery'; import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; function definition(): monaco.languages.IMonarchLanguage { diff --git a/static/modes/hylo-mode.ts b/static/modes/hylo-mode.ts index a406add3c..974a9fced 100644 --- a/static/modes/hylo-mode.ts +++ b/static/modes/hylo-mode.ts @@ -23,6 +23,8 @@ // POSSIBILITY OF SUCH DAMAGE. import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as swift from 'monaco-editor/esm/vs/basic-languages/swift/swift'; function definition(): monaco.languages.IMonarchLanguage { diff --git a/static/modes/ispc-mode.ts b/static/modes/ispc-mode.ts index ea994f053..35a671db9 100644 --- a/static/modes/ispc-mode.ts +++ b/static/modes/ispc-mode.ts @@ -25,6 +25,8 @@ import $ from 'jquery'; import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; function definition(): monaco.languages.IMonarchLanguage { diff --git a/static/modes/nc-mode.ts b/static/modes/nc-mode.ts index 77e43ede4..1270fd1d1 100644 --- a/static/modes/nc-mode.ts +++ b/static/modes/nc-mode.ts @@ -25,6 +25,8 @@ import $ from 'jquery'; import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; // We need to ensure we use proper keywords for the Monaco Editor matcher. Note how diff --git a/static/modes/openclc-mode.ts b/static/modes/openclc-mode.ts index e446a85c2..b27ccc2e8 100644 --- a/static/modes/openclc-mode.ts +++ b/static/modes/openclc-mode.ts @@ -25,6 +25,8 @@ import $ from 'jquery'; import * as monaco from 'monaco-editor'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore "Could not find a declaration file" import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as nc from './nc-mode.js'; diff --git a/static/multifile-service.ts b/static/multifile-service.ts index 2e35adbb5..eda461dc2 100644 --- a/static/multifile-service.ts +++ b/static/multifile-service.ts @@ -332,7 +332,7 @@ export class MultifileService { }); } - public getEditorIdByFilename(filename: string): number | null { + public getEditorIdByFilename(filename: string | null): number | null { const file = this.files.find((file: MultifileFile) => { return file.isIncluded && file.filename === filename; }); diff --git a/static/options.interfaces.ts b/static/options.interfaces.ts index 3ce46565c..1b3c1c889 100644 --- a/static/options.interfaces.ts +++ b/static/options.interfaces.ts @@ -64,7 +64,7 @@ export type Options = { release?: string; sentryEnvironment?: string; compileOptions: Record; - tools: Partial>>; + tools: Record>; slides?: any[]; cookieDomainRe: string; motdUrl: string; diff --git a/static/options.ts b/static/options.ts index 74e08a7da..5086c9fe7 100644 --- a/static/options.ts +++ b/static/options.ts @@ -35,7 +35,7 @@ window.staticRoot = unwrap(configElement.getAttribute('staticRoot')); const extraOptions: object = JSON.parse(decodeURIComponent(configElement.getAttribute('extraOptions') ?? '"%7B%7D"')); // Encoded {} for (const key in extraOptions) { - window.compilerExplorerOptions[key] = extraOptions[key]; + window.compilerExplorerOptions[key] = extraOptions[key as keyof typeof extraOptions]; } declare let __webpack_public_path__: string; diff --git a/static/panes/ast-view.ts b/static/panes/ast-view.ts index e0a2d8cd5..796c91ed9 100644 --- a/static/panes/ast-view.ts +++ b/static/panes/ast-view.ts @@ -36,6 +36,7 @@ import * as monacoConfig from '../monaco-config.js'; import {Hub} from '../hub.js'; import {unwrap} from '../assert.js'; import {CompilerInfo} from '../compiler.interfaces.js'; +import {CompilationResult} from '../compilation/compilation.interfaces.js'; type DecorationEntry = { linkedCode: any[]; @@ -168,7 +169,7 @@ export class Ast extends MonacoPane = {}; for (const [index, code] of this.astCode.entries()) { if ( code.source && diff --git a/static/panes/cfg-view.ts b/static/panes/cfg-view.ts index 4cd7a1ea2..c561d2a11 100644 --- a/static/panes/cfg-view.ts +++ b/static/panes/cfg-view.ts @@ -176,7 +176,7 @@ export class Cfg extends Pane { dropdownParent: 'body', plugins: ['dropdown_input'], sortField: 'title', - onChange: e => this.selectFunction(e as unknown as string), + onChange: (e: string) => this.selectFunction(e), }); this.functionSelector.on('dropdown_close', () => { // scroll back to the selection on the next open diff --git a/static/panes/clangir-view.ts b/static/panes/clangir-view.ts index 59df2f781..ecbd6e673 100644 --- a/static/panes/clangir-view.ts +++ b/static/panes/clangir-view.ts @@ -69,7 +69,10 @@ export class Clangir extends MonacoPane this.onDidChangeCursorSelection(event), 500); + const throttleFunction = _.throttle( + (event: monaco.editor.ICursorSelectionChangedEvent) => this.onDidChangeCursorSelection(event), + 500, + ); this.editor.onDidChangeCursorSelection(event => throttleFunction(event)); this.eventHub.emit('clangirViewOpened', this.compilerInfo.compilerId); this.eventHub.emit('requestSettings'); diff --git a/static/panes/compiler.ts b/static/panes/compiler.ts index 284467085..348913e1f 100644 --- a/static/panes/compiler.ts +++ b/static/panes/compiler.ts @@ -2692,8 +2692,8 @@ export class Compiler extends MonacoPane { - const btn = $("