@@ -87,17 +87,17 @@ export class VSCode extends React.Component<Props> implements Editor {
8787 sandbox : Props [ 'sandbox' ] ;
8888 currentModule : Props [ 'currentModule' ] ;
8989 currentTitle : string ;
90- currentDirectoryShortid : string | undefined ;
90+ currentDirectoryShortid : string | null ;
9191 settings : Props [ 'settings' ] ;
9292 dependencies : Props [ 'dependencies' ] | undefined ;
9393 tsconfig : Props [ 'tsconfig' ] | undefined ;
9494 disposeInitializer ?: Function ;
95- lintWorker : Worker | undefined ;
95+ lintWorker : Worker | null ;
9696 editor ?: any ;
9797 monaco ?: any ;
9898 receivingCode : boolean = false ;
9999 codeSandboxAPIListener : ( ) => void ;
100- sizeProbeInterval : number | null ;
100+ sizeProbeInterval : number | undefined ;
101101
102102 modelSelectionListener : {
103103 dispose : ( ) => void ;
@@ -121,7 +121,7 @@ export class VSCode extends React.Component<Props> implements Editor {
121121 this . tsconfig = props . tsconfig ;
122122
123123 this . lintWorker = null ;
124- this . sizeProbeInterval = null ;
124+ this . sizeProbeInterval = undefined ;
125125
126126 this . resizeEditor = debounce ( this . resizeEditorInstantly , 150 ) ;
127127 this . commitLibChanges = debounce ( this . commitLibChangesInstantly , 300 ) ;
@@ -562,7 +562,9 @@ export class VSCode extends React.Component<Props> implements Editor {
562562 // Something went wrong while composing the operation, so we're opting for a full sync
563563 console . error ( e ) ;
564564
565- this . props . onModuleStateMismatch ( ) ;
565+ if ( this . props . onModuleStateMismatch ) {
566+ this . props . onModuleStateMismatch ( ) ;
567+ }
566568 }
567569
568570 requestAnimationFrame ( ( ) => {
@@ -650,7 +652,11 @@ export class VSCode extends React.Component<Props> implements Editor {
650652 pushStack = false ,
651653 model = this . editor . getActiveCodeEditor ( ) . getModel ( )
652654 ) => {
653- const results = [ ] ;
655+ const results : Array < {
656+ range : unknown ;
657+ text : string ;
658+ forceMoveMarkers ?: boolean ;
659+ } > = [ ] ;
654660 let index = 0 ;
655661 const currentEOLLength = model . getEOL ( ) . length ;
656662 let eolChanged = false ;
@@ -723,9 +729,15 @@ export class VSCode extends React.Component<Props> implements Editor {
723729 Object . keys ( operationsJSON ) . forEach ( moduleShortid => {
724730 const operation = TextOperation . fromJSON ( operationsJSON [ moduleShortid ] ) ;
725731
726- const moduleId = this . sandbox . modules . find (
732+ const foundModule = this . sandbox . modules . find (
727733 m => m . shortid === moduleShortid
728- ) . id ;
734+ ) ;
735+
736+ if ( ! foundModule ) {
737+ return ;
738+ }
739+
740+ const moduleId = foundModule . id ;
729741
730742 const modulePath =
731743 '/sandbox' +
@@ -754,7 +766,9 @@ export class VSCode extends React.Component<Props> implements Editor {
754766 }
755767 } catch ( e ) {
756768 // Something went wrong while applying
757- this . props . onModuleStateMismatch ( ) ;
769+ if ( this . props . onModuleStateMismatch ) {
770+ this . props . onModuleStateMismatch ( ) ;
771+ }
758772 }
759773 } else {
760774 this . liveOperationCode = '' ;
@@ -766,7 +780,7 @@ export class VSCode extends React.Component<Props> implements Editor {
766780 model . object . textEditorModel
767781 ) ;
768782
769- if ( this . props . onChange ) {
783+ if ( this . props . onChange && module ) {
770784 this . props . onChange (
771785 model . object . textEditorModel . getValue ( ) ,
772786 module . shortid
@@ -878,7 +892,7 @@ export class VSCode extends React.Component<Props> implements Editor {
878892 if ( ! this . lintWorker ) {
879893 this . lintWorker = new LinterWorker ( ) ;
880894
881- this . lintWorker . addEventListener ( 'message' , event => {
895+ this . lintWorker ! . addEventListener ( 'message' , event => {
882896 const { markers, version } = event . data ;
883897
884898 requestAnimationFrame ( ( ) => {
@@ -1033,7 +1047,7 @@ export class VSCode extends React.Component<Props> implements Editor {
10331047 return ;
10341048 }
10351049
1036- const mode = await getMode ( title , this . monaco ) ;
1050+ const mode = ( await getMode ( title , this . monaco ) ) || '' ;
10371051 if ( this . settings . lintEnabled ) {
10381052 if (
10391053 [ 'javascript' , 'typescript' , 'typescriptreact' , 'vue' ] . includes ( mode )
0 commit comments