@microsoft/api-extractor 7.38.1 → 7.38.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +23 -23
  2. package/README.md +51 -51
  3. package/bin/api-extractor +2 -2
  4. package/extends/tsdoc-base.json +72 -72
  5. package/lib/aedoc/PackageDocComment.js.map +1 -1
  6. package/lib/analyzer/AstDeclaration.js.map +1 -1
  7. package/lib/analyzer/AstEntity.js.map +1 -1
  8. package/lib/analyzer/AstImport.js.map +1 -1
  9. package/lib/analyzer/AstModule.js.map +1 -1
  10. package/lib/analyzer/AstNamespaceImport.js.map +1 -1
  11. package/lib/analyzer/AstReferenceResolver.js.map +1 -1
  12. package/lib/analyzer/AstSymbol.js.map +1 -1
  13. package/lib/analyzer/AstSymbolTable.js.map +1 -1
  14. package/lib/analyzer/ExportAnalyzer.js.map +1 -1
  15. package/lib/analyzer/PackageMetadataManager.js.map +1 -1
  16. package/lib/analyzer/SourceFileLocationFormatter.js.map +1 -1
  17. package/lib/analyzer/Span.js.map +1 -1
  18. package/lib/analyzer/SyntaxHelpers.js.map +1 -1
  19. package/lib/analyzer/TypeScriptHelpers.js.map +1 -1
  20. package/lib/analyzer/TypeScriptInternals.js.map +1 -1
  21. package/lib/api/CompilerState.js.map +1 -1
  22. package/lib/api/ConsoleMessageId.js.map +1 -1
  23. package/lib/api/Extractor.js.map +1 -1
  24. package/lib/api/ExtractorConfig.js.map +1 -1
  25. package/lib/api/ExtractorLogLevel.js.map +1 -1
  26. package/lib/api/ExtractorMessage.js.map +1 -1
  27. package/lib/api/ExtractorMessageId.js.map +1 -1
  28. package/lib/api/IConfigFile.js.map +1 -1
  29. package/lib/cli/ApiExtractorCommandLine.js.map +1 -1
  30. package/lib/cli/InitAction.js.map +1 -1
  31. package/lib/cli/RunAction.js.map +1 -1
  32. package/lib/collector/ApiItemMetadata.js.map +1 -1
  33. package/lib/collector/Collector.js.map +1 -1
  34. package/lib/collector/CollectorEntity.js.map +1 -1
  35. package/lib/collector/DeclarationMetadata.js.map +1 -1
  36. package/lib/collector/MessageRouter.js.map +1 -1
  37. package/lib/collector/SourceMapper.js.map +1 -1
  38. package/lib/collector/SymbolMetadata.js.map +1 -1
  39. package/lib/collector/VisitorState.js.map +1 -1
  40. package/lib/collector/WorkingPackage.js.map +1 -1
  41. package/lib/enhancers/DocCommentEnhancer.js.map +1 -1
  42. package/lib/enhancers/ValidationEnhancer.js.map +1 -1
  43. package/lib/generators/ApiModelGenerator.js.map +1 -1
  44. package/lib/generators/ApiReportGenerator.d.ts +1 -0
  45. package/lib/generators/ApiReportGenerator.d.ts.map +1 -1
  46. package/lib/generators/ApiReportGenerator.js +17 -9
  47. package/lib/generators/ApiReportGenerator.js.map +1 -1
  48. package/lib/generators/DeclarationReferenceGenerator.js.map +1 -1
  49. package/lib/generators/DtsEmitHelpers.js.map +1 -1
  50. package/lib/generators/DtsRollupGenerator.js.map +1 -1
  51. package/lib/generators/ExcerptBuilder.js.map +1 -1
  52. package/lib/generators/IndentedWriter.js.map +1 -1
  53. package/lib/index.js.map +1 -1
  54. package/lib/schemas/api-extractor-defaults.json +95 -95
  55. package/lib/schemas/api-extractor-template.json +427 -427
  56. package/lib/schemas/api-extractor.schema.json +229 -229
  57. package/lib/start.js.map +1 -1
  58. package/package.json +3 -3
