@@ -86,7 +86,7 @@ class VirtualMachine extends EventEmitter {
8686 asyncLoadingProjectAssetsSupported : boolean ;
8787 _dragTarget : RenderedTarget | null ;
8888 _assetsLoadProgress : Progress | null ;
89- extensionManager : any ;
89+ extensionManager : ExtensionManager ;
9090 securityManager : any ;
9191 exports : {
9292 Sprite : typeof Sprite ;
@@ -399,7 +399,7 @@ class VirtualMachine extends EventEmitter {
399399 this . extensionManager = new ExtensionManager ( this ) ;
400400 this . securityManager = this . extensionManager . securityManager ;
401401 // extensionManager is attached dynamically (not declared on Runtime).
402- ( this . runtime as any ) . extensionManager = this . extensionManager ;
402+ this . runtime . extensionManager = this . extensionManager ;
403403
404404 // Load core extensions
405405 for ( const id of CORE_EXTENSIONS ) {
@@ -677,7 +677,7 @@ class VirtualMachine extends EventEmitter {
677677 // Support non-blocking loading of project assets.
678678 if ( this . asyncLoadingProjectAssetsSupported ) {
679679 this . runtime . asyncLoadingProjectAssets = true ;
680- ( this . runtime as any ) . isLoadProjectAssetsNonBlocking = true ;
680+ this . runtime . isLoadProjectAssetsNonBlocking = true ;
681681 }
682682 const _projectProcessingUniqueId = ( this . _projectProcessingUniqueId =
683683 Math . random ( ) ) ;
@@ -696,7 +696,7 @@ class VirtualMachine extends EventEmitter {
696696 }
697697
698698 const validationPromise = new Promise ( ( resolve , reject ) => {
699- const { default : validate } = ScratchParser ;
699+ const { default : validate } = ScratchParser ;
700700 // The second argument of false below indicates to the validator that the
701701 // input should be parsed/validated as an entire project (and not a single sprite)
702702 validate ( input , false , ( error : any , res : unknown ) => {
@@ -769,7 +769,7 @@ class VirtualMachine extends EventEmitter {
769769 } )
770770 . then ( ( ) => this . runtime . handleProjectLoaded ( ) )
771771 . then ( ( ) => {
772- ( this . runtime as any ) . isLoadProjectAssetsNonBlocking = false ;
772+ this . runtime . isLoadProjectAssetsNonBlocking = false ;
773773 this . runtime . fireWaitingLoadCallbackQueue ( ) ;
774774 } )
775775 . catch ( ( error ) => {
@@ -1239,7 +1239,7 @@ class VirtualMachine extends EventEmitter {
12391239 * @type {[{id: string; url?: string}] }
12401240 */
12411241 const extInfo : Array < { id : string ; url ?: string } > = [ ] ;
1242- extensions . extensionIDs . forEach ( ( extensionID : string | number ) => {
1242+ extensions . extensionIDs . forEach ( ( extensionID : string ) => {
12431243 // 跳过已加载
12441244 if ( this . extensionManager . isExtensionLoaded ( extensionID ) ) return ;
12451245 // 跳过 builtin
@@ -1886,11 +1886,7 @@ class VirtualMachine extends EventEmitter {
18861886 x : 0 ,
18871887 y : 0 ,
18881888 } ;
1889- ( target . blocks as any ) . createBlock (
1890- shadowBlock ,
1891- "default" ,
1892- undefined ,
1893- ) ;
1889+ target . blocks . createBlock ( shadowBlock , "default" ) ;
18941890 this . runtime . emitTargetBlocksChanged (
18951891 targetId ,
18961892 [ "add" , [ shadowBlock ] ] ,
@@ -2487,7 +2483,7 @@ class VirtualMachine extends EventEmitter {
24872483 newName : string ,
24882484 sendNameChangedEvent : boolean = true ,
24892485 ) {
2490- const target = this . runtime . getTargetById ( targetId ) as any ;
2486+ const target = this . runtime . getTargetById ( targetId ) as RenderedTarget ;
24912487 if ( target ) {
24922488 if ( ! target . isSprite ( ) ) {
24932489 throw new Error ( "Cannot rename non-sprite targets." ) ;
@@ -2837,7 +2833,7 @@ class VirtualMachine extends EventEmitter {
28372833 // Create an array promises for extensions to load
28382834 const extensionPromises = Array . from ( extensionIDs , ( id ) =>
28392835 // Only support builtin extension for now, so not using extensionURLs to load
2840- this . extensionManager . loadExtensionURL ( id ) ,
2836+ this . extensionManager . loadExtensionURL ( id as string ) ,
28412837 ) ;
28422838
28432839 return Promise . all ( extensionPromises ) . then ( ( ) => {
@@ -3133,7 +3129,7 @@ class VirtualMachine extends EventEmitter {
31333129 continue ;
31343130 }
31353131 globalProcedures = globalProcedures . concat (
3136- ( target as any ) . blocks . getGlobalProceduresXML ( ) ,
3132+ target . blocks . getGlobalProceduresXML ( ) ,
31373133 ) ;
31383134 }
31393135 return globalProcedures ;
0 commit comments