diff options
-rw-r--r-- | cli/doc/printer.rs | 3 | ||||
-rw-r--r-- | cli/doc/tests.rs | 13 |
2 files changed, 16 insertions, 0 deletions
diff --git a/cli/doc/printer.rs b/cli/doc/printer.rs index 7a6b9e731..f7f41079d 100644 --- a/cli/doc/printer.rs +++ b/cli/doc/printer.rs @@ -127,6 +127,9 @@ fn render_params(params: Vec<doc::ParamDef>) -> String { } fn render_ts_type(ts_type: doc::ts_type::TsTypeDef) -> String { + if ts_type.kind.is_none() { + return "<UNIMPLEMENTED>".to_string(); + } let kind = ts_type.kind.unwrap(); match kind { TsTypeDefKind::Array => { diff --git a/cli/doc/tests.rs b/cli/doc/tests.rs index f8e693c9a..7f2c18639 100644 --- a/cli/doc/tests.rs +++ b/cli/doc/tests.rs @@ -162,6 +162,19 @@ export function foo(a: string, b?: number, cb: (...cbArgs: unknown[]) => void, . } #[tokio::test] +async fn format_type_predicate() { + let source_code = r#" +export function isFish(pet: Fish | Bird): pet is Fish { + return (pet as Fish).swim !== undefined; +} +"#; + let loader = + TestLoader::new(vec![("test.ts".to_string(), source_code.to_string())]); + let entries = DocParser::new(loader).parse("test.ts").await.unwrap(); + super::printer::format(entries); +} + +#[tokio::test] async fn export_fn2() { let source_code = r#" interface AssignOpts { |