summaryrefslogtreecommitdiff
path: root/cli/doc/ts_type.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-04-30 16:40:51 +0200
committerGitHub <noreply@github.com>2020-04-30 16:40:51 +0200
commit4993a6504b4b447e0e02454094cffb02ee18c081 (patch)
tree16f694212b2ee0c3cacbd11f55f2e2ba8ea216f5 /cli/doc/ts_type.rs
parent81c75332fbf2635f5275cc85053dc244f211471d (diff)
fix(doc): better repr for object literal types (#4998)
Diffstat (limited to 'cli/doc/ts_type.rs')
-rw-r--r--cli/doc/ts_type.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/cli/doc/ts_type.rs b/cli/doc/ts_type.rs
index 8359f64cc..b5f5a8807 100644
--- a/cli/doc/ts_type.rs
+++ b/cli/doc/ts_type.rs
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+use super::interface::expr_to_name;
use super::params::ts_fn_param_to_param_def;
use super::ts_type_param::maybe_type_param_decl_to_type_param_defs;
use super::ts_type_param::TsTypeParamDef;
@@ -24,7 +25,6 @@ use crate::swc_ecma_ast::TsTypeQuery;
use crate::swc_ecma_ast::TsTypeRef;
use crate::swc_ecma_ast::TsUnionOrIntersectionType;
use serde::Serialize;
-
// pub enum TsType {
// * TsKeywordType(TsKeywordType),
// * TsThisType(TsThisType),
@@ -354,8 +354,9 @@ impl Into<TsTypeDef> for &TsTypeLit {
let type_params = maybe_type_param_decl_to_type_param_defs(
ts_method_sig.type_params.as_ref(),
);
+ let name = expr_to_name(&*ts_method_sig.key);
let method_def = LiteralMethodDef {
- name: "<TODO>".to_string(),
+ name,
params,
return_type: maybe_return_type,
type_params,
@@ -363,10 +364,7 @@ impl Into<TsTypeDef> for &TsTypeLit {
methods.push(method_def);
}
TsPropertySignature(ts_prop_sig) => {
- let name = match &*ts_prop_sig.key {
- swc_ecma_ast::Expr::Ident(ident) => ident.sym.to_string(),
- _ => "TODO".to_string(),
- };
+ let name = expr_to_name(&*ts_prop_sig.key);
let mut params = vec![];