mirror of
https://github.com/denoland/deno.git
synced 2024-12-27 17:49:08 -05:00
fix(doc): crash on formatting type predicate (#5651)
This commit is contained in:
parent
949061c4b6
commit
0fb5f23466
2 changed files with 16 additions and 0 deletions
|
@ -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 => {
|
||||
|
|
|
@ -161,6 +161,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#"
|
||||
|
|
Loading…
Reference in a new issue