44
55import inquirer from 'inquirer' ;
66
7- const directionsPrompt : Parameters < typeof inquirer . prompt > [ 0 ] = {
8- type : 'list' ,
9- name : 'direction' ,
10- message : 'Which direction would you like to go?' ,
11- choices : [ 'Forward' , 'Right' , 'Left' , 'Back' ] ,
12- } ;
13-
147async function main ( ) {
158 console . log ( 'You find youself in a small room, there is a door in front of you.' ) ;
169 await exitHouse ( ) ;
1710}
1811
1912async function exitHouse ( ) {
20- const answers = await inquirer . prompt ( directionsPrompt ) ;
13+ const answers = await inquirer . prompt < { direction : string } > ( {
14+ type : 'list' ,
15+ name : 'direction' ,
16+ message : 'Which direction would you like to go?' ,
17+ choices : [ 'Forward' , 'Right' , 'Left' , 'Back' ] ,
18+ } ) ;
2119 if ( answers [ 'direction' ] === 'Forward' ) {
2220 console . log ( 'You find yourself in a forest' ) ;
2321 console . log (
@@ -31,7 +29,12 @@ async function exitHouse() {
3129}
3230
3331async function encounter1 ( ) {
34- const answers = await inquirer . prompt ( directionsPrompt ) ;
32+ const answers = await inquirer . prompt < { direction : string } > ( {
33+ type : 'list' ,
34+ name : 'direction' ,
35+ message : 'Which direction would you like to go?' ,
36+ choices : [ 'Forward' , 'Right' , 'Left' , 'Back' ] ,
37+ } ) ;
3538 if ( answers [ 'direction' ] === 'Forward' ) {
3639 console . log ( 'You attempt to fight the wolf' ) ;
3740 console . log ( 'Theres a stick and some stones lying around you could use as a weapon' ) ;
@@ -47,7 +50,12 @@ async function encounter1() {
4750}
4851
4952async function encounter2a ( ) {
50- const answers = await inquirer . prompt ( directionsPrompt ) ;
53+ const answers = await inquirer . prompt < { direction : string } > ( {
54+ type : 'list' ,
55+ name : 'direction' ,
56+ message : 'Which direction would you like to go?' ,
57+ choices : [ 'Forward' , 'Right' , 'Left' , 'Back' ] ,
58+ } ) ;
5159 if ( answers [ 'direction' ] === 'Forward' ) {
5260 let output = 'You find a painted wooden sign that says:' ;
5361 output += ' \n' ;
@@ -63,7 +71,7 @@ async function encounter2a() {
6371}
6472
6573async function encounter2b ( ) {
66- await inquirer . prompt ( {
74+ await inquirer . prompt < { weapon : string } > ( {
6775 type : 'list' ,
6876 name : 'weapon' ,
6977 message : 'Pick one' ,
0 commit comments