1 | use super::{ToTypeDef, TypeDef}; |
2 | |
3 | use crate::{js_doc_from_comments, ty_to_ts_type, typegen::add_alias, NapiConst}; |
4 | |
5 | impl ToTypeDef for NapiConst { |
6 | fn to_type_def(&self) -> Option<TypeDef> { |
7 | if self.skip_typescript { |
8 | return None; |
9 | } |
10 | |
11 | add_alias(self.name.to_string(), self.js_name.to_string()); |
12 | |
13 | Some(TypeDef { |
14 | kind: "const" .to_owned(), |
15 | name: self.js_name.to_owned(), |
16 | original_name: Some(self.name.to_string()), |
17 | def: format!( |
18 | "export const {}: {}" , |
19 | &self.js_name, |
20 | ty_to_ts_type(&self.type_name, false, false, false).0 |
21 | ), |
22 | js_mod: self.js_mod.to_owned(), |
23 | js_doc: js_doc_from_comments(&self.comments), |
24 | }) |
25 | } |
26 | } |
27 | |