@@ -30,6 +30,7 @@ export async function get_tutorial_data(base = CONTENT_BASE_PATHS.TUTORIAL) {
3030 const tutorials = [ ] ;
3131
3232 for ( const subdir of await readdir ( base ) ) {
33+ /** @type {import('./types').TutorialDatum } */
3334 const section = {
3435 title : '' , // Initialise with empty
3536 slug : subdir . split ( '-' ) . slice ( 1 ) . join ( '-' ) ,
@@ -55,6 +56,12 @@ export async function get_tutorial_data(base = CONTENT_BASE_PATHS.TUTORIAL) {
5556 const { metadata, body } = extractFrontmatter ( contents ) ;
5657
5758 // Get the contents of the apps.
59+ /**
60+ * @type {{
61+ * initial: import('./types').CompletionState[];
62+ * complete: import('./types').CompletionState[];
63+ * }}
64+ */
5865 const completion_states_data = { initial : [ ] , complete : [ ] } ;
5966 for ( const app_dir of await readdir ( tutorial_base_dir ) ) {
6067 if ( ! app_dir . startsWith ( 'app-' ) ) continue ;
@@ -63,9 +70,13 @@ export async function get_tutorial_data(base = CONTENT_BASE_PATHS.TUTORIAL) {
6370 const app_contents = await readdir ( app_dir_path , 'utf-8' ) ;
6471
6572 for ( const file of app_contents ) {
73+ const type = file . split ( '.' ) . at ( - 1 ) ;
74+ if ( ! type ) {
75+ throw new Error ( `Could not determine type from ${ file } ` ) ;
76+ }
6677 completion_states_data [ app_dir === 'app-a' ? 'initial' : 'complete' ] . push ( {
6778 name : file ,
68- type : file . split ( '.' ) . at ( - 1 ) ,
79+ type,
6980 content : await readFile ( `${ app_dir_path } /${ file } ` , 'utf-8' )
7081 } ) ;
7182 }
0 commit comments