Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/main' into api-readonly-…
Browse files Browse the repository at this point in the history
…mixin

# Conflicts:
#	apps/api-extractor/src/generators/ApiModelGenerator.ts
#	build-tests/install-test-workspace/workspace/common/pnpm-lock.yaml
#	common/reviews/api/api-extractor-model.api.md
#	libraries/api-extractor-model/src/model/ApiProperty.ts
  • Loading branch information
octogonz committed Jun 7, 2022
2 parents a41f3fa + fd89af2 commit 7913201
Show file tree
Hide file tree
Showing 272 changed files with 7,254 additions and 1,127 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -62,6 +62,8 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/libraries/debug-certificate-manager](./libraries/debug-certificate-manager/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fdebug-certificate-manager.svg)](https://badge.fury.io/js/%40rushstack%2Fdebug-certificate-manager) | [changelog](./libraries/debug-certificate-manager/CHANGELOG.md) | [@rushstack/debug-certificate-manager](https://www.npmjs.com/package/@rushstack/debug-certificate-manager) |
| [/libraries/heft-config-file](./libraries/heft-config-file/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft-config-file.svg)](https://badge.fury.io/js/%40rushstack%2Fheft-config-file) | [changelog](./libraries/heft-config-file/CHANGELOG.md) | [@rushstack/heft-config-file](https://www.npmjs.com/package/@rushstack/heft-config-file) |
| [/libraries/load-themed-styles](./libraries/load-themed-styles/) | [![npm version](https://badge.fury.io/js/%40microsoft%2Fload-themed-styles.svg)](https://badge.fury.io/js/%40microsoft%2Fload-themed-styles) | [changelog](./libraries/load-themed-styles/CHANGELOG.md) | [@microsoft/load-themed-styles](https://www.npmjs.com/package/@microsoft/load-themed-styles) |
| [/libraries/localization-utilities](./libraries/localization-utilities/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Flocalization-utilities.svg)](https://badge.fury.io/js/%40rushstack%2Flocalization-utilities) | [changelog](./libraries/localization-utilities/CHANGELOG.md) | [@rushstack/localization-utilities](https://www.npmjs.com/package/@rushstack/localization-utilities) |
| [/libraries/module-minifier](./libraries/module-minifier/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fmodule-minifier.svg)](https://badge.fury.io/js/%40rushstack%2Fmodule-minifier) | [changelog](./libraries/module-minifier/CHANGELOG.md) | [@rushstack/module-minifier](https://www.npmjs.com/package/@rushstack/module-minifier) |
| [/libraries/node-core-library](./libraries/node-core-library/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fnode-core-library.svg)](https://badge.fury.io/js/%40rushstack%2Fnode-core-library) | [changelog](./libraries/node-core-library/CHANGELOG.md) | [@rushstack/node-core-library](https://www.npmjs.com/package/@rushstack/node-core-library) |
| [/libraries/package-deps-hash](./libraries/package-deps-hash/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fpackage-deps-hash.svg)](https://badge.fury.io/js/%40rushstack%2Fpackage-deps-hash) | [changelog](./libraries/package-deps-hash/CHANGELOG.md) | [@rushstack/package-deps-hash](https://www.npmjs.com/package/@rushstack/package-deps-hash) |
| [/libraries/rig-package](./libraries/rig-package/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frig-package.svg)](https://badge.fury.io/js/%40rushstack%2Frig-package) | [changelog](./libraries/rig-package/CHANGELOG.md) | [@rushstack/rig-package](https://www.npmjs.com/package/@rushstack/rig-package) |
Expand All @@ -72,6 +74,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/libraries/tree-pattern](./libraries/tree-pattern/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Ftree-pattern.svg)](https://badge.fury.io/js/%40rushstack%2Ftree-pattern) | [changelog](./libraries/tree-pattern/CHANGELOG.md) | [@rushstack/tree-pattern](https://www.npmjs.com/package/@rushstack/tree-pattern) |
| [/libraries/ts-command-line](./libraries/ts-command-line/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fts-command-line.svg)](https://badge.fury.io/js/%40rushstack%2Fts-command-line) | [changelog](./libraries/ts-command-line/CHANGELOG.md) | [@rushstack/ts-command-line](https://www.npmjs.com/package/@rushstack/ts-command-line) |
| [/libraries/typings-generator](./libraries/typings-generator/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Ftypings-generator.svg)](https://badge.fury.io/js/%40rushstack%2Ftypings-generator) | [changelog](./libraries/typings-generator/CHANGELOG.md) | [@rushstack/typings-generator](https://www.npmjs.com/package/@rushstack/typings-generator) |
| [/libraries/worker-pool](./libraries/worker-pool/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fworker-pool.svg)](https://badge.fury.io/js/%40rushstack%2Fworker-pool) | [changelog](./libraries/worker-pool/CHANGELOG.md) | [@rushstack/worker-pool](https://www.npmjs.com/package/@rushstack/worker-pool) |
| [/rigs/heft-node-rig](./rigs/heft-node-rig/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft-node-rig.svg)](https://badge.fury.io/js/%40rushstack%2Fheft-node-rig) | [changelog](./rigs/heft-node-rig/CHANGELOG.md) | [@rushstack/heft-node-rig](https://www.npmjs.com/package/@rushstack/heft-node-rig) |
| [/rigs/heft-web-rig](./rigs/heft-web-rig/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft-web-rig.svg)](https://badge.fury.io/js/%40rushstack%2Fheft-web-rig) | [changelog](./rigs/heft-web-rig/CHANGELOG.md) | [@rushstack/heft-web-rig](https://www.npmjs.com/package/@rushstack/heft-web-rig) |
| [/rush-plugins/rush-amazon-s3-build-cache-plugin](./rush-plugins/rush-amazon-s3-build-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-amazon-s3-build-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-amazon-s3-build-cache-plugin) | | [@rushstack/rush-amazon-s3-build-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-amazon-s3-build-cache-plugin) |
Expand All @@ -82,6 +85,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/webpack/loader-raw-script](./webpack/loader-raw-script/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Floader-raw-script.svg)](https://badge.fury.io/js/%40rushstack%2Floader-raw-script) | [changelog](./webpack/loader-raw-script/CHANGELOG.md) | [@rushstack/loader-raw-script](https://www.npmjs.com/package/@rushstack/loader-raw-script) |
| [/webpack/localization-plugin](./webpack/localization-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Flocalization-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Flocalization-plugin) | [changelog](./webpack/localization-plugin/CHANGELOG.md) | [@rushstack/localization-plugin](https://www.npmjs.com/package/@rushstack/localization-plugin) |
| [/webpack/module-minifier-plugin](./webpack/module-minifier-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fmodule-minifier-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fmodule-minifier-plugin) | [changelog](./webpack/module-minifier-plugin/CHANGELOG.md) | [@rushstack/module-minifier-plugin](https://www.npmjs.com/package/@rushstack/module-minifier-plugin) |
| [/webpack/module-minifier-plugin-5](./webpack/module-minifier-plugin-5/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fwebpack5-module-minifier-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fwebpack5-module-minifier-plugin) | [changelog](./webpack/module-minifier-plugin-5/CHANGELOG.md) | [@rushstack/webpack5-module-minifier-plugin](https://www.npmjs.com/package/@rushstack/webpack5-module-minifier-plugin) |
| [/webpack/preserve-dynamic-require-plugin](./webpack/preserve-dynamic-require-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fwebpack-preserve-dynamic-require-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fwebpack-preserve-dynamic-require-plugin) | [changelog](./webpack/preserve-dynamic-require-plugin/CHANGELOG.md) | [@rushstack/webpack-preserve-dynamic-require-plugin](https://www.npmjs.com/package/@rushstack/webpack-preserve-dynamic-require-plugin) |
| [/webpack/set-webpack-public-path-plugin](./webpack/set-webpack-public-path-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fset-webpack-public-path-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fset-webpack-public-path-plugin) | [changelog](./webpack/set-webpack-public-path-plugin/CHANGELOG.md) | [@rushstack/set-webpack-public-path-plugin](https://www.npmjs.com/package/@rushstack/set-webpack-public-path-plugin) |
| [/webpack/webpack-plugin-utilities](./webpack/webpack-plugin-utilities/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fwebpack-plugin-utilities.svg)](https://badge.fury.io/js/%40rushstack%2Fwebpack-plugin-utilities) | [changelog](./webpack/webpack-plugin-utilities/CHANGELOG.md) | [@rushstack/webpack-plugin-utilities](https://www.npmjs.com/package/@rushstack/webpack-plugin-utilities) |
Expand Down
30 changes: 30 additions & 0 deletions apps/api-documenter/CHANGELOG.json
@@ -1,6 +1,36 @@
{
"name": "@microsoft/api-documenter",
"entries": [
{
"version": "7.17.16",
"tag": "@microsoft/api-documenter_v7.17.16",
"date": "Wed, 25 May 2022 22:25:07 GMT",
"comments": {
"dependency": [
{
"comment": "Updating dependency \"@rushstack/heft\" to `0.45.5`"
},
{
"comment": "Updating dependency \"@rushstack/heft-node-rig\" to `1.9.6`"
}
]
}
},
{
"version": "7.17.15",
"tag": "@microsoft/api-documenter_v7.17.15",
"date": "Thu, 19 May 2022 15:13:20 GMT",
"comments": {
"dependency": [
{
"comment": "Updating dependency \"@rushstack/heft\" to `0.45.4`"
},
{
"comment": "Updating dependency \"@rushstack/heft-node-rig\" to `1.9.5`"
}
]
}
},
{
"version": "7.17.14",
"tag": "@microsoft/api-documenter_v7.17.14",
Expand Down
12 changes: 11 additions & 1 deletion apps/api-documenter/CHANGELOG.md
@@ -1,6 +1,16 @@
# Change Log - @microsoft/api-documenter

This log was last generated on Sat, 14 May 2022 03:01:27 GMT and should not be manually modified.
This log was last generated on Wed, 25 May 2022 22:25:07 GMT and should not be manually modified.

## 7.17.16
Wed, 25 May 2022 22:25:07 GMT

_Version update only_

## 7.17.15
Thu, 19 May 2022 15:13:20 GMT

_Version update only_

## 7.17.14
Sat, 14 May 2022 03:01:27 GMT
Expand Down
2 changes: 1 addition & 1 deletion apps/api-documenter/package.json
@@ -1,6 +1,6 @@
{
"name": "@microsoft/api-documenter",
"version": "7.17.14",
"version": "7.17.16",
"description": "Read JSON files from api-extractor, generate documentation pages",
"repository": {
"type": "git",
Expand Down
24 changes: 24 additions & 0 deletions apps/api-extractor/CHANGELOG.json
@@ -1,6 +1,30 @@
{
"name": "@microsoft/api-extractor",
"entries": [
{
"version": "7.24.2",
"tag": "@microsoft/api-extractor_v7.24.2",
"date": "Wed, 25 May 2022 22:25:07 GMT",
"comments": {
"patch": [
{
"comment": "Fix an issue where API Extractor would fail to run on a project where `\"moduleResolution\"` is set to `\"Node16\"` in `tsconfig.json`"
}
]
}
},
{
"version": "7.24.1",
"tag": "@microsoft/api-extractor_v7.24.1",
"date": "Thu, 19 May 2022 15:13:20 GMT",
"comments": {
"patch": [
{
"comment": "Fix a recent regression that produced an error \"Cannot read properties of undefined\" (GitHub #3423)"
}
]
}
},
{
"version": "7.24.0",
"tag": "@microsoft/api-extractor_v7.24.0",
Expand Down
16 changes: 15 additions & 1 deletion apps/api-extractor/CHANGELOG.md
@@ -1,6 +1,20 @@
# Change Log - @microsoft/api-extractor

This log was last generated on Sat, 14 May 2022 03:01:27 GMT and should not be manually modified.
This log was last generated on Wed, 25 May 2022 22:25:07 GMT and should not be manually modified.

## 7.24.2
Wed, 25 May 2022 22:25:07 GMT

### Patches

- Fix an issue where API Extractor would fail to run on a project where `"moduleResolution"` is set to `"Node16"` in `tsconfig.json`

## 7.24.1
Thu, 19 May 2022 15:13:20 GMT

### Patches

- Fix a recent regression that produced an error "Cannot read properties of undefined" (GitHub #3423)

## 7.24.0
Sat, 14 May 2022 03:01:27 GMT
Expand Down
2 changes: 1 addition & 1 deletion apps/api-extractor/package.json
@@ -1,6 +1,6 @@
{
"name": "@microsoft/api-extractor",
"version": "7.24.0",
"version": "7.24.2",
"description": "Analyze the exported API for a TypeScript library and generate reviews, documentation, and .d.ts rollups",
"keywords": [
"typescript",
Expand Down
22 changes: 20 additions & 2 deletions apps/api-extractor/src/analyzer/ExportAnalyzer.ts
Expand Up @@ -259,9 +259,18 @@ export class ExportAnalyzer {
importOrExportDeclaration: ts.ImportDeclaration | ts.ExportDeclaration | ts.ImportTypeNode,
moduleSpecifier: string
): boolean {
const specifier: ts.TypeNode | ts.Expression | undefined = ts.isImportTypeNode(importOrExportDeclaration)
? importOrExportDeclaration.argument
: importOrExportDeclaration.moduleSpecifier;
const mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined =
specifier && ts.isStringLiteralLike(specifier)
? TypeScriptInternals.getModeForUsageLocation(importOrExportDeclaration.getSourceFile(), specifier)
: undefined;

const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(
importOrExportDeclaration.getSourceFile(),
moduleSpecifier
moduleSpecifier,
mode
);

if (resolvedModule === undefined) {
Expand Down Expand Up @@ -863,9 +872,18 @@ export class ExportAnalyzer {
exportSymbol: ts.Symbol
): AstModule {
const moduleSpecifier: string = this._getModuleSpecifier(importOrExportDeclaration);
const mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined =
importOrExportDeclaration.moduleSpecifier &&
ts.isStringLiteralLike(importOrExportDeclaration.moduleSpecifier)
? TypeScriptInternals.getModeForUsageLocation(
importOrExportDeclaration.getSourceFile(),
importOrExportDeclaration.moduleSpecifier
)
: undefined;
const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(
importOrExportDeclaration.getSourceFile(),
moduleSpecifier
moduleSpecifier,
mode
);

if (resolvedModule === undefined) {
Expand Down
20 changes: 17 additions & 3 deletions apps/api-extractor/src/analyzer/TypeScriptInternals.ts
Expand Up @@ -83,12 +83,26 @@ export class TypeScriptInternals {
*/
public static getResolvedModule(
sourceFile: ts.SourceFile,
moduleNameText: string
moduleNameText: string,
mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined
): ts.ResolvedModuleFull | undefined {
// Compiler internal:
// https://github.com/microsoft/TypeScript/blob/v3.2.2/src/compiler/utilities.ts#L218
// https://github.com/microsoft/TypeScript/blob/v4.7.2/src/compiler/utilities.ts#L161

return (ts as any).getResolvedModule(sourceFile, moduleNameText);
return (ts as any).getResolvedModule(sourceFile, moduleNameText, mode);
}

/**
* Gets the mode required for module resolution required with the addition of Node16/nodenext
*/
public static getModeForUsageLocation(
file: { impliedNodeFormat?: ts.SourceFile['impliedNodeFormat'] },
usage: ts.StringLiteralLike | undefined
): ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined {
// Compiler internal:
// https://github.com/microsoft/TypeScript/blob/v4.7.2/src/compiler/program.ts#L568

return (ts as any).getModeForUsageLocation?.(file, usage);
}

/**
Expand Down
47 changes: 35 additions & 12 deletions apps/api-extractor/src/generators/ApiModelGenerator.ts
Expand Up @@ -43,7 +43,6 @@ import { DeclarationMetadata } from '../collector/DeclarationMetadata';
import { AstNamespaceImport } from '../analyzer/AstNamespaceImport';
import { AstEntity } from '../analyzer/AstEntity';
import { AstModule } from '../analyzer/AstModule';

import { TypeScriptInternals } from '../analyzer/TypeScriptInternals';

export class ApiModelGenerator {
Expand Down Expand Up @@ -336,10 +335,12 @@ export class ApiModelGenerator {
const apiItemMetadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
const docComment: tsdoc.DocComment | undefined = apiItemMetadata.tsdocComment;
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const isProtected: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;

apiConstructor = new ApiConstructor({
docComment,
releaseTag,
isProtected,
parameters,
overloadIndex,
excerptTokens
Expand Down Expand Up @@ -711,11 +712,13 @@ export class ApiModelGenerator {
}
const isOptional: boolean =
(astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
const isProtected: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;

apiMethod = new ApiMethod({
name,
docComment,
releaseTag,
isProtected,
isStatic,
isOptional,
typeParameters,
Expand Down Expand Up @@ -826,13 +829,20 @@ export class ApiModelGenerator {
const nodesToCapture: IExcerptBuilderNodeToCapture[] = [];

const propertyTypeTokenRange: IExcerptTokenRange = ExcerptBuilder.createEmptyTokenRange();
let propertyTypeNode: ts.TypeNode | undefined;

if (
ts.isPropertyDeclaration(astDeclaration.declaration) ||
ts.isGetAccessorDeclaration(astDeclaration.declaration)
) {
propertyTypeNode = astDeclaration.declaration.type;
}

if (ts.isSetAccessorDeclaration(astDeclaration.declaration)) {
// Note that TypeScript always reports an error if a setter does not have exactly one parameter.
propertyTypeNode = astDeclaration.declaration.parameters[0].type;
}

// If the property declaration's type is `undefined`, then we're processing a setter with no corresponding
// getter. Use the parameter type instead (note that TypeScript always reports an error if a setter
// does not have exactly one parameter).
const propertyTypeNode: ts.TypeNode | undefined =
(astDeclaration.declaration as ts.PropertyDeclaration | ts.GetAccessorDeclaration).type ||
(astDeclaration.declaration as ts.SetAccessorDeclaration).parameters[0].type;
nodesToCapture.push({ node: propertyTypeNode, tokenRange: propertyTypeTokenRange });

const excerptTokens: IExcerptToken[] = this._buildExcerptTokens(astDeclaration, nodesToCapture);
Expand All @@ -841,12 +851,14 @@ export class ApiModelGenerator {
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const isOptional: boolean =
(astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
const isProtected: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;
const isReadonly: boolean = this._determineReadonly(astDeclaration);

apiProperty = new ApiProperty({
name,
docComment,
releaseTag,
isProtected,
isStatic,
isOptional,
isReadonly,
Expand Down Expand Up @@ -976,7 +988,14 @@ export class ApiModelGenerator {
const releaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;
const isReadonly: boolean = this._determineReadonly(astDeclaration);

apiVariable = new ApiVariable({ name, docComment, releaseTag, excerptTokens, variableTypeTokenRange, isReadonly });
apiVariable = new ApiVariable({
name,
docComment,
releaseTag,
excerptTokens,
variableTypeTokenRange,
isReadonly
});

parentApiItem.addMember(apiVariable);
}
Expand Down Expand Up @@ -1058,9 +1077,13 @@ export class ApiModelGenerator {
//Line 2: sees if the TSDoc comment for @readonly is present
//Line 3: sees whether a getter is present for a property with no setter
//Line 4: sees if the var declaration has Const keyword
return (astDeclaration.modifierFlags & (ts.ModifierFlags.Readonly + ts.ModifierFlags.Const)) !== 0
|| (docComment !== undefined && docComment.modifierTagSet.hasTagName('@readonly'))
|| (declarationMetadata.ancillaryDeclarations.length === 0 && astDeclaration.declaration.kind === ts.SyntaxKind.GetAccessor)
|| ts.isVariableDeclaration(astDeclaration.declaration) && TypeScriptInternals.isVarConst(astDeclaration.declaration)
return (
(astDeclaration.modifierFlags & (ts.ModifierFlags.Readonly + ts.ModifierFlags.Const)) !== 0 ||
(docComment !== undefined && docComment.modifierTagSet.hasTagName('@readonly')) ||
(declarationMetadata.ancillaryDeclarations.length === 0 &&
astDeclaration.declaration.kind === ts.SyntaxKind.GetAccessor) ||
(ts.isVariableDeclaration(astDeclaration.declaration) &&
TypeScriptInternals.isVarConst(astDeclaration.declaration))
);
}
}

0 comments on commit 7913201

Please sign in to comment.