@@ -6,6 +6,7 @@ import { getLocator } from 'locate-character';
66import { walk } from 'zimmerframe' ;
77import { validate_component_options , validate_module_options } from './validate-options.js' ;
88import { convert } from './legacy.js' ;
9+ import { CompileError } from './errors.js' ;
910export { default as preprocess } from './preprocess/index.js' ;
1011
1112/**
@@ -30,12 +31,8 @@ export function compile(source, options) {
3031 const result = transform_component ( analysis , source , combined_options ) ;
3132 return result ;
3233 } catch ( e ) {
33- if ( /** @type {any } */ ( e ) . name === 'CompileError' ) {
34- handle_compile_error (
35- /** @type {import('#compiler').CompileError } */ ( e ) ,
36- options . filename ,
37- source
38- ) ;
34+ if ( e instanceof CompileError ) {
35+ handle_compile_error ( e , options . filename , source ) ;
3936 }
4037
4138 throw e ;
@@ -56,12 +53,8 @@ export function compileModule(source, options) {
5653 const analysis = analyze_module ( parse_acorn ( source , false ) , validated ) ;
5754 return transform_module ( analysis , source , validated ) ;
5855 } catch ( e ) {
59- if ( /** @type {any } */ ( e ) . name === 'CompileError' ) {
60- handle_compile_error (
61- /** @type {import('#compiler').CompileError } */ ( e ) ,
62- options . filename ,
63- source
64- ) ;
56+ if ( e instanceof CompileError ) {
57+ handle_compile_error ( e , options . filename , source ) ;
6558 }
6659
6760 throw e ;
@@ -106,12 +99,8 @@ export function parse(source, options = {}) {
10699 try {
107100 ast = _parse ( source ) ;
108101 } catch ( e ) {
109- if ( /** @type {any } */ ( e ) . name === 'CompileError' ) {
110- handle_compile_error (
111- /** @type {import('#compiler').CompileError } */ ( e ) ,
112- options . filename ,
113- source
114- ) ;
102+ if ( e instanceof CompileError ) {
103+ handle_compile_error ( e , options . filename , source ) ;
115104 }
116105
117106 throw e ;
0 commit comments