Skip to content

Regex replace paren notation with dot notation for properties on types #14 #15

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jcurtis-cc
Copy link

@jcurtis-cc jcurtis-cc commented Apr 25, 2023

this change will allow JSDoc to parse any docstrings using the syntax in #14 which is used by VSCode / intellisense. Currently, JSDoc throws if it encounters these, when this plugin successfully imports them from another file.

The output is the same as if dot notation was used to reference a type's property (JSDoc compatible).

index.js:226

  e.comment = e.comment.replace(typeRegex, (typeExpr) => {
    typeExpr = typeExpr.replace(/\[["'](.*)['"]\]/g, ".$1"); 
    return typeExpr.replace(identifiers, (identifier) => {
      return (fileInfo.moduleId && typeDefsSet.has(identifier)) ?
        `module:${fileInfo.moduleId}~${identifier}` : identifier

There is a separate issue where dot notation used on a type to reference a property is not correctly assigned to the module - which this PR doesn't fix, but it does fix the issue above and allow docs to be built.

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

Successfully merging this pull request may close these issues.

2 participants