Skip to content

Commit 8060ecc

Browse files
committed
Merge remote-tracking branch 'remotes/origin/main' into excerpt-tokens
2 parents caf47f4 + 5f56cf6 commit 8060ecc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1103
-633
lines changed

apps/api-extractor/src/api/ExtractorMessageId.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ export const enum ExtractorMessageId {
9595
/**
9696
* "The property ___ has a setter but no getter."
9797
*/
98-
MissingGetter = 'ae-missing-getter'
98+
MissingGetter = 'ae-missing-getter',
99+
100+
/**
101+
* "Incorrect file type; API Extractor expects to analyze compiler outputs with the .d.ts file extension.
102+
* Troubleshooting tips: `https://api-extractor.com/link/dts-error`"
103+
*/
104+
WrongInputFileType = 'ae-wrong-input-file-type'
99105
}
100106

101107
export const allExtractorMessageIds: Set<string> = new Set<string>([
@@ -114,5 +120,6 @@ export const allExtractorMessageIds: Set<string> = new Set<string>([
114120
'ae-cyclic-inherit-doc',
115121
'ae-unresolved-link',
116122
'ae-setter-with-docs',
117-
'ae-missing-getter'
123+
'ae-missing-getter',
124+
'ae-wrong-input-file-type'
118125
]);

apps/api-extractor/src/collector/Collector.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ export class Collector {
188188
this.messageRouter.addCompilerDiagnostic(diagnostic);
189189
}
190190

191+
const sourceFiles: readonly ts.SourceFile[] = this.program.getSourceFiles();
192+
191193
if (this.messageRouter.showDiagnostics) {
192194
this.messageRouter.logDiagnosticHeader('Root filenames');
193195
for (const fileName of this.program.getRootFileNames()) {
@@ -196,12 +198,28 @@ export class Collector {
196198
this.messageRouter.logDiagnosticFooter();
197199

198200
this.messageRouter.logDiagnosticHeader('Files analyzed by compiler');
199-
for (const sourceFile of this.program.getSourceFiles()) {
201+
for (const sourceFile of sourceFiles) {
200202
this.messageRouter.logDiagnostic(sourceFile.fileName);
201203
}
202204
this.messageRouter.logDiagnosticFooter();
203205
}
204206

207+
// We can throw this error earlier in CompilerState.ts, but intentionally wait until after we've logged the
208+
// associated diagnostic message above to make debugging easier for developers.
209+
// Typically there will be many such files -- to avoid too much noise, only report the first one.
210+
const badSourceFile: ts.SourceFile | undefined = sourceFiles.find(
211+
({ fileName }) => !ExtractorConfig.hasDtsFileExtension(fileName)
212+
);
213+
if (badSourceFile) {
214+
this.messageRouter.addAnalyzerIssueForPosition(
215+
ExtractorMessageId.WrongInputFileType,
216+
'Incorrect file type; API Extractor expects to analyze compiler outputs with the .d.ts file extension. ' +
217+
'Troubleshooting tips: https://api-extractor.com/link/dts-error',
218+
badSourceFile,
219+
0
220+
);
221+
}
222+
205223
// Build the entry point
206224
const entryPointSourceFile: ts.SourceFile = this.workingPackage.entryPointSourceFile;
207225

apps/api-extractor/src/generators/ApiModelGenerator.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ export class ApiModelGenerator {
202202
this._processApiProperty(astDeclaration, exportedName, parentApiItem);
203203
break;
204204

205+
case ts.SyntaxKind.SetAccessor:
206+
this._processApiProperty(astDeclaration, exportedName, parentApiItem);
207+
break;
208+
205209
case ts.SyntaxKind.IndexSignature:
206210
this._processApiIndexSignature(astDeclaration, exportedName, parentApiItem);
207211
break;
@@ -817,13 +821,17 @@ export class ApiModelGenerator {
817821
let apiProperty: ApiProperty | undefined = parentApiItem.tryGetMemberByKey(containerKey) as ApiProperty;
818822

819823
if (apiProperty === undefined) {
820-
const propertyDeclaration: ts.PropertyDeclaration =
821-
astDeclaration.declaration as ts.PropertyDeclaration;
822-
823824
const nodesToCapture: IExcerptBuilderNodeToCapture[] = [];
824825

825826
const propertyTypeTokenRange: IExcerptTokenRange = ExcerptBuilder.createEmptyTokenRange();
826-
nodesToCapture.push({ node: propertyDeclaration.type, tokenRange: propertyTypeTokenRange });
827+
828+
// If the property declaration's type is `undefined`, then we're processing a setter with no corresponding
829+
// getter. Use the parameter type instead (note that TypeScript always reports an error if a setter
830+
// does not have exactly one parameter).
831+
const propertyTypeNode: ts.TypeNode | undefined =
832+
(astDeclaration.declaration as ts.PropertyDeclaration | ts.GetAccessorDeclaration).type ||
833+
(astDeclaration.declaration as ts.SetAccessorDeclaration).parameters[0].type;
834+
nodesToCapture.push({ node: propertyTypeNode, tokenRange: propertyTypeTokenRange });
827835

828836
const excerptTokens: IExcerptToken[] = this._buildExcerptTokens(astDeclaration, nodesToCapture);
829837
const apiItemMetadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);

apps/api-extractor/src/schemas/api-extractor-defaults.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
"ae-unresolved-inheritdoc-base": {
7373
"logLevel": "warning",
7474
"addToApiReportFile": true
75+
},
76+
"ae-wrong-input-file-type": {
77+
"logLevel": "error"
7578
}
7679
},
7780
"tsdocMessageReporting": {

apps/rush/CHANGELOG.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
{
22
"name": "@microsoft/rush",
33
"entries": [
4+
{
5+
"version": "5.70.0",
6+
"tag": "@microsoft/rush_v5.70.0",
7+
"date": "Wed, 11 May 2022 22:21:40 GMT",
8+
"comments": {
9+
"none": [
10+
{
11+
"comment": "Add a new `afterExecuteOperations` hook to phased command execution. This hook is used for the console timeline view and the standard result summary."
12+
}
13+
]
14+
}
15+
},
416
{
517
"version": "5.69.0",
618
"tag": "@microsoft/rush_v5.69.0",

apps/rush/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log - @microsoft/rush
22

3-
This log was last generated on Tue, 10 May 2022 01:20:58 GMT and should not be manually modified.
3+
This log was last generated on Wed, 11 May 2022 22:21:40 GMT and should not be manually modified.
4+
5+
## 5.70.0
6+
Wed, 11 May 2022 22:21:40 GMT
7+
8+
### Updates
9+
10+
- Add a new `afterExecuteOperations` hook to phased command execution. This hook is used for the console timeline view and the standard result summary.
411

512
## 5.69.0
613
Tue, 10 May 2022 01:20:58 GMT

apps/rush/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/rush",
3-
"version": "5.69.0",
3+
"version": "5.70.0",
44
"description": "A professional solution for consolidating all your JavaScript projects in one Git repo",
55
"keywords": [
66
"install",

build-tests/api-documenter-test/config/api-extractor.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,14 @@
1818
"enabled": false
1919
},
2020

21-
"testMode": true
21+
"testMode": true,
22+
23+
"messages": {
24+
"extractorMessageReporting": {
25+
// Purposefully disabled for the `writeonlyProperty` test case.
26+
"ae-missing-getter": {
27+
"logLevel": "none"
28+
}
29+
}
30+
}
2231
}

build-tests/api-documenter-test/etc/api-documenter-test.api.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,33 @@
905905
"endIndex": 2
906906
},
907907
"isStatic": false
908+
},
909+
{
910+
"kind": "Property",
911+
"canonicalReference": "api-documenter-test!DocClass1#writeonlyProperty:member",
912+
"docComment": "/**\n * API Extractor will surface an `ae-missing-getter` finding for this property.\n */\n",
913+
"excerptTokens": [
914+
{
915+
"kind": "Content",
916+
"text": "set writeonlyProperty(value: "
917+
},
918+
{
919+
"kind": "Content",
920+
"text": "string"
921+
},
922+
{
923+
"kind": "Content",
924+
"text": ");"
925+
}
926+
],
927+
"isOptional": false,
928+
"releaseTag": "Public",
929+
"name": "writeonlyProperty",
930+
"propertyTypeTokenRange": {
931+
"startIndex": 1,
932+
"endIndex": 2
933+
},
934+
"isStatic": false
908935
}
909936
],
910937
"extendsTokenRange": {

build-tests/api-documenter-test/etc/api-documenter-test.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class DocClass1 extends DocBaseClass implements IDocInterface1, IDocInter
4949
// (undocumented)
5050
get writeableProperty(): string;
5151
set writeableProperty(value: string);
52+
set writeonlyProperty(value: string);
5253
}
5354

5455
// @public

build-tests/api-documenter-test/etc/markdown/api-documenter-test.docclass1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The constructor for this class is marked as internal. Third-party code should no
3838
| [readonlyProperty](./api-documenter-test.docclass1.readonlyproperty.md) | | string | |
3939
| [regularProperty](./api-documenter-test.docclass1.regularproperty.md) | | [SystemEvent](./api-documenter-test.systemevent.md) | This is a regular property that happens to use the SystemEvent type. |
4040
| [writeableProperty](./api-documenter-test.docclass1.writeableproperty.md) | | string | |
41+
| [writeonlyProperty](./api-documenter-test.docclass1.writeonlyproperty.md) | | string | API Extractor will surface an <code>ae-missing-getter</code> finding for this property. |
4142
4243
## Methods
4344
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [api-documenter-test](./api-documenter-test.md) &gt; [DocClass1](./api-documenter-test.docclass1.md) &gt; [writeonlyProperty](./api-documenter-test.docclass1.writeonlyproperty.md)
4+
5+
## DocClass1.writeonlyProperty property
6+
7+
API Extractor will surface an `ae-missing-getter` finding for this property.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
set writeonlyProperty(value: string);
13+
```

build-tests/api-documenter-test/etc/yaml/api-documenter-test/docclass1.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ properties:
6161
set writeableProperty(value: string);
6262
return:
6363
type: string
64+
- name: writeonlyProperty
65+
uid: 'api-documenter-test!DocClass1#writeonlyProperty:member'
66+
package: api-documenter-test!
67+
fullName: writeonlyProperty
68+
summary: API Extractor will surface an `ae-missing-getter` finding for this property.
69+
remarks: ''
70+
example: []
71+
isPreview: false
72+
isDeprecated: false
73+
syntax:
74+
content: 'set writeonlyProperty(value: string);'
75+
return:
76+
type: string
6477
methods:
6578
- name: deprecatedExample()
6679
uid: 'api-documenter-test!DocClass1#deprecatedExample:member(1)'

build-tests/api-documenter-test/src/DocClass1.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ export class DocClass1 extends DocBaseClass implements IDocInterface1, IDocInter
206206
}
207207
public set writeableProperty(value: string) {}
208208

209+
/**
210+
* API Extractor will surface an `ae-missing-getter` finding for this property.
211+
*/
212+
public set writeonlyProperty(value: string) {}
213+
209214
/**
210215
* This event is fired whenever the object is modified.
211216
* @eventProperty
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/api-extractor",
5+
"comment": "Throw an error early if API Extractor will attempt to process non-.d.ts files",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@microsoft/api-extractor"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/api-extractor",
5+
"comment": "Generate API doc model nodes for setters without getters",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@microsoft/api-extractor"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Write local telemetry for all phased commands, including partial runs when running in watch mode.",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Export the list of workspace packages to the pnpmfile shim.",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush"
10+
}

common/config/rush/version-policies.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
{
103103
"policyName": "rush",
104104
"definitionName": "lockStepVersion",
105-
"version": "5.69.0",
105+
"version": "5.70.0",
106106
"nextBump": "minor",
107107
"mainProject": "@microsoft/rush"
108108
}

common/reviews/api/api-extractor.api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ export const enum ExtractorMessageId {
141141
SetterWithDocs = "ae-setter-with-docs",
142142
UnresolvedInheritDocBase = "ae-unresolved-inheritdoc-base",
143143
UnresolvedInheritDocReference = "ae-unresolved-inheritdoc-reference",
144-
UnresolvedLink = "ae-unresolved-link"
144+
UnresolvedLink = "ae-unresolved-link",
145+
WrongInputFileType = "ae-wrong-input-file-type"
145146
}
146147

147148
// @public

common/reviews/api/rush-lib.api.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ export interface IEnvironmentConfigurationInitializeOptions {
287287
doNotNormalizePaths?: boolean;
288288
}
289289

290+
// @alpha
291+
export interface IExecutionResult {
292+
readonly operationResults: ReadonlyMap<Operation, IOperationExecutionResult>;
293+
readonly status: OperationStatus;
294+
}
295+
290296
// @beta
291297
export interface IExperimentsJson {
292298
buildCacheWithAllowWarningsInSuccessfulBuild?: boolean;
@@ -360,6 +366,14 @@ export class IndividualVersionPolicy extends VersionPolicy {
360366
export interface _INpmOptionsJson extends IPackageManagerOptionsJsonBase {
361367
}
362368

369+
// @alpha
370+
export interface IOperationExecutionResult {
371+
readonly error: Error | undefined;
372+
readonly status: OperationStatus;
373+
readonly stdioSummarizer: StdioSummarizer;
374+
readonly stopwatch: IStopwatchResult;
375+
}
376+
363377
// @alpha
364378
export interface IOperationOptions {
365379
phase?: IPhase | undefined;
@@ -446,12 +460,20 @@ export interface IRushSessionOptions {
446460
terminalProvider: ITerminalProvider;
447461
}
448462

463+
// @alpha
464+
export interface IStopwatchResult {
465+
get duration(): number;
466+
get endTime(): number | undefined;
467+
get startTime(): number | undefined;
468+
toString(): string;
469+
}
470+
449471
// @beta (undocumented)
450472
export interface ITelemetryData {
451473
readonly durationInSeconds: number;
452474
// (undocumented)
453475
readonly extraData?: {
454-
[key: string]: string;
476+
[key: string]: string | number | boolean;
455477
};
456478
readonly name: string;
457479
readonly platform?: string;
@@ -605,6 +627,7 @@ export abstract class PackageManagerOptionsConfigurationBase implements IPackage
605627

606628
// @alpha
607629
export class PhasedCommandHooks {
630+
readonly afterExecuteOperations: AsyncSeriesHook<[IExecutionResult, ICreateOperationsContext]>;
608631
readonly createOperations: AsyncSeriesWaterfallHook<[Set<Operation>, ICreateOperationsContext]>;
609632
readonly waitingForChanges: SyncHook<void>;
610633
}

libraries/rush-lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/rush-lib",
3-
"version": "5.69.0",
3+
"version": "5.70.0",
44
"description": "A library for writing scripts that interact with the Rush tool",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)