@@ -87,7 +87,15 @@ const window = new Adw.ApplicationWindow();
8787
8888function createLSPClients ( { root_uri } ) {
8989 return Object . fromEntries (
90- [ "javascript" , "blueprint" , "css" , "vala" , "rust" , "python" ] . map ( ( id ) => {
90+ [
91+ "javascript" ,
92+ "blueprint" ,
93+ "css" ,
94+ "vala" ,
95+ "rust" ,
96+ "python" ,
97+ "typescript" ,
98+ ] . map ( ( id ) => {
9199 const lang = languages . find ( ( language ) => language . id === id ) ;
92100 const lspc = createLSPClient ( {
93101 lang,
@@ -344,6 +352,73 @@ async function ci({ filenames }) {
344352 } ) ;
345353 }
346354
355+ const file_typescript = demo_dir . get_child ( "main.ts" ) ;
356+ if ( file_typescript . query_exists ( null ) ) {
357+ print ( ` ${ file_typescript . get_path ( ) } ` ) ;
358+
359+ const uri = file_typescript . get_uri ( ) ;
360+ const languageId = "typescript" ;
361+ let version = 0 ;
362+
363+ const [ contents ] = await file_typescript . load_contents_async ( null ) ;
364+ const text = new TextDecoder ( ) . decode ( contents ) ;
365+
366+ await lsp_clients . typescript . _notify ( "textDocument/didOpen" , {
367+ textDocument : {
368+ uri,
369+ languageId,
370+ version : version ++ ,
371+ text,
372+ } ,
373+ } ) ;
374+
375+ const diagnostics = await waitForDiagnostics ( {
376+ uri,
377+ lspc : lsp_clients . typescript ,
378+ } ) ;
379+ if ( diagnostics . length > 0 ) {
380+ printerr ( serializeDiagnostics ( { diagnostics } ) ) ;
381+ return false ;
382+ }
383+ print ( ` ✅ lints` ) ;
384+
385+ const checks = await checkFile ( {
386+ lspc : lsp_clients . typescript ,
387+ file : file_typescript ,
388+ lang : getLanguage ( "typescript" ) ,
389+ uri,
390+ } ) ;
391+ if ( ! checks ) return false ;
392+
393+ const js_object_ids = getCodeObjectIds ( text ) ;
394+ for ( const object_id of js_object_ids ) {
395+ if ( ! blueprint_object_ids . includes ( object_id ) ) {
396+ print ( ` ❌ Reference to inexistant object id "${ object_id } "` ) ;
397+ return false ;
398+ }
399+ }
400+
401+ globalThis . workbench = {
402+ window,
403+ application,
404+ builder,
405+ template,
406+ resolve ( path ) {
407+ return demo_dir . resolve_relative_path ( path ) . get_uri ( ) ;
408+ } ,
409+ preview ( ) { } ,
410+ } ;
411+
412+ await import ( `file://${ file_typescript . get_path ( ) } ` ) ;
413+ print ( " ✅ runs" ) ;
414+
415+ await lsp_clients . typescript . _notify ( "textDocument/didClose" , {
416+ textDocument : {
417+ uri,
418+ } ,
419+ } ) ;
420+ }
421+
347422 const file_vala = demo_dir . get_child ( "main.vala" ) ;
348423 if ( file_vala . query_exists ( null ) ) {
349424 print ( ` ${ file_vala . get_path ( ) } ` ) ;
0 commit comments