Comparing version 2.1.2 to 2.1.3
@@ -9,2 +9,24 @@ "use strict"; | ||
const readonlyModifier = ts.createModifier(ts.SyntaxKind.ReadonlyKeyword); | ||
const rgxIdentifier = /^[a-zA-Z\$_][a-zA-Z0-9\$_]+$/; | ||
const reservedWords = [ | ||
'break', 'do', 'instanceof', 'typeof', | ||
'case', 'else', 'new', 'var', | ||
'catch', 'finally', 'return', 'void', | ||
'continue', 'for', 'switch', 'while', | ||
'debugger', 'function', 'this', 'with', | ||
'default', 'if', 'throw', | ||
'delete', 'in', 'try', | ||
'class', 'enum', 'extends', 'super', | ||
'const', 'export', 'import', | ||
'implements', 'let', 'private', 'public', 'yield', | ||
'interface', 'package', 'protected', 'static', | ||
'null', 'true', 'false', | ||
]; | ||
function isValidIdentifier(name) { | ||
if (!name || !rgxIdentifier.test(name)) | ||
return false; | ||
if (reservedWords.indexOf(name) !== -1) | ||
return false; | ||
return true; | ||
} | ||
function validateClassLikeChildren(children, validate, msg) { | ||
@@ -187,3 +209,7 @@ if (children) { | ||
} | ||
const name = ts.createIdentifier(doclet.name); | ||
let name; | ||
if (isValidIdentifier(doclet.name)) | ||
name = ts.createIdentifier(doclet.name); | ||
else | ||
name = ts.createStringLiteral(doclet.name); | ||
return handleComment(doclet, ts.createModuleDeclaration(undefined, mods, name, body, flags)); | ||
@@ -190,0 +216,0 @@ } |
{ | ||
"name": "tsd-jsdoc", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "Compiles JSDoc annotated javascript into a Typescript Declaration File (.d.ts).", | ||
@@ -5,0 +5,0 @@ "main": "dist/publish.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80421
906