diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-03-28 19:16:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-28 14:16:57 -0400 |
commit | 3fac487461abf055165fe0e2bb962573950277b8 (patch) | |
tree | c0ba09a2049975f9eb8625365e3ba395e67d8b50 /cli/doc/type_alias.rs | |
parent | bced52505f32d6cca4f944bb610a8a26767908a8 (diff) |
feat: Add "deno doc" subcommand (#4500)
Diffstat (limited to 'cli/doc/type_alias.rs')
-rw-r--r-- | cli/doc/type_alias.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cli/doc/type_alias.rs b/cli/doc/type_alias.rs new file mode 100644 index 000000000..3740aee84 --- /dev/null +++ b/cli/doc/type_alias.rs @@ -0,0 +1,25 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +use serde::Serialize; +use swc_ecma_ast; + +use super::parser::DocParser; +use super::ts_type::TsTypeDef; + +#[derive(Debug, Serialize, Clone)] +#[serde(rename_all = "camelCase")] +pub struct TypeAliasDef { + pub ts_type: TsTypeDef, + // TODO: type_params +} + +pub fn get_doc_for_ts_type_alias_decl( + _doc_parser: &DocParser, + type_alias_decl: &swc_ecma_ast::TsTypeAliasDecl, +) -> (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 }; + + (alias_name, type_alias_def) +} |