@@ -133,6 +133,10 @@ pub struct JsxSpecs {
133133 pub v3_dependencies : Option < Vec < String > > ,
134134}
135135
136+ /// Empty struct - the gentype config is loaded by bsc
137+ #[ derive( Deserialize , Debug , Clone ) ]
138+ pub struct GenTypeConfig { }
139+
136140/// # bsconfig.json representation
137141/// This is tricky, there is a lot of ambiguity. This is probably incomplete.
138142#[ derive( Deserialize , Debug , Clone ) ]
@@ -157,6 +161,8 @@ pub struct Config {
157161 pub namespace : Option < NamespaceConfig > ,
158162 pub jsx : Option < JsxSpecs > ,
159163 pub uncurried : Option < bool > ,
164+ #[ serde( rename = "gentypeconfig" ) ]
165+ pub gentype_config : Option < GenTypeConfig > ,
160166 // this is a new feature of rewatch, and it's not part of the bsconfig.json spec
161167 #[ serde( rename = "namespace-entry" ) ]
162168 pub namespace_entry : Option < String > ,
@@ -366,6 +372,13 @@ impl Config {
366372 . or ( self . suffix . to_owned ( ) )
367373 . unwrap_or ( ".js" . to_string ( ) )
368374 }
375+
376+ pub fn get_gentype_arg ( & self ) -> Vec < String > {
377+ match & self . gentype_config {
378+ Some ( _) => vec ! [ "-bs-gentype" . to_string( ) ] ,
379+ None => vec ! [ ] ,
380+ }
381+ }
369382}
370383
371384#[ cfg( test) ]
@@ -389,4 +402,26 @@ mod tests {
389402 assert_eq ! ( config. get_suffix( ) , ".mjs" ) ;
390403 assert_eq ! ( config. get_module( ) , "es6" ) ;
391404 }
405+
406+ #[ test]
407+ fn test_detect_gentypeconfig ( ) {
408+ let json = r#"
409+ {
410+ "name": "my-monorepo",
411+ "sources": [ { "dir": "src/", "subdirs": true } ],
412+ "package-specs": [ { "module": "es6", "in-source": true } ],
413+ "suffix": ".mjs",
414+ "pinned-dependencies": [ "@teamwalnut/app" ],
415+ "bs-dependencies": [ "@teamwalnut/app" ],
416+ "gentypeconfig": {
417+ "module": "esmodule",
418+ "generatedFileExtension": ".gen.tsx"
419+ }
420+ }
421+ "# ;
422+
423+ let config = serde_json:: from_str :: < Config > ( json) . unwrap ( ) ;
424+ assert_eq ! ( config. gentype_config. is_some( ) , true ) ;
425+ assert_eq ! ( config. get_gentype_arg( ) , vec![ "-bs-gentype" . to_string( ) ] ) ;
426+ }
392427}
0 commit comments