package/LICENSE CHANGED
@@ -1,24 +1,24 @@
1
- @microsoft/api-extractor
2
-
3
- Copyright (c) Microsoft Corporation. All rights reserved.
4
-
5
- MIT License
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining
8
- a copy of this software and associated documentation files (the
9
- "Software"), to deal in the Software without restriction, including
10
- without limitation the rights to use, copy, modify, merge, publish,
11
- distribute, sublicense, and/or sell copies of the Software, and to
12
- permit persons to whom the Software is furnished to do so, subject to
13
- the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be
16
- included in all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1
+ @microsoft/api-extractor
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
24
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,51 +1,51 @@
1
- # @microsoft/api-extractor
2
-
3
-
4
- ![API Extractor](https://github.com/microsoft/rushstack/raw/main/common/wiki-images/api-extractor-title.png?raw=true)
5
- <br />
6
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; https://api-extractor.com/
7
-
8
- <!-- ------------------------------------------------------------------ -->
9
- <!-- Text below this line should stay in sync with the web site content -->
10
- <!-- ------------------------------------------------------------------ -->
11
-
12
- **API Extractor** helps you build better [TypeScript](https://www.typescriptlang.org/) library packages. Suppose for example that your company has published an NPM package called "**awesome-widgets**" that exports many classes and interfaces. As developers start to depend on your library, you may encounter issues such as...
13
-
14
- - **Accidental breaks:** People keep reporting that their code won't compile after a supposedly "minor" update. To address this, you boldly propose that every **awesome-widgets** pull request must be approved by an experienced developer from your team. But that proves unrealistic -- nobody has time to look at every single PR! What you really need is a way to detect PRs that change API contracts, and flag them for review. That would focus attention in the right place... but how to do that?
15
-
16
- - **Missing exports:** Suppose the **awesome-widgets** package exports an API function `AwesomeButton.draw()` that requires a parameter of type `DrawStyle`, but you forgot to export this enum. Things seem fine at first, but when a developer tries to call that function, they discover that there's no way to specify the `DrawStyle`. How to avoid these oversights?
17
-
18
- - **Accidental exports:** You meant for your `DrawHelper` class to be kept internal, but one day you realize it's being exported. When you try to remove it, consumers complain that they're using it. How do we avoid this in the future?
19
-
20
- - **Alpha/Beta graduation:** You want to release previews of new APIs that are not ready for prime time yet. But if you did a major SemVer bump every time these definitions evolve, the villagers would be after you with torches and pitchforks! A better approach is to designate certain classes/members as **alpha** quality, then promote them to **beta** and finally to **public** as they mature. But how to indicate this to your consumers? (And how to detect scoping mistakes? A **public** function should never return a **beta** result.)
21
-
22
- - **\*.d.ts rollup:** You webpacked your library into a nice **\*.js** bundle file -- so why ship your typings as a messy tree of **lib/\*.d.ts** files full of private definitions? Can't we consolidate them into a tidy **\*.d.ts** rollup file? And if you publish internal/beta/public releases, each release type should get its own **\*.d.ts** file with appropriate trimming. Developers building a production project don't want to see a bunch of **internal** and **beta** members in their VS Code IntelliSense!
23
-
24
- - **Online documentation:** You have faithfully annotated each TypeScript member with nice [TSDoc](https://github.com/microsoft/tsdoc) descriptions. Now that your library has shipped, it's time to set up [a nicely formatted](https://docs.microsoft.com/en-us/javascript/api/sp-http) API reference. What tool to use?
25
-
26
- **API Extractor** provides an integrated, professional-quality solution for all these problems. It is invoked at build time by your toolchain and leverages the TypeScript compiler engine to:
27
-
28
- - Detect a project's exported API surface
29
- - Capture the contracts in a concise report designed to facilitate review
30
- - Warn about common mistakes (e.g. missing exports, inconsistent visibility, etc.)
31
- - Generate \*.d.ts rollups with trimming according to release type
32
- - Output API documentation in a portable format that's easy to integrate with your content pipeline
33
-
34
- Best of all, **API Extractor** is free and open source. Join the community and create a pull request!
35
-
36
- <!-- ------------------------------------------------------------------ -->
37
- <!-- Text above this line should stay in sync with the web site content -->
38
- <!-- ------------------------------------------------------------------ -->
39
-
40
- ## Getting Started
41
-
42
- For more details and support resources, please visit: https://api-extractor.com/
43
-
44
- ## Links
45
-
46
- - [CHANGELOG.md](
47
- https://github.com/microsoft/rushstack/blob/main/apps/api-extractor/CHANGELOG.md) - Find
48
- out what's new in the latest version
49
- - [API Reference](https://rushstack.io/pages/api/api-extractor/)
50
-
51
- API Extractor is part of the [Rush Stack](https://rushstack.io/) family of projects.
1
+ # @microsoft/api-extractor
2
+
3
+
4
+ ![API Extractor](https://github.com/microsoft/rushstack/raw/main/common/wiki-images/api-extractor-title.png?raw=true)
5
+ <br />
6
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; https://api-extractor.com/
7
+
8
+ <!-- ------------------------------------------------------------------ -->
9
+ <!-- Text below this line should stay in sync with the web site content -->
10
+ <!-- ------------------------------------------------------------------ -->
11
+
12
+ **API Extractor** helps you build better [TypeScript](https://www.typescriptlang.org/) library packages. Suppose for example that your company has published an NPM package called "**awesome-widgets**" that exports many classes and interfaces. As developers start to depend on your library, you may encounter issues such as...
13
+
14
+ - **Accidental breaks:** People keep reporting that their code won't compile after a supposedly "minor" update. To address this, you boldly propose that every **awesome-widgets** pull request must be approved by an experienced developer from your team. But that proves unrealistic -- nobody has time to look at every single PR! What you really need is a way to detect PRs that change API contracts, and flag them for review. That would focus attention in the right place... but how to do that?
15
+
16
+ - **Missing exports:** Suppose the **awesome-widgets** package exports an API function `AwesomeButton.draw()` that requires a parameter of type `DrawStyle`, but you forgot to export this enum. Things seem fine at first, but when a developer tries to call that function, they discover that there's no way to specify the `DrawStyle`. How to avoid these oversights?
17
+
18
+ - **Accidental exports:** You meant for your `DrawHelper` class to be kept internal, but one day you realize it's being exported. When you try to remove it, consumers complain that they're using it. How do we avoid this in the future?
19
+
20
+ - **Alpha/Beta graduation:** You want to release previews of new APIs that are not ready for prime time yet. But if you did a major SemVer bump every time these definitions evolve, the villagers would be after you with torches and pitchforks! A better approach is to designate certain classes/members as **alpha** quality, then promote them to **beta** and finally to **public** as they mature. But how to indicate this to your consumers? (And how to detect scoping mistakes? A **public** function should never return a **beta** result.)
21
+
22
+ - **\*.d.ts rollup:** You webpacked your library into a nice **\*.js** bundle file -- so why ship your typings as a messy tree of **lib/\*.d.ts** files full of private definitions? Can't we consolidate them into a tidy **\*.d.ts** rollup file? And if you publish internal/beta/public releases, each release type should get its own **\*.d.ts** file with appropriate trimming. Developers building a production project don't want to see a bunch of **internal** and **beta** members in their VS Code IntelliSense!
23
+
24
+ - **Online documentation:** You have faithfully annotated each TypeScript member with nice [TSDoc](https://github.com/microsoft/tsdoc) descriptions. Now that your library has shipped, it's time to set up [a nicely formatted](https://docs.microsoft.com/en-us/javascript/api/sp-http) API reference. What tool to use?
25
+
26
+ **API Extractor** provides an integrated, professional-quality solution for all these problems. It is invoked at build time by your toolchain and leverages the TypeScript compiler engine to:
27
+
28
+ - Detect a project's exported API surface
29
+ - Capture the contracts in a concise report designed to facilitate review
30
+ - Warn about common mistakes (e.g. missing exports, inconsistent visibility, etc.)
31
+ - Generate \*.d.ts rollups with trimming according to release type
32
+ - Output API documentation in a portable format that's easy to integrate with your content pipeline
33
+
34
+ Best of all, **API Extractor** is free and open source. Join the community and create a pull request!
35
+
36
+ <!-- ------------------------------------------------------------------ -->
37
+ <!-- Text above this line should stay in sync with the web site content -->
38
+ <!-- ------------------------------------------------------------------ -->
39
+
40
+ ## Getting Started
41
+
42
+ For more details and support resources, please visit: https://api-extractor.com/
43
+
44
+ ## Links
45
+
46
+ - [CHANGELOG.md](
47
+ https://github.com/microsoft/rushstack/blob/main/apps/api-extractor/CHANGELOG.md) - Find
48
+ out what's new in the latest version
49
+ - [API Reference](https://rushstack.io/pages/api/api-extractor/)
50
+
51
+ API Extractor is part of the [Rush Stack](https://rushstack.io/) family of projects.
package/bin/api-extractor CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
2
- require('../lib/start.js')
1
+ #!/usr/bin/env node
2
+ require('../lib/start.js')
@@ -1,72 +1,72 @@
1
- /**
2
- * This file defines the TSDoc custom tags for use with API Extractor.
3
- *
4
- * If your project has a custom tsdoc.json file, then it should use the "extends" field to
5
- * inherit the definitions from this file. For example:
6
- *
7
- * ```
8
- * {
9
- * "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
10
- * "extends": [ "@microsoft/api-extractor/extends/tsdoc-config.json" ],
11
- * . . .
12
- * }
13
- * ```
14
- *
15
- * For details about this config file, please see: https://tsdoc.org/pages/packages/tsdoc-config/
16
- */
17
- {
18
- "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
19
-
20
- /**
21
- * The "AEDoc" custom tags:
22
- */
23
- "tagDefinitions": [
24
- {
25
- "tagName": "@betaDocumentation",
26
- "syntaxKind": "modifier"
27
- },
28
- {
29
- "tagName": "@internalRemarks",
30
- "syntaxKind": "block"
31
- },
32
- {
33
- "tagName": "@preapproved",
34
- "syntaxKind": "modifier"
35
- }
36
- ],
37
-
38
- /**
39
- * TSDoc tags implemented by API Extractor:
40
- */
41
- "supportForTags": {
42
- "@alpha": true,
43
- "@beta": true,
44
- "@defaultValue": true,
45
- "@decorator": true,
46
- "@deprecated": true,
47
- "@eventProperty": true,
48
- "@example": true,
49
- "@experimental": true,
50
- "@inheritDoc": true,
51
- "@internal": true,
52
- "@label": true,
53
- "@link": true,
54
- "@override": true,
55
- "@packageDocumentation": true,
56
- "@param": true,
57
- "@privateRemarks": true,
58
- "@public": true,
59
- "@readonly": true,
60
- "@remarks": true,
61
- "@returns": true,
62
- "@sealed": true,
63
- "@see": true,
64
- "@throws": true,
65
- "@typeParam": true,
66
- "@virtual": true,
67
-
68
- "@betaDocumentation": true,
69
- "@internalRemarks": true,
70
- "@preapproved": true
71
- }
72
- }
1
+ /**
2
+ * This file defines the TSDoc custom tags for use with API Extractor.
3
+ *
4
+ * If your project has a custom tsdoc.json file, then it should use the "extends" field to
5
+ * inherit the definitions from this file. For example:
6
+ *
7
+ * ```
8
+ * {
9
+ * "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
10
+ * "extends": [ "@microsoft/api-extractor/extends/tsdoc-config.json" ],
11
+ * . . .
12
+ * }
13
+ * ```
14
+ *
15
+ * For details about this config file, please see: https://tsdoc.org/pages/packages/tsdoc-config/
16
+ */
17
+ {
18
+ "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
19
+
20
+ /**
21
+ * The "AEDoc" custom tags:
22
+ */
23
+ "tagDefinitions": [
24
+ {
25
+ "tagName": "@betaDocumentation",
26
+ "syntaxKind": "modifier"
27
+ },
28
+ {
29
+ "tagName": "@internalRemarks",
30
+ "syntaxKind": "block"
31
+ },
32
+ {
33
+ "tagName": "@preapproved",
34
+ "syntaxKind": "modifier"
35
+ }
36
+ ],
37
+
38
+ /**
39
+ * TSDoc tags implemented by API Extractor:
40
+ */
41
+ "supportForTags": {
42
+ "@alpha": true,
43
+ "@beta": true,
44
+ "@defaultValue": true,
45
+ "@decorator": true,
46
+ "@deprecated": true,
47
+ "@eventProperty": true,
48
+ "@example": true,
49
+ "@experimental": true,
50
+ "@inheritDoc": true,
51
+ "@internal": true,
52
+ "@label": true,
53
+ "@link": true,
54
+ "@override": true,
55
+ "@packageDocumentation": true,
56
+ "@param": true,
57
+ "@privateRemarks": true,
58
+ "@public": true,
59
+ "@readonly": true,
60
+ "@remarks": true,
61
+ "@returns": true,
62
+ "@sealed": true,
63
+ "@see": true,
64
+ "@throws": true,
65
+ "@typeParam": true,
66
+ "@virtual": true,
67
+
68
+ "@betaDocumentation": true,
69
+ "@internalRemarks": true,
70
+ "@preapproved": true
71
+ }
72
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"PackageDocComment.js","sourceRoot":"","sources":["../../src/aedoc/PackageDocComment.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAIjC,MAAa,iBAAiB;IAC5B;;OAEG;IACI,MAAM,CAAC,mBAAmB,CAC/B,UAAyB,EACzB,SAAoB;QAEpB,oFAAoF;QACpF,mFAAmF;QACnF,6BAA6B;QAC7B,EAAE;QACF,sFAAsF;QACtF,uFAAuF;QACvF,+DAA+D;QAC/D,EAAE;QACF,kGAAkG;QAClG,wFAAwF;QACxF,8FAA8F;QAC9F,eAAe;QACf,IAAI,mBAAmB,GAA6B,SAAS,CAAC,CAAC,eAAe;QAE9E,KAAK,MAAM,YAAY,IAAI,EAAE,CAAC,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE;YACvG,IAAI,YAAY,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,sBAAsB,EAAE;gBAC9D,MAAM,WAAW,GAAW,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;gBAE1F,uCAAuC;gBACvC,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;oBAClC,oEAAoE;oBACpE,wDAAwD;oBACxD,IAAI,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;wBAC/C,mBAAmB,GAAG,YAAY,CAAC;qBACpC;oBACD,MAAM;iBACP;aACF;SACF;QAED,IAAI,CAAC,mBAAmB,EAAE;YACxB,uFAAuF;YACvF,8FAA8F;YAC9F,KAAK,MAAM,SAAS,IAAI,UAAU,CAAC,UAAU,EAAE;gBAC7C,MAAM,MAAM,GAAsB,EAAE,CAAC;gBACrC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;gBAC9F,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,wBAAwB,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;gBAEzF,KAAK,MAAM,YAAY,IAAI,MAAM,EAAE;oBACjC,MAAM,WAAW,GAAW,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;oBAE1F,IAAI,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;wBAC/C,SAAS,CAAC,aAAa,CAAC,2BAA2B,0EAEjD,qFAAqF,EACrF,UAAU,EACV,YAAY,CAAC,GAAG,CACjB,CAAC;wBACF,MAAM;qBACP;iBACF;aACF;SACF;QAED,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AAhED,8CAgEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport * as ts from 'typescript';\r\nimport type { Collector } from '../collector/Collector';\r\nimport { ExtractorMessageId } from '../api/ExtractorMessageId';\r\n\r\nexport class PackageDocComment {\r\n /**\r\n * For the given source file, see if it starts with a TSDoc comment containing the `@packageDocumentation` tag.\r\n */\r\n public static tryFindInSourceFile(\r\n sourceFile: ts.SourceFile,\r\n collector: Collector\r\n ): ts.TextRange | undefined {\r\n // The @packageDocumentation comment is special because it is not attached to an AST\r\n // definition. Instead, it is part of the \"trivia\" tokens that the compiler treats\r\n // as irrelevant white space.\r\n //\r\n // WARNING: If the comment doesn't precede an export statement, the compiler will omit\r\n // it from the *.d.ts file, and API Extractor won't find it. If this happens, you need\r\n // to rearrange your statements to ensure it is passed through.\r\n //\r\n // This implementation assumes that the \"@packageDocumentation\" will be in the first TSDoc comment\r\n // that appears in the entry point *.d.ts file. We could possibly look in other places,\r\n // but the above warning suggests enforcing a standardized layout. This design choice is open\r\n // to feedback.\r\n let packageCommentRange: ts.TextRange | undefined = undefined; // empty string\r\n\r\n for (const commentRange of ts.getLeadingCommentRanges(sourceFile.text, sourceFile.getFullStart()) || []) {\r\n if (commentRange.kind === ts.SyntaxKind.MultiLineCommentTrivia) {\r\n const commentBody: string = sourceFile.text.substring(commentRange.pos, commentRange.end);\r\n\r\n // Choose the first JSDoc-style comment\r\n if (/^\\s*\\/\\*\\*/.test(commentBody)) {\r\n // But only if it looks like it's trying to be @packageDocumentation\r\n // (The TSDoc parser will validate this more rigorously)\r\n if (/\\@packageDocumentation/i.test(commentBody)) {\r\n packageCommentRange = commentRange;\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (!packageCommentRange) {\r\n // If we didn't find the @packageDocumentation tag in the expected place, is it in some\r\n // wrong place? This sanity check helps people to figure out why there comment isn't working.\r\n for (const statement of sourceFile.statements) {\r\n const ranges: ts.CommentRange[] = [];\r\n ranges.push(...(ts.getLeadingCommentRanges(sourceFile.text, statement.getFullStart()) || []));\r\n ranges.push(...(ts.getTrailingCommentRanges(sourceFile.text, statement.getEnd()) || []));\r\n\r\n for (const commentRange of ranges) {\r\n const commentBody: string = sourceFile.text.substring(commentRange.pos, commentRange.end);\r\n\r\n if (/\\@packageDocumentation/i.test(commentBody)) {\r\n collector.messageRouter.addAnalyzerIssueForPosition(\r\n ExtractorMessageId.MisplacedPackageTag,\r\n 'The @packageDocumentation comment must appear at the top of entry point *.d.ts file',\r\n sourceFile,\r\n commentRange.pos\r\n );\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return packageCommentRange;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PackageDocComment.js","sourceRoot":"","sources":["../../src/aedoc/PackageDocComment.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAIjC,MAAa,iBAAiB;IAC5B;;OAEG;IACI,MAAM,CAAC,mBAAmB,CAC/B,UAAyB,EACzB,SAAoB;QAEpB,oFAAoF;QACpF,mFAAmF;QACnF,6BAA6B;QAC7B,EAAE;QACF,sFAAsF;QACtF,uFAAuF;QACvF,+DAA+D;QAC/D,EAAE;QACF,kGAAkG;QAClG,wFAAwF;QACxF,8FAA8F;QAC9F,eAAe;QACf,IAAI,mBAAmB,GAA6B,SAAS,CAAC,CAAC,eAAe;QAE9E,KAAK,MAAM,YAAY,IAAI,EAAE,CAAC,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE;YACvG,IAAI,YAAY,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,sBAAsB,EAAE;gBAC9D,MAAM,WAAW,GAAW,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;gBAE1F,uCAAuC;gBACvC,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;oBAClC,oEAAoE;oBACpE,wDAAwD;oBACxD,IAAI,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;wBAC/C,mBAAmB,GAAG,YAAY,CAAC;qBACpC;oBACD,MAAM;iBACP;aACF;SACF;QAED,IAAI,CAAC,mBAAmB,EAAE;YACxB,uFAAuF;YACvF,8FAA8F;YAC9F,KAAK,MAAM,SAAS,IAAI,UAAU,CAAC,UAAU,EAAE;gBAC7C,MAAM,MAAM,GAAsB,EAAE,CAAC;gBACrC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;gBAC9F,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,wBAAwB,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;gBAEzF,KAAK,MAAM,YAAY,IAAI,MAAM,EAAE;oBACjC,MAAM,WAAW,GAAW,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;oBAE1F,IAAI,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;wBAC/C,SAAS,CAAC,aAAa,CAAC,2BAA2B,0EAEjD,qFAAqF,EACrF,UAAU,EACV,YAAY,CAAC,GAAG,CACjB,CAAC;wBACF,MAAM;qBACP;iBACF;aACF;SACF;QAED,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AAhED,8CAgEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\nimport type { Collector } from '../collector/Collector';\nimport { ExtractorMessageId } from '../api/ExtractorMessageId';\n\nexport class PackageDocComment {\n /**\n * For the given source file, see if it starts with a TSDoc comment containing the `@packageDocumentation` tag.\n */\n public static tryFindInSourceFile(\n sourceFile: ts.SourceFile,\n collector: Collector\n ): ts.TextRange | undefined {\n // The @packageDocumentation comment is special because it is not attached to an AST\n // definition. Instead, it is part of the \"trivia\" tokens that the compiler treats\n // as irrelevant white space.\n //\n // WARNING: If the comment doesn't precede an export statement, the compiler will omit\n // it from the *.d.ts file, and API Extractor won't find it. If this happens, you need\n // to rearrange your statements to ensure it is passed through.\n //\n // This implementation assumes that the \"@packageDocumentation\" will be in the first TSDoc comment\n // that appears in the entry point *.d.ts file. We could possibly look in other places,\n // but the above warning suggests enforcing a standardized layout. This design choice is open\n // to feedback.\n let packageCommentRange: ts.TextRange | undefined = undefined; // empty string\n\n for (const commentRange of ts.getLeadingCommentRanges(sourceFile.text, sourceFile.getFullStart()) || []) {\n if (commentRange.kind === ts.SyntaxKind.MultiLineCommentTrivia) {\n const commentBody: string = sourceFile.text.substring(commentRange.pos, commentRange.end);\n\n // Choose the first JSDoc-style comment\n if (/^\\s*\\/\\*\\*/.test(commentBody)) {\n // But only if it looks like it's trying to be @packageDocumentation\n // (The TSDoc parser will validate this more rigorously)\n if (/\\@packageDocumentation/i.test(commentBody)) {\n packageCommentRange = commentRange;\n }\n break;\n }\n }\n }\n\n if (!packageCommentRange) {\n // If we didn't find the @packageDocumentation tag in the expected place, is it in some\n // wrong place? This sanity check helps people to figure out why there comment isn't working.\n for (const statement of sourceFile.statements) {\n const ranges: ts.CommentRange[] = [];\n ranges.push(...(ts.getLeadingCommentRanges(sourceFile.text, statement.getFullStart()) || []));\n ranges.push(...(ts.getTrailingCommentRanges(sourceFile.text, statement.getEnd()) || []));\n\n for (const commentRange of ranges) {\n const commentBody: string = sourceFile.text.substring(commentRange.pos, commentRange.end);\n\n if (/\\@packageDocumentation/i.test(commentBody)) {\n collector.messageRouter.addAnalyzerIssueForPosition(\n ExtractorMessageId.MisplacedPackageTag,\n 'The @packageDocumentation comment must appear at the top of entry point *.d.ts file',\n sourceFile,\n commentRange.pos\n );\n break;\n }\n }\n }\n }\n\n return packageCommentRange;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AstDeclaration.js","sourceRoot":"","sources":["../../src/analyzer/AstDeclaration.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,iCAA8B;AAC9B,oEAA6D;AA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C,mBAAmB,CAAC;YACvC,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;YACrC,KAAK,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,0CAA0C;YACnF,KAAK,EAAE,CAAC,UAAU,CAAC,mBAAmB;gBACpC,OAAO,IAAI,CAAC;YAEd,gHAAgH;YAChH,0CAA0C;YAE1C,gGAAgG;YAChG,8FAA8F;YAC9F,4FAA4F;YAC5F,gGAAgG;YAChG,0DAA0D;SAC3D;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAvPD,wCAuPC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport * as ts from 'typescript';\r\nimport type { AstSymbol } from './AstSymbol';\r\nimport { Span } from './Span';\r\nimport { InternalError } from '@rushstack/node-core-library';\r\nimport type { AstEntity } from './AstEntity';\r\n\r\n/**\r\n * Constructor options for AstDeclaration\r\n */\r\nexport interface IAstDeclarationOptions {\r\n readonly declaration: ts.Declaration;\r\n readonly astSymbol: AstSymbol;\r\n readonly parent: AstDeclaration | undefined;\r\n}\r\n\r\n/**\r\n * The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's\r\n * ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.\r\n *\r\n * @remarks\r\n * The AstDeclaration represents one or more syntax components of a symbol. Usually there is\r\n * only one AstDeclaration per AstSymbol, but certain TypeScript constructs can have multiple\r\n * declarations (e.g. overloaded functions, merged declarations, etc.).\r\n *\r\n * Because of this, the `AstDeclaration` manages the parent/child nesting hierarchy (e.g. with\r\n * declaration merging, each declaration has its own children) and becomes the main focus\r\n * of analyzing AEDoc and emitting *.d.ts files.\r\n *\r\n * The AstDeclarations correspond to items from the compiler's ts.Node hierarchy, but\r\n * omitting/skipping any nodes that don't match the AstDeclaration.isSupportedSyntaxKind()\r\n * criteria. This simplification makes the other API Extractor stages easier to implement.\r\n */\r\nexport class AstDeclaration {\r\n public readonly declaration: ts.Declaration;\r\n\r\n public readonly astSymbol: AstSymbol;\r\n\r\n /**\r\n * The parent, if this object is nested inside another AstDeclaration.\r\n */\r\n public readonly parent: AstDeclaration | undefined;\r\n\r\n /**\r\n * A bit set of TypeScript modifiers such as \"private\", \"protected\", etc.\r\n */\r\n public readonly modifierFlags: ts.ModifierFlags;\r\n\r\n /**\r\n * Additional information that is calculated later by the `Collector`. The actual type is `DeclarationMetadata`,\r\n * but we declare it as `unknown` because consumers must obtain this object by calling\r\n * `Collector.fetchDeclarationMetadata()`.\r\n */\r\n public declarationMetadata: unknown;\r\n\r\n /**\r\n * Additional information that is calculated later by the `Collector`. The actual type is `ApiItemMetadata`,\r\n * but we declare it as `unknown` because consumers must obtain this object by calling\r\n * `Collector.fetchApiItemMetadata()`.\r\n */\r\n public apiItemMetadata: unknown;\r\n\r\n // NOTE: This array becomes immutable after astSymbol.analyze() sets astSymbol.analyzed=true\r\n private readonly _analyzedChildren: AstDeclaration[] = [];\r\n\r\n private readonly _analyzedReferencedAstEntitiesSet: Set<AstEntity> = new Set<AstEntity>();\r\n\r\n // Reverse lookup used by findChildrenWithName()\r\n private _childrenByName: Map<string, AstDeclaration[]> | undefined = undefined;\r\n\r\n public constructor(options: IAstDeclarationOptions) {\r\n this.declaration = options.declaration;\r\n this.astSymbol = options.astSymbol;\r\n this.parent = options.parent;\r\n\r\n this.astSymbol._notifyDeclarationAttach(this);\r\n\r\n if (this.parent) {\r\n this.parent._notifyChildAttach(this);\r\n }\r\n\r\n this.modifierFlags = ts.getCombinedModifierFlags(this.declaration);\r\n\r\n // Check for ECMAScript private fields, for example:\r\n //\r\n // class Person { #name: string; }\r\n //\r\n const declarationName: ts.DeclarationName | undefined = ts.getNameOfDeclaration(this.declaration);\r\n if (declarationName) {\r\n if (ts.isPrivateIdentifier(declarationName)) {\r\n // eslint-disable-next-line no-bitwise\r\n this.modifierFlags |= ts.ModifierFlags.Private;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Returns the children for this AstDeclaration.\r\n * @remarks\r\n * The collection will be empty until AstSymbol.analyzed is true.\r\n */\r\n public get children(): ReadonlyArray<AstDeclaration> {\r\n return this.astSymbol.analyzed ? this._analyzedChildren : [];\r\n }\r\n\r\n /**\r\n * Returns the AstEntity objects referenced by this node.\r\n * @remarks\r\n * NOTE: The collection will be empty until AstSymbol.analyzed is true.\r\n *\r\n * Since we assume references are always collected by a traversal starting at the\r\n * root of the nesting declarations, this array omits the following items because they\r\n * would be redundant:\r\n * - symbols corresponding to parents of this declaration (e.g. a method that returns its own class)\r\n * - symbols already listed in the referencedAstSymbols property for parents of this declaration\r\n * (e.g. a method that returns its own class's base class)\r\n * - symbols that are referenced only by nested children of this declaration\r\n * (e.g. if a method returns an enum, this doesn't imply that the method's class references that enum)\r\n */\r\n public get referencedAstEntities(): ReadonlyArray<AstEntity> {\r\n return this.astSymbol.analyzed ? [...this._analyzedReferencedAstEntitiesSet] : [];\r\n }\r\n\r\n /**\r\n * This is an internal callback used when the AstSymbolTable attaches a new\r\n * child AstDeclaration to this object.\r\n * @internal\r\n */\r\n public _notifyChildAttach(child: AstDeclaration): void {\r\n if (child.parent !== this) {\r\n throw new InternalError('Invalid call to notifyChildAttach()');\r\n }\r\n\r\n if (this.astSymbol.analyzed) {\r\n throw new InternalError('_notifyChildAttach() called after analysis is already complete');\r\n }\r\n\r\n this._analyzedChildren.push(child);\r\n }\r\n\r\n /**\r\n * Returns a diagnostic dump of the tree, which reports the hierarchy of\r\n * AstDefinition objects.\r\n */\r\n public getDump(indent: string = ''): string {\r\n const declarationKind: string = ts.SyntaxKind[this.declaration.kind];\r\n let result: string = indent + `+ ${this.astSymbol.localName} (${declarationKind})`;\r\n if (this.astSymbol.nominalAnalysis) {\r\n result += ' (nominal)';\r\n }\r\n result += '\\n';\r\n\r\n for (const referencedAstEntity of this._analyzedReferencedAstEntitiesSet.values()) {\r\n result += indent + ` ref: ${referencedAstEntity.localName}\\n`;\r\n }\r\n\r\n for (const child of this.children) {\r\n result += child.getDump(indent + ' ');\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Returns a diagnostic dump using Span.getDump(), which reports the detailed\r\n * compiler structure.\r\n */\r\n public getSpanDump(indent: string = ''): string {\r\n const span: Span = new Span(this.declaration);\r\n return span.getDump(indent);\r\n }\r\n\r\n /**\r\n * This is an internal callback used when AstSymbolTable.analyze() discovers a new\r\n * type reference associated with this declaration.\r\n * @internal\r\n */\r\n public _notifyReferencedAstEntity(referencedAstEntity: AstEntity): void {\r\n if (this.astSymbol.analyzed) {\r\n throw new InternalError('_notifyReferencedAstEntity() called after analysis is already complete');\r\n }\r\n\r\n for (let current: AstDeclaration | undefined = this; current; current = current.parent) {\r\n // Don't add references to symbols that are already referenced by a parent\r\n if (current._analyzedReferencedAstEntitiesSet.has(referencedAstEntity)) {\r\n return;\r\n }\r\n // Don't add the symbols of parents either\r\n if (referencedAstEntity === current.astSymbol) {\r\n return;\r\n }\r\n }\r\n\r\n this._analyzedReferencedAstEntitiesSet.add(referencedAstEntity);\r\n }\r\n\r\n /**\r\n * Visits all the current declaration and all children recursively in a depth-first traversal,\r\n * and performs the specified action for each one.\r\n */\r\n public forEachDeclarationRecursive(action: (astDeclaration: AstDeclaration) => void): void {\r\n action(this);\r\n for (const child of this.children) {\r\n child.forEachDeclarationRecursive(action);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the list of child declarations whose `AstSymbol.localName` matches the provided `name`.\r\n *\r\n * @remarks\r\n * This is an efficient O(1) lookup.\r\n */\r\n public findChildrenWithName(name: string): ReadonlyArray<AstDeclaration> {\r\n // The children property returns:\r\n //\r\n // return this.astSymbol.analyzed ? this._analyzedChildren : [];\r\n //\r\n if (!this.astSymbol.analyzed || this._analyzedChildren.length === 0) {\r\n return [];\r\n }\r\n\r\n if (this._childrenByName === undefined) {\r\n // Build the lookup table\r\n const childrenByName: Map<string, AstDeclaration[]> = new Map<string, AstDeclaration[]>();\r\n\r\n for (const child of this._analyzedChildren) {\r\n const childName: string = child.astSymbol.localName;\r\n let array: AstDeclaration[] | undefined = childrenByName.get(childName);\r\n if (array === undefined) {\r\n array = [];\r\n childrenByName.set(childName, array);\r\n }\r\n array.push(child);\r\n }\r\n this._childrenByName = childrenByName;\r\n }\r\n\r\n return this._childrenByName.get(name) || [];\r\n }\r\n\r\n /**\r\n * This function determines which ts.Node kinds will generate an AstDeclaration.\r\n * These correspond to the definitions that we can add AEDoc to.\r\n */\r\n public static isSupportedSyntaxKind(kind: ts.SyntaxKind): boolean {\r\n // (alphabetical order)\r\n switch (kind) {\r\n case ts.SyntaxKind.CallSignature:\r\n case ts.SyntaxKind.ClassDeclaration:\r\n case ts.SyntaxKind.ConstructSignature: // Example: \"new(x: number): IMyClass\"\r\n case ts.SyntaxKind.Constructor: // Example: \"constructor(x: number)\"\r\n case ts.SyntaxKind.EnumDeclaration:\r\n case ts.SyntaxKind.EnumMember:\r\n case ts.SyntaxKind.FunctionDeclaration: // Example: \"(x: number): number\"\r\n case ts.SyntaxKind.GetAccessor:\r\n case ts.SyntaxKind.SetAccessor:\r\n case ts.SyntaxKind.IndexSignature: // Example: \"[key: string]: string\"\r\n case ts.SyntaxKind.InterfaceDeclaration:\r\n case ts.SyntaxKind.MethodDeclaration:\r\n case ts.SyntaxKind.MethodSignature:\r\n case ts.SyntaxKind.ModuleDeclaration: // Used for both \"module\" and \"namespace\" declarations\r\n case ts.SyntaxKind.PropertyDeclaration:\r\n case ts.SyntaxKind.PropertySignature:\r\n case ts.SyntaxKind.TypeAliasDeclaration: // Example: \"type Shape = Circle | Square\"\r\n case ts.SyntaxKind.VariableDeclaration:\r\n return true;\r\n\r\n // NOTE: Prior to TypeScript 3.7, in the emitted .d.ts files, the compiler would merge a GetAccessor/SetAccessor\r\n // pair into a single PropertyDeclaration.\r\n\r\n // NOTE: In contexts where a source file is treated as a module, we do create \"nominal analysis\"\r\n // AstSymbol objects corresponding to a ts.SyntaxKind.SourceFile node. However, a source file\r\n // is NOT considered a nesting structure, and it does NOT act as a root for the declarations\r\n // appearing in the file. This is because the *.d.ts generator is in the business of rolling up\r\n // source files, and thus wants to ignore them in general.\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AstDeclaration.js","sourceRoot":"","sources":["../../src/analyzer/AstDeclaration.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,iCAA8B;AAC9B,oEAA6D;AAY7D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,cAAc;IAqCzB,YAAmB,OAA+B;QARlD,4FAA4F;QAC3E,sBAAiB,GAAqB,EAAE,CAAC;QAEzC,sCAAiC,GAAmB,IAAI,GAAG,EAAa,CAAC;QAE1F,gDAAgD;QACxC,oBAAe,GAA8C,SAAS,CAAC;QAG7E,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAE7B,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;SACtC;QAED,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEnE,oDAAoD;QACpD,EAAE;QACF,qCAAqC;QACrC,EAAE;QACF,MAAM,eAAe,GAAmC,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAClG,IAAI,eAAe,EAAE;YACnB,IAAI,EAAE,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE;gBAC3C,sCAAsC;gBACtC,IAAI,CAAC,aAAa,IAAI,EAAE,C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CAAC,WAAW,CAAC;YAC/B,KAAK,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,mCAAmC;YACtE,KAAK,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC;YACxC,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;YACrC,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;YACnC,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,sDAAsD;YAC5F,KAAK,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC;YACvC,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;YACrC,KAAK,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,0CAA0C;YACnF,KAAK,EAAE,CAAC,UAAU,CAAC,mBAAmB;gBACpC,OAAO,IAAI,CAAC;YAEd,gHAAgH;YAChH,0CAA0C;YAE1C,gGAAgG;YAChG,8FAA8F;YAC9F,4FAA4F;YAC5F,gGAAgG;YAChG,0DAA0D;SAC3D;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAvPD,wCAuPC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\nimport type { AstSymbol } from './AstSymbol';\nimport { Span } from './Span';\nimport { InternalError } from '@rushstack/node-core-library';\nimport type { AstEntity } from './AstEntity';\n\n/**\n * Constructor options for AstDeclaration\n */\nexport interface IAstDeclarationOptions {\n readonly declaration: ts.Declaration;\n readonly astSymbol: AstSymbol;\n readonly parent: AstDeclaration | undefined;\n}\n\n/**\n * The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's\n * ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.\n *\n * @remarks\n * The AstDeclaration represents one or more syntax components of a symbol. Usually there is\n * only one AstDeclaration per AstSymbol, but certain TypeScript constructs can have multiple\n * declarations (e.g. overloaded functions, merged declarations, etc.).\n *\n * Because of this, the `AstDeclaration` manages the parent/child nesting hierarchy (e.g. with\n * declaration merging, each declaration has its own children) and becomes the main focus\n * of analyzing AEDoc and emitting *.d.ts files.\n *\n * The AstDeclarations correspond to items from the compiler's ts.Node hierarchy, but\n * omitting/skipping any nodes that don't match the AstDeclaration.isSupportedSyntaxKind()\n * criteria. This simplification makes the other API Extractor stages easier to implement.\n */\nexport class AstDeclaration {\n public readonly declaration: ts.Declaration;\n\n public readonly astSymbol: AstSymbol;\n\n /**\n * The parent, if this object is nested inside another AstDeclaration.\n */\n public readonly parent: AstDeclaration | undefined;\n\n /**\n * A bit set of TypeScript modifiers such as \"private\", \"protected\", etc.\n */\n public readonly modifierFlags: ts.ModifierFlags;\n\n /**\n * Additional information that is calculated later by the `Collector`. The actual type is `DeclarationMetadata`,\n * but we declare it as `unknown` because consumers must obtain this object by calling\n * `Collector.fetchDeclarationMetadata()`.\n */\n public declarationMetadata: unknown;\n\n /**\n * Additional information that is calculated later by the `Collector`. The actual type is `ApiItemMetadata`,\n * but we declare it as `unknown` because consumers must obtain this object by calling\n * `Collector.fetchApiItemMetadata()`.\n */\n public apiItemMetadata: unknown;\n\n // NOTE: This array becomes immutable after astSymbol.analyze() sets astSymbol.analyzed=true\n private readonly _analyzedChildren: AstDeclaration[] = [];\n\n private readonly _analyzedReferencedAstEntitiesSet: Set<AstEntity> = new Set<AstEntity>();\n\n // Reverse lookup used by findChildrenWithName()\n private _childrenByName: Map<string, AstDeclaration[]> | undefined = undefined;\n\n public constructor(options: IAstDeclarationOptions) {\n this.declaration = options.declaration;\n this.astSymbol = options.astSymbol;\n this.parent = options.parent;\n\n this.astSymbol._notifyDeclarationAttach(this);\n\n if (this.parent) {\n this.parent._notifyChildAttach(this);\n }\n\n this.modifierFlags = ts.getCombinedModifierFlags(this.declaration);\n\n // Check for ECMAScript private fields, for example:\n //\n // class Person { #name: string; }\n //\n const declarationName: ts.DeclarationName | undefined = ts.getNameOfDeclaration(this.declaration);\n if (declarationName) {\n if (ts.isPrivateIdentifier(declarationName)) {\n // eslint-disable-next-line no-bitwise\n this.modifierFlags |= ts.ModifierFlags.Private;\n }\n }\n }\n\n /**\n * Returns the children for this AstDeclaration.\n * @remarks\n * The collection will be empty until AstSymbol.analyzed is true.\n */\n public get children(): ReadonlyArray<AstDeclaration> {\n return this.astSymbol.analyzed ? this._analyzedChildren : [];\n }\n\n /**\n * Returns the AstEntity objects referenced by this node.\n * @remarks\n * NOTE: The collection will be empty until AstSymbol.analyzed is true.\n *\n * Since we assume references are always collected by a traversal starting at the\n * root of the nesting declarations, this array omits the following items because they\n * would be redundant:\n * - symbols corresponding to parents of this declaration (e.g. a method that returns its own class)\n * - symbols already listed in the referencedAstSymbols property for parents of this declaration\n * (e.g. a method that returns its own class's base class)\n * - symbols that are referenced only by nested children of this declaration\n * (e.g. if a method returns an enum, this doesn't imply that the method's class references that enum)\n */\n public get referencedAstEntities(): ReadonlyArray<AstEntity> {\n return this.astSymbol.analyzed ? [...this._analyzedReferencedAstEntitiesSet] : [];\n }\n\n /**\n * This is an internal callback used when the AstSymbolTable attaches a new\n * child AstDeclaration to this object.\n * @internal\n */\n public _notifyChildAttach(child: AstDeclaration): void {\n if (child.parent !== this) {\n throw new InternalError('Invalid call to notifyChildAttach()');\n }\n\n if (this.astSymbol.analyzed) {\n throw new InternalError('_notifyChildAttach() called after analysis is already complete');\n }\n\n this._analyzedChildren.push(child);\n }\n\n /**\n * Returns a diagnostic dump of the tree, which reports the hierarchy of\n * AstDefinition objects.\n */\n public getDump(indent: string = ''): string {\n const declarationKind: string = ts.SyntaxKind[this.declaration.kind];\n let result: string = indent + `+ ${this.astSymbol.localName} (${declarationKind})`;\n if (this.astSymbol.nominalAnalysis) {\n result += ' (nominal)';\n }\n result += '\\n';\n\n for (const referencedAstEntity of this._analyzedReferencedAstEntitiesSet.values()) {\n result += indent + ` ref: ${referencedAstEntity.localName}\\n`;\n }\n\n for (const child of this.children) {\n result += child.getDump(indent + ' ');\n }\n\n return result;\n }\n\n /**\n * Returns a diagnostic dump using Span.getDump(), which reports the detailed\n * compiler structure.\n */\n public getSpanDump(indent: string = ''): string {\n const span: Span = new Span(this.declaration);\n return span.getDump(indent);\n }\n\n /**\n * This is an internal callback used when AstSymbolTable.analyze() discovers a new\n * type reference associated with this declaration.\n * @internal\n */\n public _notifyReferencedAstEntity(referencedAstEntity: AstEntity): void {\n if (this.astSymbol.analyzed) {\n throw new InternalError('_notifyReferencedAstEntity() called after analysis is already complete');\n }\n\n for (let current: AstDeclaration | undefined = this; current; current = current.parent) {\n // Don't add references to symbols that are already referenced by a parent\n if (current._analyzedReferencedAstEntitiesSet.has(referencedAstEntity)) {\n return;\n }\n // Don't add the symbols of parents either\n if (referencedAstEntity === current.astSymbol) {\n return;\n }\n }\n\n this._analyzedReferencedAstEntitiesSet.add(referencedAstEntity);\n }\n\n /**\n * Visits all the current declaration and all children recursively in a depth-first traversal,\n * and performs the specified action for each one.\n */\n public forEachDeclarationRecursive(action: (astDeclaration: AstDeclaration) => void): void {\n action(this);\n for (const child of this.children) {\n child.forEachDeclarationRecursive(action);\n }\n }\n\n /**\n * Returns the list of child declarations whose `AstSymbol.localName` matches the provided `name`.\n *\n * @remarks\n * This is an efficient O(1) lookup.\n */\n public findChildrenWithName(name: string): ReadonlyArray<AstDeclaration> {\n // The children property returns:\n //\n // return this.astSymbol.analyzed ? this._analyzedChildren : [];\n //\n if (!this.astSymbol.analyzed || this._analyzedChildren.length === 0) {\n return [];\n }\n\n if (this._childrenByName === undefined) {\n // Build the lookup table\n const childrenByName: Map<string, AstDeclaration[]> = new Map<string, AstDeclaration[]>();\n\n for (const child of this._analyzedChildren) {\n const childName: string = child.astSymbol.localName;\n let array: AstDeclaration[] | undefined = childrenByName.get(childName);\n if (array === undefined) {\n array = [];\n childrenByName.set(childName, array);\n }\n array.push(child);\n }\n this._childrenByName = childrenByName;\n }\n\n return this._childrenByName.get(name) || [];\n }\n\n /**\n * This function determines which ts.Node kinds will generate an AstDeclaration.\n * These correspond to the definitions that we can add AEDoc to.\n */\n public static isSupportedSyntaxKind(kind: ts.SyntaxKind): boolean {\n // (alphabetical order)\n switch (kind) {\n case ts.SyntaxKind.CallSignature:\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.ConstructSignature: // Example: \"new(x: number): IMyClass\"\n case ts.SyntaxKind.Constructor: // Example: \"constructor(x: number)\"\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.EnumMember:\n case ts.SyntaxKind.FunctionDeclaration: // Example: \"(x: number): number\"\n case ts.SyntaxKind.GetAccessor:\n case ts.SyntaxKind.SetAccessor:\n case ts.SyntaxKind.IndexSignature: // Example: \"[key: string]: string\"\n case ts.SyntaxKind.InterfaceDeclaration:\n case ts.SyntaxKind.MethodDeclaration:\n case ts.SyntaxKind.MethodSignature:\n case ts.SyntaxKind.ModuleDeclaration: // Used for both \"module\" and \"namespace\" declarations\n case ts.SyntaxKind.PropertyDeclaration:\n case ts.SyntaxKind.PropertySignature:\n case ts.SyntaxKind.TypeAliasDeclaration: // Example: \"type Shape = Circle | Square\"\n case ts.SyntaxKind.VariableDeclaration:\n return true;\n\n // NOTE: Prior to TypeScript 3.7, in the emitted .d.ts files, the compiler would merge a GetAccessor/SetAccessor\n // pair into a single PropertyDeclaration.\n\n // NOTE: In contexts where a source file is treated as a module, we do create \"nominal analysis\"\n // AstSymbol objects corresponding to a ts.SyntaxKind.SourceFile node. However, a source file\n // is NOT considered a nesting structure, and it does NOT act as a root for the declarations\n // appearing in the file. This is because the *.d.ts generator is in the business of rolling up\n // source files, and thus wants to ignore them in general.\n }\n\n return false;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AstEntity.js","sourceRoot":"","sources":["../../src/analyzer/AstEntity.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAsB,SAAS;CAY9B;AAZD,8BAYC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAsB,kBAAmB,SAAQ,SAAS;CAAG;AAA7D,gDAA6D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * `AstEntity` is the abstract base class for analyzer objects that can become a `CollectorEntity`.\r\n *\r\n * @remarks\r\n *\r\n * The subclasses are:\r\n * ```\r\n * - AstEntity\r\n * - AstSymbol\r\n * - AstSyntheticEntity\r\n * - AstImport\r\n * - AstNamespaceImport\r\n * ```\r\n */\r\nexport abstract class AstEntity {\r\n /**\r\n * The original name of the symbol, as exported from the module (i.e. source file)\r\n * containing the original TypeScript definition. Constructs such as\r\n * `import { X as Y } from` may introduce other names that differ from the local name.\r\n *\r\n * @remarks\r\n * For the most part, `localName` corresponds to `followedSymbol.name`, but there\r\n * are some edge cases. For example, the ts.Symbol.name for `export default class X { }`\r\n * is actually `\"default\"`, not `\"X\"`.\r\n */\r\n public abstract readonly localName: string;\r\n}\r\n\r\n/**\r\n * `AstSyntheticEntity` is the abstract base class for analyzer objects whose emitted declarations\r\n * are not text transformations performed by the `Span` helper.\r\n *\r\n * @remarks\r\n * Most of API Extractor's output is produced by using the using the `Span` utility to regurgitate strings from\r\n * the input .d.ts files. If we need to rename an identifier, the `Span` visitor can pick out an interesting\r\n * node and rewrite its string, but otherwise the transformation operates on dumb text and not compiler concepts.\r\n * (Historically we did this because the compiler's emitter was an internal API, but it still has some advantages,\r\n * for example preserving syntaxes generated by an older compiler to avoid incompatibilities.)\r\n *\r\n * This strategy does not work for cases where the output looks very different from the input. Today these\r\n * cases are always kinds of `import` statements, but that may change in the future.\r\n */\r\nexport abstract class AstSyntheticEntity extends AstEntity {}\r\n"]}
1
+ {"version":3,"file":"AstEntity.js","sourceRoot":"","sources":["../../src/analyzer/AstEntity.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAsB,SAAS;CAY9B;AAZD,8BAYC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAsB,kBAAmB,SAAQ,SAAS;CAAG;AAA7D,gDAA6D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * `AstEntity` is the abstract base class for analyzer objects that can become a `CollectorEntity`.\n *\n * @remarks\n *\n * The subclasses are:\n * ```\n * - AstEntity\n * - AstSymbol\n * - AstSyntheticEntity\n * - AstImport\n * - AstNamespaceImport\n * ```\n */\nexport abstract class AstEntity {\n /**\n * The original name of the symbol, as exported from the module (i.e. source file)\n * containing the original TypeScript definition. Constructs such as\n * `import { X as Y } from` may introduce other names that differ from the local name.\n *\n * @remarks\n * For the most part, `localName` corresponds to `followedSymbol.name`, but there\n * are some edge cases. For example, the ts.Symbol.name for `export default class X { }`\n * is actually `\"default\"`, not `\"X\"`.\n */\n public abstract readonly localName: string;\n}\n\n/**\n * `AstSyntheticEntity` is the abstract base class for analyzer objects whose emitted declarations\n * are not text transformations performed by the `Span` helper.\n *\n * @remarks\n * Most of API Extractor's output is produced by using the using the `Span` utility to regurgitate strings from\n * the input .d.ts files. If we need to rename an identifier, the `Span` visitor can pick out an interesting\n * node and rewrite its string, but otherwise the transformation operates on dumb text and not compiler concepts.\n * (Historically we did this because the compiler's emitter was an internal API, but it still has some advantages,\n * for example preserving syntaxes generated by an older compiler to avoid incompatibilities.)\n *\n * This strategy does not work for cases where the output looks very different from the input. Today these\n * cases are always kinds of `import` statements, but that may change in the future.\n */\nexport abstract class AstSyntheticEntity extends AstEntity {}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AstImport.js","sourceRoot":"","sources":["../../src/analyzer/AstImport.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oEAA6D;AAC7D,2CAAiD;AAEjD;;GAEG;AACH,IAAY,aAyBX;AAzBD,WAAY,aAAa;IACvB;;OAEG;IACH,mEAAa,CAAA;IAEb;;O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;oBACxC,CAAC,CAAC,GAAG,CAAC,2BAA2B;oBACjC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,+BAA+B;wBAClE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;wBAClC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;gBACvB,OAAO,GAAG,OAAO,CAAC,UAAU,IAAI,MAAM,EAAE,CAAC;aAC1C;YACD;gBACE,MAAM,IAAI,iCAAa,CAAC,uBAAuB,CAAC,CAAC;SACpD;IACH,CAAC;CACF;AA3GD,8BA2GC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { AstSymbol } from './AstSymbol';\r\nimport { InternalError } from '@rushstack/node-core-library';\r\nimport { AstSyntheticEntity } from './AstEntity';\r\n\r\n/**\r\n * Indicates the import kind for an `AstImport`.\r\n */\r\nexport enum AstImportKind {\r\n /**\r\n * An import statement such as `import X from \"y\";`.\r\n */\r\n DefaultImport,\r\n\r\n /**\r\n * An import statement such as `import { X } from \"y\";`.\r\n */\r\n NamedImport,\r\n\r\n /**\r\n * An import statement such as `import * as x from \"y\";`.\r\n */\r\n StarImport,\r\n\r\n /**\r\n * An import statement such as `import x = require(\"y\");`.\r\n */\r\n EqualsImport,\r\n\r\n /**\r\n * An import statement such as `interface foo { foo: import(\"bar\").a.b.c }`.\r\n */\r\n ImportType\r\n}\r\n\r\n/**\r\n * Constructor parameters for AstImport\r\n *\r\n * @privateRemarks\r\n * Our naming convention is to use I____Parameters for constructor options and\r\n * I____Options for general function options. However the word \"parameters\" is\r\n * confusingly similar to the terminology for function parameters modeled by API Extractor,\r\n * so we use I____Options for both cases in this code base.\r\n */\r\nexport interface IAstImportOptions {\r\n readonly importKind: AstImportKind;\r\n readonly modulePath: string;\r\n readonly exportName: string;\r\n readonly isTypeOnly: boolean;\r\n}\r\n\r\n/**\r\n * For a symbol that was imported from an external package, this tracks the import\r\n * statement that was used to reach it.\r\n */\r\nexport class AstImport extends AstSyntheticEntity {\r\n public readonly importKind: AstImportKind;\r\n\r\n /**\r\n * The name of the external package (and possibly module path) that this definition\r\n * was imported from.\r\n *\r\n * Example: \"@rushstack/node-core-library/lib/FileSystem\"\r\n */\r\n public readonly modulePath: string;\r\n\r\n /**\r\n * The name of the symbol being imported.\r\n *\r\n * @remarks\r\n *\r\n * The name depends on the type of import:\r\n *\r\n * ```ts\r\n * // For AstImportKind.DefaultImport style, exportName would be \"X\" in this example:\r\n * import X from \"y\";\r\n *\r\n * // For AstImportKind.NamedImport style, exportName would be \"X\" in this example:\r\n * import { X } from \"y\";\r\n *\r\n * // For AstImportKind.StarImport style, exportName would be \"x\" in this example:\r\n * import * as x from \"y\";\r\n *\r\n * // For AstImportKind.EqualsImport style, exportName would be \"x\" in this example:\r\n * import x = require(\"y\");\r\n *\r\n * // For AstImportKind.ImportType style, exportName would be \"a.b.c\" in this example:\r\n * interface foo { foo: import('bar').a.b.c };\r\n * ```\r\n */\r\n public readonly exportName: string;\r\n\r\n /**\r\n * Whether it is a type-only import, for example:\r\n *\r\n * ```ts\r\n * import type { X } from \"y\";\r\n * ```\r\n *\r\n * This is set to true ONLY if the type-only form is used in *every* reference to this AstImport.\r\n */\r\n public isTypeOnlyEverywhere: boolean;\r\n\r\n /**\r\n * If this import statement refers to an API from an external package that is tracked by API Extractor\r\n * (according to `PackageMetadataManager.isAedocSupportedFor()`), then this property will return the\r\n * corresponding AstSymbol. Otherwise, it is undefined.\r\n */\r\n public astSymbol: AstSymbol | undefined;\r\n\r\n /**\r\n * If modulePath and exportName are defined, then this is a dictionary key\r\n * that combines them with a colon (\":\").\r\n *\r\n * Example: \"@rushstack/node-core-library/lib/FileSystem:FileSystem\"\r\n */\r\n public readonly key: string;\r\n\r\n public constructor(options: IAstImportOptions) {\r\n super();\r\n\r\n this.importKind = options.importKind;\r\n this.modulePath = options.modulePath;\r\n this.exportName = options.exportName;\r\n\r\n // We start with this assumption, but it may get changed later if non-type-only import is encountered.\r\n this.isTypeOnlyEverywhere = options.isTypeOnly;\r\n\r\n this.key = AstImport.getKey(options);\r\n }\r\n\r\n /** {@inheritdoc} */\r\n public get localName(): string {\r\n // abstract\r\n return this.exportName;\r\n }\r\n\r\n /**\r\n * Calculates the lookup key used with `AstImport.key`\r\n */\r\n public static getKey(options: IAstImportOptions): string {\r\n switch (options.importKind) {\r\n case AstImportKind.DefaultImport:\r\n return `${options.modulePath}:${options.exportName}`;\r\n case AstImportKind.NamedImport:\r\n return `${options.modulePath}:${options.exportName}`;\r\n case AstImportKind.StarImport:\r\n return `${options.modulePath}:*`;\r\n case AstImportKind.EqualsImport:\r\n return `${options.modulePath}:=`;\r\n case AstImportKind.ImportType: {\r\n const subKey: string = !options.exportName\r\n ? '*' // Equivalent to StarImport\r\n : options.exportName.includes('.') // Equivalent to a named export\r\n ? options.exportName.split('.')[0]\r\n : options.exportName;\r\n return `${options.modulePath}:${subKey}`;\r\n }\r\n default:\r\n throw new InternalError('Unknown AstImportKind');\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AstImport.js","sourceRoot":"","sources":["../../src/analyzer/AstImport.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oEAA6D;AAC7D,2CAAiD;AAEjD;;GAEG;AACH,IAAY,aAyBX;AAzBD,WAAY,aAAa;IACvB;;OAEG;IACH,mEAAa,CAAA;IAEb;;OAEG;IACH,+DAAW,CAAA;IAEX;;OAEG;IACH,6DAAU,CAAA;IAEV;;OAEG;IACH,iEAAY,CAAA;IAEZ;;OAEG;IACH,6DAAU,CAAA;AACZ,CAAC,EAzBW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAyBxB;AAkBD;;;GAGG;AACH,MAAa,SAAU,SAAQ,8BAAkB;IA+D/C,YAAmB,OAA0B;QAC3C,KAAK,EAAE,CAAC;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AO,CAAC,UAAU,IAAI,MAAM,EAAE,CAAC;aAC1C;YACD;gBACE,MAAM,IAAI,iCAAa,CAAC,uBAAuB,CAAC,CAAC;SACpD;IACH,CAAC;CACF;AA3GD,8BA2GC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { AstSymbol } from './AstSymbol';\nimport { InternalError } from '@rushstack/node-core-library';\nimport { AstSyntheticEntity } from './AstEntity';\n\n/**\n * Indicates the import kind for an `AstImport`.\n */\nexport enum AstImportKind {\n /**\n * An import statement such as `import X from \"y\";`.\n */\n DefaultImport,\n\n /**\n * An import statement such as `import { X } from \"y\";`.\n */\n NamedImport,\n\n /**\n * An import statement such as `import * as x from \"y\";`.\n */\n StarImport,\n\n /**\n * An import statement such as `import x = require(\"y\");`.\n */\n EqualsImport,\n\n /**\n * An import statement such as `interface foo { foo: import(\"bar\").a.b.c }`.\n */\n ImportType\n}\n\n/**\n * Constructor parameters for AstImport\n *\n * @privateRemarks\n * Our naming convention is to use I____Parameters for constructor options and\n * I____Options for general function options. However the word \"parameters\" is\n * confusingly similar to the terminology for function parameters modeled by API Extractor,\n * so we use I____Options for both cases in this code base.\n */\nexport interface IAstImportOptions {\n readonly importKind: AstImportKind;\n readonly modulePath: string;\n readonly exportName: string;\n readonly isTypeOnly: boolean;\n}\n\n/**\n * For a symbol that was imported from an external package, this tracks the import\n * statement that was used to reach it.\n */\nexport class AstImport extends AstSyntheticEntity {\n public readonly importKind: AstImportKind;\n\n /**\n * The name of the external package (and possibly module path) that this definition\n * was imported from.\n *\n * Example: \"@rushstack/node-core-library/lib/FileSystem\"\n */\n public readonly modulePath: string;\n\n /**\n * The name of the symbol being imported.\n *\n * @remarks\n *\n * The name depends on the type of import:\n *\n * ```ts\n * // For AstImportKind.DefaultImport style, exportName would be \"X\" in this example:\n * import X from \"y\";\n *\n * // For AstImportKind.NamedImport style, exportName would be \"X\" in this example:\n * import { X } from \"y\";\n *\n * // For AstImportKind.StarImport style, exportName would be \"x\" in this example:\n * import * as x from \"y\";\n *\n * // For AstImportKind.EqualsImport style, exportName would be \"x\" in this example:\n * import x = require(\"y\");\n *\n * // For AstImportKind.ImportType style, exportName would be \"a.b.c\" in this example:\n * interface foo { foo: import('bar').a.b.c };\n * ```\n */\n public readonly exportName: string;\n\n /**\n * Whether it is a type-only import, for example:\n *\n * ```ts\n * import type { X } from \"y\";\n * ```\n *\n * This is set to true ONLY if the type-only form is used in *every* reference to this AstImport.\n */\n public isTypeOnlyEverywhere: boolean;\n\n /**\n * If this import statement refers to an API from an external package that is tracked by API Extractor\n * (according to `PackageMetadataManager.isAedocSupportedFor()`), then this property will return the\n * corresponding AstSymbol. Otherwise, it is undefined.\n */\n public astSymbol: AstSymbol | undefined;\n\n /**\n * If modulePath and exportName are defined, then this is a dictionary key\n * that combines them with a colon (\":\").\n *\n * Example: \"@rushstack/node-core-library/lib/FileSystem:FileSystem\"\n */\n public readonly key: string;\n\n public constructor(options: IAstImportOptions) {\n super();\n\n this.importKind = options.importKind;\n this.modulePath = options.modulePath;\n this.exportName = options.exportName;\n\n // We start with this assumption, but it may get changed later if non-type-only import is encountered.\n this.isTypeOnlyEverywhere = options.isTypeOnly;\n\n this.key = AstImport.getKey(options);\n }\n\n /** {@inheritdoc} */\n public get localName(): string {\n // abstract\n return this.exportName;\n }\n\n /**\n * Calculates the lookup key used with `AstImport.key`\n */\n public static getKey(options: IAstImportOptions): string {\n switch (options.importKind) {\n case AstImportKind.DefaultImport:\n return `${options.modulePath}:${options.exportName}`;\n case AstImportKind.NamedImport:\n return `${options.modulePath}:${options.exportName}`;\n case AstImportKind.StarImport:\n return `${options.modulePath}:*`;\n case AstImportKind.EqualsImport:\n return `${options.modulePath}:=`;\n case AstImportKind.ImportType: {\n const subKey: string = !options.exportName\n ? '*' // Equivalent to StarImport\n : options.exportName.includes('.') // Equivalent to a named export\n ? options.exportName.split('.')[0]\n : options.exportName;\n return `${options.modulePath}:${subKey}`;\n }\n default:\n throw new InternalError('Unknown AstImportKind');\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AstModule.js","sourceRoot":"","sources":["../../src/analyzer/AstModule.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAO3D;;GAEG;AACH,MAAa,mBAAmB;IAAhC;QACkB,0BAAqB,GAA2B,IAAI,GAAG,EAAqB,CAAC;QAC7E,gCAA2B,GAAmB,IAAI,GAAG,EAAa,CAAC;IACrF,CAAC;CAAA;AAHD,kDAGC;AAiBD;;GAEG;AACH,MAAa,SAAS;IAkCpB,YAAmB,OAA0B;QAC3C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QAEzC,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QAErD,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAa,CAAC;QAEhD,IAAI,CAAC,sBAAsB,GAAG,IAAI,GAAG,EAAqB,CAAC;QAE3D,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,kBAAkB,KAAK,SAAS,CAAC;IAC/C,CAAC;CACF;AArDD,8BAqDC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type * as ts from 'typescript';\r\n\r\nimport type { AstSymbol } from './AstSymbol';\r\nimport type { AstEntity } from './AstEntity';\r\n\r\n/**\r\n * Represents information collected by {@link AstSymbolTable.fetchAstModuleExportInfo}\r\n */\r\nexport class AstModuleExportInfo {\r\n public readonly exportedLocalEntities: Map<string, AstEntity> = new Map<string, AstEntity>();\r\n public readonly starExportedExternalModules: Set<AstModule> = new Set<AstModule>();\r\n}\r\n\r\n/**\r\n * Constructor parameters for AstModule\r\n *\r\n * @privateRemarks\r\n * Our naming convention is to use I____Parameters for constructor options and\r\n * I____Options for general function options. However the word \"parameters\" is\r\n * confusingly similar to the terminology for function parameters modeled by API Extractor,\r\n * so we use I____Options for both cases in this code base.\r\n */\r\nexport interface IAstModuleOptions {\r\n sourceFile: ts.SourceFile;\r\n moduleSymbol: ts.Symbol;\r\n externalModulePath: string | undefined;\r\n}\r\n\r\n/**\r\n * An internal data structure that represents a source file that is analyzed by AstSymbolTable.\r\n */\r\nexport class AstModule {\r\n /**\r\n * The source file that declares this TypeScript module. In most cases, the source file's\r\n * top-level exports constitute the module.\r\n */\r\n public readonly sourceFile: ts.SourceFile;\r\n\r\n /**\r\n * The symbol for the module. Typically this corresponds to ts.SourceFile itself, however\r\n * in some cases the ts.SourceFile may contain multiple modules declared using the `module` keyword.\r\n */\r\n public readonly moduleSymbol: ts.Symbol;\r\n\r\n /**\r\n * Example: \"@rushstack/node-core-library/lib/FileSystem\"\r\n * but never: \"./FileSystem\"\r\n */\r\n public readonly externalModulePath: string | undefined;\r\n\r\n /**\r\n * A list of other `AstModule` objects that appear in `export * from \"___\";` statements.\r\n */\r\n public readonly starExportedModules: Set<AstModule>;\r\n\r\n /**\r\n * A partial map of entities exported by this module. The key is the exported name.\r\n */\r\n public readonly cachedExportedEntities: Map<string, AstEntity>; // exportName --> entity\r\n\r\n /**\r\n * Additional state calculated by `AstSymbolTable.fetchWorkingPackageModule()`.\r\n */\r\n public astModuleExportInfo: AstModuleExportInfo | undefined;\r\n\r\n public constructor(options: IAstModuleOptions) {\r\n this.sourceFile = options.sourceFile;\r\n this.moduleSymbol = options.moduleSymbol;\r\n\r\n this.externalModulePath = options.externalModulePath;\r\n\r\n this.starExportedModules = new Set<AstModule>();\r\n\r\n this.cachedExportedEntities = new Map<string, AstSymbol>();\r\n\r\n this.astModuleExportInfo = undefined;\r\n }\r\n\r\n /**\r\n * If false, then this source file is part of the working package being processed by the `Collector`.\r\n */\r\n public get isExternal(): boolean {\r\n return this.externalModulePath !== undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AstModule.js","sourceRoot":"","sources":["../../src/analyzer/AstModule.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAO3D;;GAEG;AACH,MAAa,mBAAmB;IAAhC;QACkB,0BAAqB,GAA2B,IAAI,GAAG,EAAqB,CAAC;QAC7E,gCAA2B,GAAmB,IAAI,GAAG,EAAa,CAAC;IACrF,CAAC;CAAA;AAHD,kDAGC;AAiBD;;GAEG;AACH,MAAa,SAAS;IAkCpB,YAAmB,OAA0B;QAC3C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QAEzC,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QAErD,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAa,CAAC;QAEhD,IAAI,CAAC,sBAAsB,GAAG,IAAI,GAAG,EAAqB,CAAC;QAE3D,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,kBAAkB,KAAK,SAAS,CAAC;IAC/C,CAAC;CACF;AArDD,8BAqDC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as ts from 'typescript';\n\nimport type { AstSymbol } from './AstSymbol';\nimport type { AstEntity } from './AstEntity';\n\n/**\n * Represents information collected by {@link AstSymbolTable.fetchAstModuleExportInfo}\n */\nexport class AstModuleExportInfo {\n public readonly exportedLocalEntities: Map<string, AstEntity> = new Map<string, AstEntity>();\n public readonly starExportedExternalModules: Set<AstModule> = new Set<AstModule>();\n}\n\n/**\n * Constructor parameters for AstModule\n *\n * @privateRemarks\n * Our naming convention is to use I____Parameters for constructor options and\n * I____Options for general function options. However the word \"parameters\" is\n * confusingly similar to the terminology for function parameters modeled by API Extractor,\n * so we use I____Options for both cases in this code base.\n */\nexport interface IAstModuleOptions {\n sourceFile: ts.SourceFile;\n moduleSymbol: ts.Symbol;\n externalModulePath: string | undefined;\n}\n\n/**\n * An internal data structure that represents a source file that is analyzed by AstSymbolTable.\n */\nexport class AstModule {\n /**\n * The source file that declares this TypeScript module. In most cases, the source file's\n * top-level exports constitute the module.\n */\n public readonly sourceFile: ts.SourceFile;\n\n /**\n * The symbol for the module. Typically this corresponds to ts.SourceFile itself, however\n * in some cases the ts.SourceFile may contain multiple modules declared using the `module` keyword.\n */\n public readonly moduleSymbol: ts.Symbol;\n\n /**\n * Example: \"@rushstack/node-core-library/lib/FileSystem\"\n * but never: \"./FileSystem\"\n */\n public readonly externalModulePath: string | undefined;\n\n /**\n * A list of other `AstModule` objects that appear in `export * from \"___\";` statements.\n */\n public readonly starExportedModules: Set<AstModule>;\n\n /**\n * A partial map of entities exported by this module. The key is the exported name.\n */\n public readonly cachedExportedEntities: Map<string, AstEntity>; // exportName --> entity\n\n /**\n * Additional state calculated by `AstSymbolTable.fetchWorkingPackageModule()`.\n */\n public astModuleExportInfo: AstModuleExportInfo | undefined;\n\n public constructor(options: IAstModuleOptions) {\n this.sourceFile = options.sourceFile;\n this.moduleSymbol = options.moduleSymbol;\n\n this.externalModulePath = options.externalModulePath;\n\n this.starExportedModules = new Set<AstModule>();\n\n this.cachedExportedEntities = new Map<string, AstSymbol>();\n\n this.astModuleExportInfo = undefined;\n }\n\n /**\n * If false, then this source file is part of the working package being processed by the `Collector`.\n */\n public get isExternal(): boolean {\n return this.externalModulePath !== undefined;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AstNamespaceImport.js","sourceRoot":"","sources":["../../src/analyzer/AstNamespaceImport.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAK3D,2CAAiD;AAUjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,kBAAmB,SAAQ,8BAAkB;IA6BxD,YAAmB,OAAmC;QACpD,KAAK,EAAE,CAAC;QA7BV;;;WAGG;QACI,aAAQ,GAAY,KAAK,CAAC;QA0B/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED,oBAAoB;IACpB,IAAW,SAAS;QAClB,WAAW;QACX,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAEM,wBAAwB,CAAC,SAAoB;QAClD,MAAM,mBAAmB,GAAwB,SAAS,CAAC,cAAc,CAAC,wBAAwB,CAChG,IAAI,CAAC,SAAS,CACf,CAAC;QACF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AAjDD,gDAiDC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type * as ts from 'typescript';\r\n\r\nimport type { AstModule, AstModuleExportInfo } from './AstModule';\r\nimport { AstSyntheticEntity } from './AstEntity';\r\nimport type { Collector } from '../collector/Collector';\r\n\r\nexport interface IAstNamespaceImportOptions {\r\n readonly astModule: AstModule;\r\n readonly namespaceName: string;\r\n readonly declaration: ts.Declaration;\r\n readonly symbol: ts.Symbol;\r\n}\r\n\r\n/**\r\n * `AstNamespaceImport` represents a namespace that is created implicitly by a statement\r\n * such as `import * as example from \"./file\";`\r\n *\r\n * @remarks\r\n *\r\n * A typical input looks like this:\r\n * ```ts\r\n * // Suppose that example.ts exports two functions f1() and f2().\r\n * import * as example from \"./file\";\r\n * export { example };\r\n * ```\r\n *\r\n * API Extractor's .d.ts rollup will transform it into an explicit namespace, like this:\r\n * ```ts\r\n * declare f1(): void;\r\n * declare f2(): void;\r\n *\r\n * declare namespace example {\r\n * export {\r\n * f1,\r\n * f2\r\n * }\r\n * }\r\n * ```\r\n *\r\n * The current implementation does not attempt to relocate f1()/f2() to be inside the `namespace`\r\n * because other type signatures may reference them directly (without using the namespace qualifier).\r\n * The `declare namespace example` is a synthetic construct represented by `AstNamespaceImport`.\r\n */\r\nexport class AstNamespaceImport extends AstSyntheticEntity {\r\n /**\r\n * Returns true if the AstSymbolTable.analyze() was called for this object.\r\n * See that function for details.\r\n */\r\n public analyzed: boolean = false;\r\n\r\n /**\r\n * For example, if the original statement was `import * as example from \"./file\";`\r\n * then `astModule` refers to the `./file.d.ts` file.\r\n */\r\n public readonly astModule: AstModule;\r\n\r\n /**\r\n * For example, if the original statement was `import * as example from \"./file\";`\r\n * then `namespaceName` would be `example`.\r\n */\r\n public readonly namespaceName: string;\r\n\r\n /**\r\n * The original `ts.SyntaxKind.NamespaceImport` which can be used as a location for error messages.\r\n */\r\n public readonly declaration: ts.Declaration;\r\n\r\n /**\r\n * The original `ts.SymbolFlags.Namespace` symbol.\r\n */\r\n public readonly symbol: ts.Symbol;\r\n\r\n public constructor(options: IAstNamespaceImportOptions) {\r\n super();\r\n this.astModule = options.astModule;\r\n this.namespaceName = options.namespaceName;\r\n this.declaration = options.declaration;\r\n this.symbol = options.symbol;\r\n }\r\n\r\n /** {@inheritdoc} */\r\n public get localName(): string {\r\n // abstract\r\n return this.namespaceName;\r\n }\r\n\r\n public fetchAstModuleExportInfo(collector: Collector): AstModuleExportInfo {\r\n const astModuleExportInfo: AstModuleExportInfo = collector.astSymbolTable.fetchAstModuleExportInfo(\r\n this.astModule\r\n );\r\n return astModuleExportInfo;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AstNamespaceImport.js","sourceRoot":"","sources":["../../src/analyzer/AstNamespaceImport.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAK3D,2CAAiD;AAUjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,kBAAmB,SAAQ,8BAAkB;IA6BxD,YAAmB,OAAmC;QACpD,KAAK,EAAE,CAAC;QA7BV;;;WAGG;QACI,aAAQ,GAAY,KAAK,CAAC;QA0B/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED,oBAAoB;IACpB,IAAW,SAAS;QAClB,WAAW;QACX,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAEM,wBAAwB,CAAC,SAAoB;QAClD,MAAM,mBAAmB,GAAwB,SAAS,CAAC,cAAc,CAAC,wBAAwB,CAChG,IAAI,CAAC,SAAS,CACf,CAAC;QACF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AAjDD,gDAiDC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as ts from 'typescript';\n\nimport type { AstModule, AstModuleExportInfo } from './AstModule';\nimport { AstSyntheticEntity } from './AstEntity';\nimport type { Collector } from '../collector/Collector';\n\nexport interface IAstNamespaceImportOptions {\n readonly astModule: AstModule;\n readonly namespaceName: string;\n readonly declaration: ts.Declaration;\n readonly symbol: ts.Symbol;\n}\n\n/**\n * `AstNamespaceImport` represents a namespace that is created implicitly by a statement\n * such as `import * as example from \"./file\";`\n *\n * @remarks\n *\n * A typical input looks like this:\n * ```ts\n * // Suppose that example.ts exports two functions f1() and f2().\n * import * as example from \"./file\";\n * export { example };\n * ```\n *\n * API Extractor's .d.ts rollup will transform it into an explicit namespace, like this:\n * ```ts\n * declare f1(): void;\n * declare f2(): void;\n *\n * declare namespace example {\n * export {\n * f1,\n * f2\n * }\n * }\n * ```\n *\n * The current implementation does not attempt to relocate f1()/f2() to be inside the `namespace`\n * because other type signatures may reference them directly (without using the namespace qualifier).\n * The `declare namespace example` is a synthetic construct represented by `AstNamespaceImport`.\n */\nexport class AstNamespaceImport extends AstSyntheticEntity {\n /**\n * Returns true if the AstSymbolTable.analyze() was called for this object.\n * See that function for details.\n */\n public analyzed: boolean = false;\n\n /**\n * For example, if the original statement was `import * as example from \"./file\";`\n * then `astModule` refers to the `./file.d.ts` file.\n */\n public readonly astModule: AstModule;\n\n /**\n * For example, if the original statement was `import * as example from \"./file\";`\n * then `namespaceName` would be `example`.\n */\n public readonly namespaceName: string;\n\n /**\n * The original `ts.SyntaxKind.NamespaceImport` which can be used as a location for error messages.\n */\n public readonly declaration: ts.Declaration;\n\n /**\n * The original `ts.SymbolFlags.Namespace` symbol.\n */\n public readonly symbol: ts.Symbol;\n\n public constructor(options: IAstNamespaceImportOptions) {\n super();\n this.astModule = options.astModule;\n this.namespaceName = options.namespaceName;\n this.declaration = options.declaration;\n this.symbol = options.symbol;\n }\n\n /** {@inheritdoc} */\n public get localName(): string {\n // abstract\n return this.namespaceName;\n }\n\n public fetchAstModuleExportInfo(collector: Collector): AstModuleExportInfo {\n const astModuleExportInfo: AstModuleExportInfo = collector.astSymbolTable.fetchAstModuleExportInfo(\n this.astModule\n );\n return astModuleExportInfo;\n }\n}\n"]}