bio-dts 0.15.1 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/generate-types.js +7 -3
- package/lib/post-transform.js +12 -2
- package/package.json +1 -1
package/lib/generate-types.js
CHANGED
|
@@ -151,15 +151,19 @@ export default function generateTypes(fileNames, compilerOptions, ts, generateOp
|
|
|
151
151
|
|
|
152
152
|
const combinedJSON = JSON.parse(JSON.stringify(combined));
|
|
153
153
|
|
|
154
|
-
// produce source maps with relative paths
|
|
155
|
-
|
|
154
|
+
// produce source maps with relative paths, following typescript conventions
|
|
155
|
+
const mapDir = path.dirname(path.resolve(fileName));
|
|
156
|
+
|
|
156
157
|
if (combinedJSON.sources) {
|
|
157
|
-
const mapDir = path.dirname(path.resolve(fileName));
|
|
158
158
|
combinedJSON.sources = combinedJSON.sources.map(src =>
|
|
159
159
|
path.relative(mapDir, path.resolve(src))
|
|
160
160
|
);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
if (combinedJSON.file) {
|
|
164
|
+
combinedJSON.file = path.relative(mapDir, path.resolve(fileName));
|
|
165
|
+
}
|
|
166
|
+
|
|
163
167
|
// keep maps small, do not inline source text in declaration maps
|
|
164
168
|
delete combinedJSON.sourcesContent;
|
|
165
169
|
|
package/lib/post-transform.js
CHANGED
|
@@ -409,7 +409,7 @@ export default function transform(src, transformOptions = {}) {
|
|
|
409
409
|
const returnTags = tags.filter(t => t.name === 'return' || t.name === 'returns');
|
|
410
410
|
|
|
411
411
|
if (returnTags.length > 1) {
|
|
412
|
-
throw error(hostPath.value,
|
|
412
|
+
throw error(hostPath.value, `must specify zero or one @return(s) in JSDoc - found ${returnTags.length}`);
|
|
413
413
|
}
|
|
414
414
|
|
|
415
415
|
return [
|
|
@@ -502,6 +502,14 @@ declare function p${
|
|
|
502
502
|
return replacements;
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
+
/**
|
|
506
|
+
* Clean the given (JSDoc) comment node - strip what is not necessary in
|
|
507
|
+
* type declarations: remove JSDoc only annotations, fixup type parameters.
|
|
508
|
+
*
|
|
509
|
+
* @param {any} comment - the comment node
|
|
510
|
+
*
|
|
511
|
+
* @return {any|null} - the cleaned comment node or null if it shall be dropped
|
|
512
|
+
*/
|
|
505
513
|
function cleanComment(comment) {
|
|
506
514
|
|
|
507
515
|
/**
|
|
@@ -566,11 +574,13 @@ declare function p${
|
|
|
566
574
|
}
|
|
567
575
|
|
|
568
576
|
/**
|
|
577
|
+
* Cleans comments on the given node - strip what is not necessary
|
|
578
|
+
* in type declarations.
|
|
579
|
+
*
|
|
569
580
|
* @param { Path<any> } nodePath
|
|
570
581
|
*/
|
|
571
582
|
function cleanComments(nodePath) {
|
|
572
583
|
|
|
573
|
-
// clean JSDoc comments: remove annotation, fixup type parameters
|
|
574
584
|
const comments = nodePath.get('comments') || { value: [] };
|
|
575
585
|
|
|
576
586
|
for (const key of keys(comments.value || []).reverse()) {
|