Skip to content

Commit

Permalink
fix: * to any work with strings now
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored and hosseinmd committed Feb 1, 2021
1 parent 43aa632 commit 95bb610
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ function convertToModernType(oldType: string): string {
// JSDoc supports generics of the form `Foo.<Arg1, Arg2>`
type = type.replace(/\.</g, "<");

type = type.replace(/\*/g, " any ");

// convert `Array<Foo>` to `Foo[]`
type = type.replace(
/(?:^|[^$\w\xA0-\uFFFF])Array\s*<((?:[^<>=]|=>|=(?!>)|<(?:[^<>=]|=>|=(?!>))+>)+)>/g,
Expand Down Expand Up @@ -51,10 +53,9 @@ function withoutStrings(type: string, mapFn: (type: string) => string): string {

function formatType(type: string, options?: Options): string {
try {
let pretty = type.replace("*", "any");
const TYPE_START = "type name = ";

pretty = format(`${TYPE_START}${pretty}`, {
let pretty = format(`${TYPE_START}${type}`, {
...options,
parser: "typescript",
});
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/main.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ exports[`Sould keep params ordering when more than 10 tags are present 1`] = `
* @param {?undefined} test4 Test param
* @param {!undefined} test5 Test param
* @param {any} test6 Test param
* @param {\\"*\\"} test6 Test param
* @param {?Number} test7 Test param
* @param {...Number} test8 Test param
* @param {!Number} test9 Test param
Expand Down
1 change: 1 addition & 0 deletions tests/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ test("Sould keep params ordering when more than 10 tags are present", () => {
* @param {?undefined} test4 Test param
* @param {!undefined} test5 Test param
* @param {*} test6 Test param
* @param {"*"} test6 Test param
* @param {?Number} test7 Test param
* @param {...Number} test8 Test param
* @param {!Number} test9 Test param
Expand Down

0 comments on commit 95bb610

Please sign in to comment.