Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSDoc imported types from namespaced packages do not work #88

Open
ekhaled opened this issue May 5, 2023 · 1 comment
Open

JSDoc imported types from namespaced packages do not work #88

ekhaled opened this issue May 5, 2023 · 1 comment

Comments

@ekhaled
Copy link
Contributor

ekhaled commented May 5, 2023

This works:

/**
* @type {import(./types).CustomType}
*/
let v1 = "something"

However, this doesn't:

/**
* @type {import(@someNamespace/package).CustomType}
*/
let v1 = "something"

The problem is this line https://github.com/alexprey/sveltedoc-parser/blob/dev/lib/utils.js#L7
That regex fails because of the second @ symbol on that line.

@ekhaled
Copy link
Contributor Author

ekhaled commented May 5, 2023

A possible fix is:

     const parsedText = text.split(/\n/)
        .map((line) => {
            return line.trim()
                .replace(/^\/\*+/, '').trim()
                .replace(/\s*\*+\/$/, '').trim()
+                .replace(/import\((\s*)(['|"])\@/, "import($1$2").trim()
                .replace(/^\s*\*/, '').trim();
        })
        .join('\n')
        .trim();

Not sure, how open you are to that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant