-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2239 from microsoft/octgonz/ae-typeof-fix
[api-extractor] Fix an InternalError when a declaration refers to itself using "typeof"
- Loading branch information
Showing
7 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
"preapproved", | ||
"typeOf", | ||
"typeOf2", | ||
"typeOf3", | ||
"typeParameters" | ||
] | ||
} |
153 changes: 153 additions & 0 deletions
153
...d-tests/api-extractor-scenarios/etc/test-outputs/typeOf3/api-extractor-scenarios.api.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
{ | ||
"metadata": { | ||
"toolPackage": "@microsoft/api-extractor", | ||
"toolVersion": "[test mode]", | ||
"schemaVersion": 1003, | ||
"oldestForwardsCompatibleVersion": 1001 | ||
}, | ||
"kind": "Package", | ||
"canonicalReference": "api-extractor-scenarios!", | ||
"docComment": "", | ||
"name": "api-extractor-scenarios", | ||
"members": [ | ||
{ | ||
"kind": "EntryPoint", | ||
"canonicalReference": "api-extractor-scenarios!", | ||
"name": "", | ||
"members": [ | ||
{ | ||
"kind": "Function", | ||
"canonicalReference": "api-extractor-scenarios!f1:function(1)", | ||
"docComment": "/**\n * A function that references its own parameter type.\n */\n", | ||
"excerptTokens": [ | ||
{ | ||
"kind": "Content", | ||
"text": "export declare function f1(x: " | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": "number" | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": "): " | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": "typeof " | ||
}, | ||
{ | ||
"kind": "Reference", | ||
"text": "x", | ||
"canonicalReference": "api-extractor-scenarios!~x:var" | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": ";" | ||
} | ||
], | ||
"returnTypeTokenRange": { | ||
"startIndex": 3, | ||
"endIndex": 5 | ||
}, | ||
"releaseTag": "Public", | ||
"overloadIndex": 1, | ||
"parameters": [ | ||
{ | ||
"parameterName": "x", | ||
"parameterTypeTokenRange": { | ||
"startIndex": 1, | ||
"endIndex": 2 | ||
} | ||
} | ||
], | ||
"name": "f1" | ||
}, | ||
{ | ||
"kind": "Function", | ||
"canonicalReference": "api-extractor-scenarios!f2:function(1)", | ||
"docComment": "/**\n * A function that indirectly references its own parameter type.\n */\n", | ||
"excerptTokens": [ | ||
{ | ||
"kind": "Content", | ||
"text": "export declare function f2(x: " | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": "number" | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": "): " | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": "keyof typeof " | ||
}, | ||
{ | ||
"kind": "Reference", | ||
"text": "x", | ||
"canonicalReference": "api-extractor-scenarios!~x:var" | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": ";" | ||
} | ||
], | ||
"returnTypeTokenRange": { | ||
"startIndex": 3, | ||
"endIndex": 5 | ||
}, | ||
"releaseTag": "Public", | ||
"overloadIndex": 1, | ||
"parameters": [ | ||
{ | ||
"parameterName": "x", | ||
"parameterTypeTokenRange": { | ||
"startIndex": 1, | ||
"endIndex": 2 | ||
} | ||
} | ||
], | ||
"name": "f2" | ||
}, | ||
{ | ||
"kind": "Function", | ||
"canonicalReference": "api-extractor-scenarios!f3:function(1)", | ||
"docComment": "/**\n * A function that references its own type.\n */\n", | ||
"excerptTokens": [ | ||
{ | ||
"kind": "Content", | ||
"text": "export declare function f3(): " | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": "typeof " | ||
}, | ||
{ | ||
"kind": "Reference", | ||
"text": "f3", | ||
"canonicalReference": "api-extractor-scenarios!f3:function" | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": " | undefined" | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": ";" | ||
} | ||
], | ||
"returnTypeTokenRange": { | ||
"startIndex": 1, | ||
"endIndex": 4 | ||
}, | ||
"releaseTag": "Public", | ||
"overloadIndex": 1, | ||
"parameters": [], | ||
"name": "f3" | ||
} | ||
] | ||
} | ||
] | ||
} |
19 changes: 19 additions & 0 deletions
19
...api-extractor-scenarios/etc/test-outputs/typeOf3/api-extractor-scenarios.api.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## 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 | ||
export function f1(x: number): typeof x; | ||
|
||
// @public | ||
export function f2(x: number): keyof typeof x; | ||
|
||
// @public | ||
export function f3(): typeof f3 | undefined; | ||
|
||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
17 changes: 17 additions & 0 deletions
17
build-tests/api-extractor-scenarios/etc/test-outputs/typeOf3/rollup.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
/** | ||
* A function that references its own parameter type. | ||
*/ | ||
export declare function f1(x: number): typeof x; | ||
|
||
/** | ||
* A function that indirectly references its own parameter type. | ||
*/ | ||
export declare function f2(x: number): keyof typeof x; | ||
|
||
/** | ||
* A function that references its own type. | ||
*/ | ||
export declare function f3(): typeof f3 | undefined; | ||
|
||
export { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
|
||
/** | ||
* A function that references its own parameter type. | ||
* @public | ||
*/ | ||
export function f1(x: number): typeof x { | ||
return x; | ||
} | ||
|
||
/** | ||
* A function that indirectly references its own parameter type. | ||
* @public | ||
*/ | ||
export function f2(x: number): keyof typeof x { | ||
return 'valueOf'; | ||
} | ||
|
||
/** | ||
* A function that references its own type. | ||
* @public | ||
*/ | ||
export function f3(): typeof f3 | undefined { | ||
return undefined; | ||
} |
11 changes: 11 additions & 0 deletions
11
common/changes/@microsoft/api-extractor/octgonz-ae-typeof-fix_2020-09-29-01-58.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@microsoft/api-extractor", | ||
"comment": "Fix an InternalError reported when a declaration referred to itself using \"tyepof\"", | ||
"type": "patch" | ||
} | ||
], | ||
"packageName": "@microsoft/api-extractor", | ||
"email": "[email protected]" | ||
} |