-
Notifications
You must be signed in to change notification settings - Fork 131
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
DeclarationReference: Parser does not handle certain inputs correctly #174
Comments
@rbuckton Seems like this is not an LR(1) problem. The current TSDoc parser scans forwards looking for the package delimiter ( tsdoc/tsdoc/src/parser/NodeParser.ts Lines 927 to 992 in 79c5511
Even if you could somehow represent this as LR(1), seems like the error messages may be better if the algorithm can tell whether something looks like an NPM package or not. |
@octogonz |
I might be able to work on it this weekend. Do you have any objection to simply scanning forwards until we find the Quoted NPM package names doesn't seem like a good option, since package names and import paths never need escapes in practice. They are much better behaved than TypeScript identifiers (which e.g. may be forced to match a freeform string key in an interface for a JSON object). |
No, its probably not a problem. I took a look and should have a PR up shortly. |
@rbuckton I validated that issues (1) and (2) are fixed, but issue (3) still repros: // (Actual) a.b c.d
// (Expected) SyntaxError
console.log(DeclarationReference.parse('a.b c.d').toString()); I'm going to go ahead and merge your PR, though, so we can unblock microsoft/rushstack#1406. I'll open a separate issue for this (relatively minor) edge case. |
@rbuckton I'm using this issue to track some bugs found while testing the DeclarationReference API. They are minor enough to be fixed in the same PR.
The
@microsoft/rush-stack-compiler-3.5
package name is not handled correctly because of the.
in the name:The parser wrongly accepts an NPM package name that is missing the
!
. The input should really be interpreted as a package, because@
is not a valid identifier, but packages should require the!
suffix to avoid confusion:The parser wrongly accepts identifiers containing spaces.
The text was updated successfully, but these errors were encountered: