1- import { SourceLocation } from 'estree'
2- import * as es from 'estree'
1+ import type es from 'estree'
32import { SourceMapConsumer } from 'source-map'
43
54import createContext from './createContext'
@@ -10,16 +9,16 @@ import { getAllOccurrencesInScopeHelper, getScopeHelper } from './scope-refactor
109import { setBreakpointAtLine } from './stdlib/inspector'
1110import {
1211 Chapter ,
13- Context ,
14- Error as ResultError ,
15- ExecutionMethod ,
16- Finished ,
17- ModuleContext ,
18- RecursivePartial ,
19- Result ,
20- SourceError ,
21- SVMProgram ,
22- Variant
12+ type Context ,
13+ type Error as ResultError ,
14+ type ExecutionMethod ,
15+ type Finished ,
16+ type ModuleContext ,
17+ type RecursivePartial ,
18+ type Result ,
19+ type SourceError ,
20+ type SVMProgram ,
21+ type Variant
2322} from './types'
2423import { assemble } from './vm/svml-assembler'
2524import { compileToIns } from './vm/svml-compiler'
@@ -30,7 +29,7 @@ import { ModuleNotFoundError } from './modules/errors'
3029import type { ImportOptions } from './modules/moduleTypes'
3130import preprocessFileImports from './modules/preprocessor'
3231import { validateFilePath } from './modules/preprocessor/filePaths'
33- import { getKeywords , getProgramNames , NameDeclaration } from './name-extractor'
32+ import { getKeywords , getProgramNames , type NameDeclaration } from './name-extractor'
3433import { htmlRunner , resolvedErrorPromise , sourceFilesRunner } from './runner'
3534
3635export interface IOptions {
@@ -57,7 +56,7 @@ export interface IOptions {
5756
5857// needed to work on browsers
5958if ( typeof window !== 'undefined' ) {
60- // @ts -ignore
59+ // @ts -expect-error Initialize doesn't exist on SourceMapConsumer
6160 SourceMapConsumer . initialize ( {
6261 'lib/mappings.wasm' :
'https://unpkg.com/[email protected] /lib/mappings.wasm' 6362 } )
@@ -77,11 +76,13 @@ export function parseError(errors: SourceError[], verbose: boolean = verboseErro
7776 // TODO currently elaboration is just tagged on to a new line after the error message itself. find a better
7877 // way to display it.
7978 const elaboration = error . elaborate ( )
80- return line < 1
79+ return typeof line === 'number' && line < 1
8180 ? `${ filePath } ${ explanation } \n${ elaboration } \n`
8281 : `${ filePath } Line ${ line } , Column ${ column } : ${ explanation } \n${ elaboration } \n`
8382 } else {
84- return line < 1 ? explanation : `${ filePath } Line ${ line } : ${ explanation } `
83+ return typeof line === 'number' && line < 1
84+ ? explanation
85+ : `${ filePath } Line ${ line } : ${ explanation } `
8586 }
8687 } )
8788 return errorMessagesArr . join ( '\n' )
@@ -91,7 +92,7 @@ export function findDeclaration(
9192 code : string ,
9293 context : Context ,
9394 loc : { line : number ; column : number }
94- ) : SourceLocation | null | undefined {
95+ ) : es . SourceLocation | null | undefined {
9596 const program = looseParse ( code , context )
9697 if ( ! program ) {
9798 return null
@@ -111,7 +112,7 @@ export function getScope(
111112 code : string ,
112113 context : Context ,
113114 loc : { line : number ; column : number }
114- ) : SourceLocation [ ] {
115+ ) : es . SourceLocation [ ] {
115116 const program = looseParse ( code , context )
116117 if ( ! program ) {
117118 return [ ]
@@ -132,7 +133,7 @@ export function getAllOccurrencesInScope(
132133 code : string ,
133134 context : Context ,
134135 loc : { line : number ; column : number }
135- ) : SourceLocation [ ] {
136+ ) : es . SourceLocation [ ] {
136137 const program = looseParse ( code , context )
137138 if ( ! program ) {
138139 return [ ]
0 commit comments