Skip to content

Commit 0b66605

Browse files
committed
lint
1 parent acaba76 commit 0b66605

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

packages/repl/src/lib/Output/Output.svelte

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import Viewer from './Viewer.svelte';
88
import { Editor, Workspace, type File } from 'editor';
99
import { untrack } from 'svelte';
10-
import { decode } from '@jridgewell/sourcemap-codec';
10+
import { decode, type SourceMapSegment } from '@jridgewell/sourcemap-codec';
1111
1212
interface Props {
1313
status: string | null;
@@ -88,17 +88,18 @@
8888
if (markdown) return;
8989
9090
if (view === 'js' || view === 'css') {
91-
const output = view === 'js' ? js_workspace : css_workspace;
91+
const v = view; // so that TS doesn't think it could become something different
92+
const output = v === 'js' ? js_workspace : css_workspace;
9293
93-
const highlight = (line: number, a: number[], b: number[]) => {
94+
const highlight = (line: number, a: SourceMapSegment, b: SourceMapSegment) => {
9495
const split = {
95-
original: workspace.current.contents.split('\n'),
96-
generated: current.result[view].code.split('\n')
96+
original: workspace.current!.contents.split('\n'),
97+
generated: current!.result![v]!.code.split('\n')
9798
};
9899
99100
const original = {
100-
start: split.original.slice(0, a[2]).join('\n').length + 1 + a[3],
101-
end: split.original.slice(0, b[2]).join('\n').length + 1 + b[3]
101+
start: split.original.slice(0, a[2]).join('\n').length + 1 + a[3]!,
102+
end: split.original.slice(0, b[2]).join('\n').length + 1 + b[3]!
102103
};
103104
104105
const generated = {
@@ -116,9 +117,9 @@
116117
};
117118
118119
workspace.onhover((pos) => {
119-
if (!current?.result?.[view]?.map) return;
120+
if (!current?.result?.[v]?.map) return;
120121
121-
const mappings = decode(current.result[view].map.mappings);
122+
const mappings = decode(current.result[v].map.mappings);
122123
123124
const { line, column } = locate(workspace.current.contents, pos)!;
124125
@@ -129,13 +130,11 @@
129130
const a = segments[j];
130131
const b = segments[j + 1];
131132
132-
if (!b) continue;
133+
if (a[2]! > line) continue;
134+
if (b[2]! < line) continue;
133135
134-
if (a[2] > line) continue;
135-
if (b[2] < line) continue;
136-
137-
if (a[2] === line && a[3] > column) continue;
138-
if (b[2] === line && b[3] < column) continue;
136+
if (a[2]! === line && a[3]! > column) continue;
137+
if (b[2]! === line && b[3]! < column) continue;
139138
140139
// if we're still here, we have a match
141140
highlight(i, a, b);
@@ -147,11 +146,11 @@
147146
});
148147
149148
output.onhover((pos) => {
150-
if (!current?.result?.[view]?.map) return;
149+
if (!current?.result?.[v]?.map) return;
151150
152-
const mappings = decode(current.result[view].map.mappings);
151+
const mappings = decode(current.result[v].map.mappings);
153152
154-
const { line, column } = locate(current.result[view].code, pos)!;
153+
const { line, column } = locate(current.result[v].code, pos)!;
155154
156155
const segments = mappings[line];
157156

0 commit comments

Comments
 (0)