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
Assignees
Labels
bug Something isn't working

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

@KatChaotic KatChaotic added the bug Something isn't working label Oct 25, 2024
@KatChaotic KatChaotic self-assigned this Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants