@@ -56,6 +56,20 @@ const { some } = Astro.props
5656---
5757<div>{some}</div>"# ;
5858
59+ const ASTRO_FILE_WITH_TS_SCRIPT_TAG : & str = r#"---
60+ const title = "My Page";
61+ ---
62+ <html>
63+ <body>
64+ <script>
65+ const message: string = "Hello TypeScript";
66+ function greet(name: string): void {
67+ console.log( message + ", " + name );
68+ }
69+ </script>
70+ </body>
71+ </html>"# ;
72+
5973#[ test]
6074fn format_astro_files ( ) {
6175 let fs = MemoryFileSystem :: default ( ) ;
@@ -620,3 +634,36 @@ fn astro_global_object() {
620634 result,
621635 ) ) ;
622636}
637+
638+ #[ test]
639+ fn format_astro_with_typescript_script_tag ( ) {
640+ let fs = MemoryFileSystem :: default ( ) ;
641+ let mut console = BufferConsole :: default ( ) ;
642+
643+ fs. insert (
644+ "biome.json" . into ( ) ,
645+ r#"{ "html": { "formatter": {"enabled": true}, "linter": {"enabled": true}, "experimentalFullSupportEnabled": true } }"# . as_bytes ( ) ,
646+ ) ;
647+
648+ let astro_file_path = Utf8Path :: new ( "file.astro" ) ;
649+ fs. insert (
650+ astro_file_path. into ( ) ,
651+ ASTRO_FILE_WITH_TS_SCRIPT_TAG . as_bytes ( ) ,
652+ ) ;
653+
654+ let ( fs, result) = run_cli (
655+ fs,
656+ & mut console,
657+ Args :: from ( [ "format" , "--write" , astro_file_path. as_str ( ) ] . as_slice ( ) ) ,
658+ ) ;
659+
660+ assert ! ( result. is_ok( ) , "run_cli returned {result:?}" ) ;
661+
662+ assert_cli_snapshot ( SnapshotPayload :: new (
663+ module_path ! ( ) ,
664+ "format_astro_with_typescript_script_tag" ,
665+ fs,
666+ console,
667+ result,
668+ ) ) ;
669+ }
0 commit comments