Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/api-extractor/src/generators/DtsEmitHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ export class DtsEmitHelpers {
}

/**
* Checks if an export keyword is part of an ExportDeclaration inside a namespace
* (e.g., "export { Foo, Bar };" inside "declare namespace SDK { ... }").
* In that case, the export keyword must be preserved, otherwise the output is invalid TypeScript.
* Checks if an export keyword is part of an ExportDeclaration or ImportEqualsDeclaration inside a namespace
* (e.g., "export { Foo, Bar };" or "export import Foo = Bar.Foo;" inside "declare namespace SDK { ... }").
* In these cases, the export keyword must be preserved so the declaration remains valid and exported.
*/
public static isExportKeywordInNamespaceExportDeclaration(node: ts.Node): boolean {
if (node.parent && ts.isExportDeclaration(node.parent)) {
if (node.parent && (ts.isExportDeclaration(node.parent) || ts.isImportEqualsDeclaration(node.parent))) {
const moduleBlock: ts.ModuleBlock | undefined = TypeScriptHelpers.findFirstParent(
node,
ts.SyntaxKind.ModuleBlock
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
{
"metadata": {
"toolPackage": "@microsoft/api-extractor",
"toolVersion": "[test mode]",
"schemaVersion": 1011,
"oldestForwardsCompatibleVersion": 1001,
"tsdocConfig": {
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"noStandardTags": true,
"tagDefinitions": [
{
"tagName": "@alpha",
"syntaxKind": "modifier"
},
{
"tagName": "@beta",
"syntaxKind": "modifier"
},
{
"tagName": "@defaultValue",
"syntaxKind": "block"
},
{
"tagName": "@decorator",
"syntaxKind": "block",
"allowMultiple": true
},
{
"tagName": "@deprecated",
"syntaxKind": "block"
},
{
"tagName": "@eventProperty",
"syntaxKind": "modifier"
},
{
"tagName": "@example",
"syntaxKind": "block",
"allowMultiple": true
},
{
"tagName": "@experimental",
"syntaxKind": "modifier"
},
{
"tagName": "@inheritDoc",
"syntaxKind": "inline"
},
{
"tagName": "@internal",
"syntaxKind": "modifier"
},
{
"tagName": "@label",
"syntaxKind": "inline"
},
{
"tagName": "@link",
"syntaxKind": "inline",
"allowMultiple": true
},
{
"tagName": "@override",
"syntaxKind": "modifier"
},
{
"tagName": "@packageDocumentation",
"syntaxKind": "modifier"
},
{
"tagName": "@param",
"syntaxKind": "block",
"allowMultiple": true
},
{
"tagName": "@privateRemarks",
"syntaxKind": "block"
},
{
"tagName": "@public",
"syntaxKind": "modifier"
},
{
"tagName": "@readonly",
"syntaxKind": "modifier"
},
{
"tagName": "@remarks",
"syntaxKind": "block"
},
{
"tagName": "@returns",
"syntaxKind": "block"
},
{
"tagName": "@sealed",
"syntaxKind": "modifier"
},
{
"tagName": "@see",
"syntaxKind": "block"
},
{
"tagName": "@throws",
"syntaxKind": "block",
"allowMultiple": true
},
{
"tagName": "@typeParam",
"syntaxKind": "block",
"allowMultiple": true
},
{
"tagName": "@virtual",
"syntaxKind": "modifier"
},
{
"tagName": "@jsx",
"syntaxKind": "block"
},
{
"tagName": "@jsxRuntime",
"syntaxKind": "block"
},
{
"tagName": "@jsxFrag",
"syntaxKind": "block"
},
{
"tagName": "@jsxImportSource",
"syntaxKind": "block"
},
{
"tagName": "@betaDocumentation",
"syntaxKind": "modifier"
},
{
"tagName": "@internalRemarks",
"syntaxKind": "block"
},
{
"tagName": "@preapproved",
"syntaxKind": "modifier"
}
],
"supportForTags": {
"@alpha": true,
"@beta": true,
"@defaultValue": true,
"@decorator": true,
"@deprecated": true,
"@eventProperty": true,
"@example": true,
"@experimental": true,
"@inheritDoc": true,
"@internal": true,
"@label": true,
"@link": true,
"@override": true,
"@packageDocumentation": true,
"@param": true,
"@privateRemarks": true,
"@public": true,
"@readonly": true,
"@remarks": true,
"@returns": true,
"@sealed": true,
"@see": true,
"@throws": true,
"@typeParam": true,
"@virtual": true,
"@betaDocumentation": true,
"@internalRemarks": true,
"@preapproved": true
},
"reportUnsupportedHtmlElements": false
}
},
"kind": "Package",
"canonicalReference": "api-extractor-scenarios!",
"docComment": "",
"name": "api-extractor-scenarios",
"preserveMemberOrder": false,
"members": [
{
"kind": "EntryPoint",
"canonicalReference": "api-extractor-scenarios!",
"name": "",
"preserveMemberOrder": false,
"members": [
{
"kind": "Namespace",
"canonicalReference": "api-extractor-scenarios!Camera:namespace",
"docComment": "/**\n * @public\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "export declare namespace Camera "
}
],
"fileUrlPath": "src/namespaceImportEquals/index.ts",
"releaseTag": "Public",
"name": "Camera",
"preserveMemberOrder": false,
"members": [
{
"kind": "Enum",
"canonicalReference": "api-extractor-scenarios!Camera.TransitionType:enum",
"docComment": "",
"excerptTokens": [
{
"kind": "Content",
"text": "enum TransitionType "
}
],
"releaseTag": "Public",
"name": "TransitionType",
"preserveMemberOrder": false,
"members": [
{
"kind": "EnumMember",
"canonicalReference": "api-extractor-scenarios!Camera.TransitionType.FLY:member",
"docComment": "",
"excerptTokens": [
{
"kind": "Content",
"text": "FLY = "
},
{
"kind": "Content",
"text": "\"fly\""
}
],
"initializerTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"releaseTag": "Public",
"name": "FLY"
},
{
"kind": "EnumMember",
"canonicalReference": "api-extractor-scenarios!Camera.TransitionType.INSTANT:member",
"docComment": "",
"excerptTokens": [
{
"kind": "Content",
"text": "INSTANT = "
},
{
"kind": "Content",
"text": "\"instant\""
}
],
"initializerTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"releaseTag": "Public",
"name": "INSTANT"
}
]
}
]
},
{
"kind": "Namespace",
"canonicalReference": "api-extractor-scenarios!Sweep:namespace",
"docComment": "/**\n * @public\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "export declare namespace Sweep "
}
],
"fileUrlPath": "src/namespaceImportEquals/index.ts",
"releaseTag": "Public",
"name": "Sweep",
"preserveMemberOrder": false,
"members": [
{
"kind": "Namespace",
"canonicalReference": "api-extractor-scenarios!Sweep.Nested:namespace",
"docComment": "",
"excerptTokens": [
{
"kind": "Content",
"text": "namespace Nested "
}
],
"releaseTag": "Public",
"name": "Nested",
"preserveMemberOrder": false,
"members": []
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## API Report File for "api-extractor-scenarios"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

// @public (undocumented)
export namespace Camera {
// (undocumented)
export enum TransitionType {
// (undocumented)
FLY = "fly",
// (undocumented)
INSTANT = "instant"
}
}

// @public (undocumented)
export namespace Sweep {
export import Transition = Camera.TransitionType;
// (undocumented)
export namespace Nested {
export import Transition = Camera.TransitionType;
}
}

// (No @packageDocumentation comment for this package)

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @public */
export declare namespace Camera {
export enum TransitionType {
FLY = "fly",
INSTANT = "instant"
}
}

/** @public */
export declare namespace Sweep {
/** Alias kept for backward compatibility. */
export import Transition = Camera.TransitionType;
export namespace Nested {
export import Transition = Camera.TransitionType;
}
}

export { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

/** @public */
export namespace Camera {
export enum TransitionType {
FLY = 'fly',
INSTANT = 'instant'
}
}

/** @public */
export namespace Sweep {
/** Alias kept for backward compatibility. */
export import Transition = Camera.TransitionType;

export namespace Nested {
export import Transition = Camera.TransitionType;
}
}
Loading
Loading