@@ -209,24 +209,30 @@ pub fn generate_typescript_defs(dir: String, output: String) -> Result<()> {
209209 defs. push_str ( "// DO NOT EDIT MANUALLY OR ELSE IT WILL BE OVERWRITTEN\n \n " ) ;
210210 defs. push_str ( "/* eslint-disable */\n " ) ;
211211 defs. push_str ( "export interface Lang {\n " ) ;
212+
212213 if let Some ( first_lang) = langs. values ( ) . next ( ) {
213214 for key in first_lang. keys ( ) {
214- // add comments with the value
215215 if let Some ( value) = first_lang. get ( key) {
216- let comment_lines: Vec < & str > = value. lines ( ) . collect ( ) ;
217- if comment_lines. len ( ) == 1 {
218- defs. push_str ( & format ! ( " /** {} */\n " , comment_lines[ 0 ] ) ) ;
216+ let trimmed = value. trim ( ) ;
217+ let cm: Vec < & str > = value. lines ( ) . collect ( ) ;
218+ if cm. len ( ) == 1 {
219+ defs. push_str ( & format ! ( " /** {} */\n " , cm[ 0 ] ) ) ;
219220 } else {
220221 defs. push_str ( " /**\n " ) ;
221- for line in comment_lines {
222+ for line in cm {
222223 defs. push_str ( & format ! ( " * {}\n " , line) ) ;
223224 }
224225 defs. push_str ( " */\n " ) ;
225226 }
227+ if trimmed. starts_with ( '[' ) && trimmed. ends_with ( ']' ) {
228+ defs. push_str ( & format ! ( " '{}': string[];\n " , key) ) ;
229+ } else {
230+ defs. push_str ( & format ! ( " '{}': string;\n " , key) ) ;
231+ }
226232 }
227- defs. push_str ( & format ! ( " '{}': string;\n " , key) ) ;
228233 }
229234 }
235+
230236 defs. push_str ( "}\n \n " ) ;
231237 defs. push_str ( "export interface Langs {\n " ) ;
232238 for lang in langs. keys ( ) {
0 commit comments