From 3fac487461abf055165fe0e2bb962573950277b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 28 Mar 2020 19:16:57 +0100 Subject: feat: Add "deno doc" subcommand (#4500) --- cli/doc/type_alias.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 cli/doc/type_alias.rs (limited to 'cli/doc/type_alias.rs') 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) +} -- cgit v1.2.3