diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-04-08 17:03:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-08 17:03:42 +0200 |
commit | 491b8e1cea76753397bdeb0aeb1598bc78d22c8f (patch) | |
tree | 2eadbbcd2efe744c222c0d1b161a0131e498848b /cli/doc/type_alias.rs | |
parent | fe17496831a0b3dcd252d097c82df529d665aad5 (diff) |
feat(doc): handle function params and type params (#4672)
Diffstat (limited to 'cli/doc/type_alias.rs')
-rw-r--r-- | cli/doc/type_alias.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/cli/doc/type_alias.rs b/cli/doc/type_alias.rs index ad9933978..b26395c3f 100644 --- a/cli/doc/type_alias.rs +++ b/cli/doc/type_alias.rs @@ -1,15 +1,16 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -use crate::swc_ecma_ast; -use serde::Serialize; - use super::parser::DocParser; use super::ts_type::TsTypeDef; +use super::ts_type_param::maybe_type_param_decl_to_type_param_defs; +use super::ts_type_param::TsTypeParamDef; +use crate::swc_ecma_ast; +use serde::Serialize; #[derive(Debug, Serialize, Clone)] #[serde(rename_all = "camelCase")] pub struct TypeAliasDef { pub ts_type: TsTypeDef, - // TODO: type_params + pub type_params: Vec<TsTypeParamDef>, } pub fn get_doc_for_ts_type_alias_decl( @@ -18,8 +19,13 @@ pub fn get_doc_for_ts_type_alias_decl( ) -> (String, TypeAliasDef) { let alias_name = type_alias_decl.id.sym.to_string(); let ts_type = type_alias_decl.type_ann.as_ref().into(); - - let type_alias_def = TypeAliasDef { ts_type }; + let type_params = maybe_type_param_decl_to_type_param_defs( + type_alias_decl.type_params.as_ref(), + ); + let type_alias_def = TypeAliasDef { + ts_type, + type_params, + }; (alias_name, type_alias_def) } |