DeclarationReference: Parser does not handle certain inputs correctly
See original GitHub issue@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:// (Actual) SyntaxError: SyntaxError: Invalid Component '@microsoft/rush-stack-compiler-3.5' // (Expected) @microsoft/rush-stack-compiler-3.5! console.log(DeclarationReference.package('@microsoft/rush-stack-compiler-3.5').toString()); // (Actual) @microsoft/rush-stack-compiler-3.5 // (Expected) @microsoft/rush-stack-compiler-3.5! console.log(DeclarationReference.parse('@microsoft/rush-stack-compiler-3.5!').toString()); // (Works correctly) @scope/package! console.log(DeclarationReference.parse('@scope/package!').toString());
-
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:// (Actual) @scope/my-package // (Expected) SyntaxError console.log(DeclarationReference.parse('@scope/my-package').toString()); // (Works correctly) @scope/my-package! console.log(DeclarationReference.parse('@scope/my-package!').toString());
-
The parser wrongly accepts identifiers containing spaces.
// (Actual) a.b c.d // (Expected) SyntaxError console.log(DeclarationReference.parse('a.b c.d').toString());
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
[api-extractor] Add an experimental new ApiItem ... - GitHub
It is marked as @beta, but the values are written in the .api.json file format for ... DeclarationReference: Parser does not handle certain...
Read more >CS 301: Roost Compiler Front End
In this project stage, you will implement the syntax analysis and semantic analysis components (the “front end”) of the Roost compiler. You will...
Read more >Explanation of the error messages for the W3C Markup Validator
This error may appear when the validator receives an empty document. Please make sure that the document you are uploading is not empty,...
Read more >TSDoc
TSDoc is a proposal to standardize the doc comments used in TypeScript code, ... Here's some examples of popular tools that need to...
Read more >Good practices for parsing user inputs with special characters?
However, the system is designed to handle more complex queries. As you can see from the previous query, the data field name and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
I’m going to go ahead and merge your PR, though, so we can unblock https://github.com/microsoft/web-build-tools/pull/1406. I’ll open a separate issue for this (relatively minor) edge case.