@@ -8,7 +8,7 @@ import type {
88 TSType ,
99 TSTypeParameterDeclaration ,
1010} from "@babel/types" ;
11- import { AnalysisError } from "./analysis/error.js" ;
11+ import { AnalysisError , SoftErrorRepository } from "./analysis/error.js" ;
1212import { BindThisSite , analyzeClassFields } from "./analysis/class_fields.js" ;
1313import { analyzeState , StateObjAnalysis } from "./analysis/state.js" ;
1414import { getAndDelete } from "./utils.js" ;
@@ -23,7 +23,7 @@ import type { PreAnalysisResult } from "./analysis/pre.js";
2323import type { LibRef } from "./analysis/lib.js" ;
2424import { EffectAnalysis , analyzeEffects } from "./analysis/effect.js" ;
2525
26- export { AnalysisError } from "./analysis/error.js" ;
26+ export { AnalysisError , SoftErrorRepository } from "./analysis/error.js" ;
2727
2828export type { LibRef } from "./analysis/lib.js" ;
2929export type { PreAnalysisResult } from "./analysis/pre.js" ;
@@ -63,14 +63,15 @@ export type AnalysisResult = {
6363
6464export function analyzeClass (
6565 path : NodePath < ClassDeclaration > ,
66- preanalysis : PreAnalysisResult
66+ preanalysis : PreAnalysisResult ,
67+ softErrors : SoftErrorRepository
6768) : AnalysisResult {
6869 const locals = new LocalManager ( path ) ;
6970 const {
7071 instanceFields : sites ,
7172 staticFields,
7273 bindThisSites,
73- } = analyzeClassFields ( path ) ;
74+ } = analyzeClassFields ( path , softErrors ) ;
7475
7576 const propsObjAnalysis = getAndDelete ( sites , "props" ) ?? { sites : [ ] } ;
7677 const defaultPropsObjAnalysis = getAndDelete (
@@ -84,6 +85,7 @@ export function analyzeClass(
8485 stateObjAnalysis ,
8586 setStateAnalysis ,
8687 locals ,
88+ softErrors ,
8789 preanalysis
8890 ) ;
8991
@@ -102,8 +104,10 @@ export function analyzeClass(
102104 analyzeOuterCapturings ( path , locals ) ;
103105 let renderPath : NodePath < ClassMethod > | undefined = undefined ;
104106 {
105- if ( renderAnalysis . sites . some ( ( site ) => site . type === "expr" ) ) {
106- throw new AnalysisError ( `do not use this.render` ) ;
107+ for ( const site of renderAnalysis . sites ) {
108+ if ( site . type === "expr" ) {
109+ softErrors . addThisError ( site . thisPath ) ;
110+ }
107111 }
108112 const init = renderAnalysis . sites . find ( ( site ) => site . init ) ;
109113 if ( init ) {
@@ -112,7 +116,7 @@ export function analyzeClass(
112116 }
113117 }
114118 }
115- const userDefined = analyzeUserDefined ( sites ) ;
119+ const userDefined = analyzeUserDefined ( sites , softErrors ) ;
116120 for ( const [ name ] of staticFields ) {
117121 if ( ! SPECIAL_STATIC_NAMES . has ( name ) ) {
118122 throw new AnalysisError ( `Cannot transform static ${ name } ` ) ;
@@ -127,6 +131,7 @@ export function analyzeClass(
127131 propsObjAnalysis ,
128132 defaultPropsObjAnalysis ,
129133 locals ,
134+ softErrors ,
130135 preanalysis
131136 ) ;
132137 postAnalyzeCallbackDependencies ( userDefined , props , states , sites ) ;
0 commit comments