-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fxied declaration emit for JS files when module.exports
is assigned a non-alias value and when it has extra type members
#56243
Merged
sandersn
merged 3 commits into
microsoft:main
from
Andarist:fix/js-dts-module-exports-non-alias-with-type-members
Jan 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
806de6d
Fxied declaration emit for JS files when `module.exports` is assigned…
Andarist d095ccd
Merge remote-tracking branch 'origin/main' into fix/js-dts-module-exp…
Andarist 4bba29b
use `Set` before converting to an array to avoid potential duplicates
Andarist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.js
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,35 @@ | ||
//// [tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.ts] //// | ||
|
||
//// [index.js] | ||
/** | ||
* @typedef Options | ||
* @property {string} opt | ||
*/ | ||
|
||
/** | ||
* @param {Options} options | ||
*/ | ||
module.exports = function loader(options) {} | ||
|
||
|
||
//// [index.js] | ||
"use strict"; | ||
/** | ||
* @typedef Options | ||
* @property {string} opt | ||
*/ | ||
/** | ||
* @param {Options} options | ||
*/ | ||
module.exports = function loader(options) { }; | ||
|
||
|
||
//// [index.d.ts] | ||
declare namespace _exports { | ||
export { Options }; | ||
} | ||
declare function _exports(options: Options): void; | ||
export = _exports; | ||
type Options = { | ||
opt: string; | ||
}; |
18 changes: 18 additions & 0 deletions
18
...selines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.symbols
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,18 @@ | ||
//// [tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.ts] //// | ||
|
||
=== index.js === | ||
/** | ||
* @typedef Options | ||
* @property {string} opt | ||
*/ | ||
|
||
/** | ||
* @param {Options} options | ||
*/ | ||
module.exports = function loader(options) {} | ||
>module.exports : Symbol(module.exports, Decl(index.js, 0, 0)) | ||
>module : Symbol(export=, Decl(index.js, 0, 0)) | ||
>exports : Symbol(export=, Decl(index.js, 0, 0)) | ||
>loader : Symbol(loader, Decl(index.js, 8, 16)) | ||
>options : Symbol(options, Decl(index.js, 8, 33)) | ||
|
20 changes: 20 additions & 0 deletions
20
...baselines/reference/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types
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,20 @@ | ||
//// [tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.ts] //// | ||
|
||
=== index.js === | ||
/** | ||
* @typedef Options | ||
* @property {string} opt | ||
*/ | ||
|
||
/** | ||
* @param {Options} options | ||
*/ | ||
module.exports = function loader(options) {} | ||
>module.exports = function loader(options) {} : (options: Options) => void | ||
>module.exports : (options: Options) => void | ||
>module : { exports: (options: Options) => void; } | ||
>exports : (options: Options) => void | ||
>function loader(options) {} : (options: Options) => void | ||
>loader : (options: Options) => void | ||
>options : Options | ||
|
16 changes: 16 additions & 0 deletions
16
tests/cases/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.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,16 @@ | ||
// @strict: true | ||
// @checkJs: true | ||
// @declaration: true | ||
// @outDir: out | ||
|
||
// @filename: index.js | ||
|
||
/** | ||
* @typedef Options | ||
* @property {string} opt | ||
*/ | ||
|
||
/** | ||
* @param {Options} options | ||
*/ | ||
module.exports = function loader(options) {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if you don't concatenate+filter? I thought the exports of
merged
would suffice to replacesymbol
's exports entirely. If not, what is missing inmerged
? Would it make more sense to start frommerged
's exports and add only specific things fromsymbol
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the diff below:
git diff
Maybe. Some time has past since I was investigating this and it is a little bit blurry to me at this point. Based on the diff above though we can't do that - we could only add more this way and with the diff above we already return too much.
Perhaps a different fix can be figured out though.