Skip to content

Commit

Permalink
feat(formats) Use TSDoc format for typescript/es6-declarations (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
christianvuerings authored Mar 16, 2023
1 parent e5ce325 commit a7f8827
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion __tests__/formats/__snapshots__/all.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ exports[`formats all should match typescript/es6-declarations snapshot 1`] = `
* Generated on Sat, 01 Jan 2000 00:00:00 GMT
*/
export const color_red : string; // comment"
/** comment */
export const color_red : string;"
`;
exports[`formats all should match typescript/module-declarations snapshot 1`] = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ exports[`formats typescript/es6-declarations with outputStringLiterals should ma
* Generated on Sat, 01 Jan 2000 00:00:00 GMT
*/
/** Used for errors */
export const colorRed : \\"#FF0000\\";"
`;
1 change: 1 addition & 0 deletions __tests__/formats/typeScriptEs6Declarations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const file = {
const properties = {
"color": {
"red": {
"comment": "Used for errors",
"name": "colorRed",
"value": "#FF0000"
}
Expand Down
5 changes: 3 additions & 2 deletions lib/common/formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,10 @@ module.exports = {
'typescript/es6-declarations': function({dictionary, file, options}) {
return fileHeader({file}) +
dictionary.allProperties.map(function(prop) {
var to_ret_prop = 'export const ' + prop.name + ' : ' + getTypeScriptType(prop.value, options) + ';';
let to_ret_prop = '';
if (prop.comment)
to_ret_prop = to_ret_prop.concat(' // ' + prop.comment);
to_ret_prop += '/** ' + prop.comment + ' */\n';
to_ret_prop += 'export const ' + prop.name + ' : ' + getTypeScriptType(prop.value, options) + ';';
return to_ret_prop;
}).join('\n');
},
Expand Down

0 comments on commit a7f8827

Please sign in to comment.