-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Serialize (noncontextual) keyword named namespace members with export declarations in both declaration emitters #38982
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
Merged
weswigham
merged 4 commits into
microsoft:master
from
weswigham:keyword-named-function-props
Jun 10, 2020
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6664d25
fix(38750): create unique names for keywords and re-export them with …
a-tarasyuk 944e1da
Serialize (noncontextual) keyword named namespace members with export…
weswigham 6f817b8
Merge remote-tracking branch 'a-tara/bug/38750' into keyword-named-fu…
weswigham f668e48
Add exhaustive keyword emit test for js declaration emitter and fix i…
weswigham 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/declarationEmitFunctionKeywordProp.js
This file contains hidden or 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,40 @@ | ||
//// [declarationEmitFunctionKeywordProp.ts] | ||
function foo() {} | ||
foo.null = true; | ||
|
||
function bar() {} | ||
bar.async = true; | ||
bar.normal = false; | ||
|
||
function baz() {} | ||
baz.class = true; | ||
baz.normal = false; | ||
|
||
//// [declarationEmitFunctionKeywordProp.js] | ||
function foo() { } | ||
foo["null"] = true; | ||
function bar() { } | ||
bar.async = true; | ||
bar.normal = false; | ||
function baz() { } | ||
baz["class"] = true; | ||
baz.normal = false; | ||
|
||
|
||
//// [declarationEmitFunctionKeywordProp.d.ts] | ||
declare function foo(): void; | ||
declare namespace foo { | ||
var _a: boolean; | ||
export { _a as null }; | ||
} | ||
declare function bar(): void; | ||
declare namespace bar { | ||
var async: boolean; | ||
var normal: boolean; | ||
} | ||
declare function baz(): void; | ||
declare namespace baz { | ||
var _a: boolean; | ||
export var normal: boolean; | ||
export { _a as class }; | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/declarationEmitFunctionKeywordProp.symbols
This file contains hidden or 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/declarationEmitFunctionKeywordProp.ts === | ||
function foo() {} | ||
>foo : Symbol(foo, Decl(declarationEmitFunctionKeywordProp.ts, 0, 0), Decl(declarationEmitFunctionKeywordProp.ts, 0, 17)) | ||
|
||
foo.null = true; | ||
>foo.null : Symbol(foo.null, Decl(declarationEmitFunctionKeywordProp.ts, 0, 17)) | ||
>foo : Symbol(foo, Decl(declarationEmitFunctionKeywordProp.ts, 0, 0), Decl(declarationEmitFunctionKeywordProp.ts, 0, 17)) | ||
>null : Symbol(foo.null, Decl(declarationEmitFunctionKeywordProp.ts, 0, 17)) | ||
|
||
function bar() {} | ||
>bar : Symbol(bar, Decl(declarationEmitFunctionKeywordProp.ts, 1, 16), Decl(declarationEmitFunctionKeywordProp.ts, 3, 17), Decl(declarationEmitFunctionKeywordProp.ts, 4, 17)) | ||
|
||
bar.async = true; | ||
>bar.async : Symbol(bar.async, Decl(declarationEmitFunctionKeywordProp.ts, 3, 17)) | ||
>bar : Symbol(bar, Decl(declarationEmitFunctionKeywordProp.ts, 1, 16), Decl(declarationEmitFunctionKeywordProp.ts, 3, 17), Decl(declarationEmitFunctionKeywordProp.ts, 4, 17)) | ||
>async : Symbol(bar.async, Decl(declarationEmitFunctionKeywordProp.ts, 3, 17)) | ||
|
||
bar.normal = false; | ||
>bar.normal : Symbol(bar.normal, Decl(declarationEmitFunctionKeywordProp.ts, 4, 17)) | ||
>bar : Symbol(bar, Decl(declarationEmitFunctionKeywordProp.ts, 1, 16), Decl(declarationEmitFunctionKeywordProp.ts, 3, 17), Decl(declarationEmitFunctionKeywordProp.ts, 4, 17)) | ||
>normal : Symbol(bar.normal, Decl(declarationEmitFunctionKeywordProp.ts, 4, 17)) | ||
|
||
function baz() {} | ||
>baz : Symbol(baz, Decl(declarationEmitFunctionKeywordProp.ts, 5, 19), Decl(declarationEmitFunctionKeywordProp.ts, 7, 17), Decl(declarationEmitFunctionKeywordProp.ts, 8, 17)) | ||
|
||
baz.class = true; | ||
>baz.class : Symbol(baz.class, Decl(declarationEmitFunctionKeywordProp.ts, 7, 17)) | ||
>baz : Symbol(baz, Decl(declarationEmitFunctionKeywordProp.ts, 5, 19), Decl(declarationEmitFunctionKeywordProp.ts, 7, 17), Decl(declarationEmitFunctionKeywordProp.ts, 8, 17)) | ||
>class : Symbol(baz.class, Decl(declarationEmitFunctionKeywordProp.ts, 7, 17)) | ||
|
||
baz.normal = false; | ||
>baz.normal : Symbol(baz.normal, Decl(declarationEmitFunctionKeywordProp.ts, 8, 17)) | ||
>baz : Symbol(baz, Decl(declarationEmitFunctionKeywordProp.ts, 5, 19), Decl(declarationEmitFunctionKeywordProp.ts, 7, 17), Decl(declarationEmitFunctionKeywordProp.ts, 8, 17)) | ||
>normal : Symbol(baz.normal, Decl(declarationEmitFunctionKeywordProp.ts, 8, 17)) | ||
|
45 changes: 45 additions & 0 deletions
45
tests/baselines/reference/declarationEmitFunctionKeywordProp.types
This file contains hidden or 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,45 @@ | ||
=== tests/cases/compiler/declarationEmitFunctionKeywordProp.ts === | ||
function foo() {} | ||
>foo : typeof foo | ||
|
||
foo.null = true; | ||
>foo.null = true : true | ||
>foo.null : boolean | ||
>foo : typeof foo | ||
>null : boolean | ||
>true : true | ||
|
||
function bar() {} | ||
>bar : typeof bar | ||
|
||
bar.async = true; | ||
>bar.async = true : true | ||
>bar.async : boolean | ||
>bar : typeof bar | ||
>async : boolean | ||
>true : true | ||
|
||
bar.normal = false; | ||
>bar.normal = false : false | ||
>bar.normal : boolean | ||
>bar : typeof bar | ||
>normal : boolean | ||
>false : false | ||
|
||
function baz() {} | ||
>baz : typeof baz | ||
|
||
baz.class = true; | ||
>baz.class = true : true | ||
>baz.class : boolean | ||
>baz : typeof baz | ||
>class : boolean | ||
>true : true | ||
|
||
baz.normal = false; | ||
>baz.normal = false : false | ||
>baz.normal : boolean | ||
>baz : typeof baz | ||
>normal : boolean | ||
>false : false | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
41 changes: 41 additions & 0 deletions
41
tests/baselines/reference/jsDeclarationsFunctionKeywordProp.js
This file contains hidden or 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,41 @@ | ||
//// [source.js] | ||
function foo() {} | ||
foo.null = true; | ||
|
||
function bar() {} | ||
bar.async = true; | ||
bar.normal = false; | ||
|
||
function baz() {} | ||
baz.class = true; | ||
baz.normal = false; | ||
|
||
//// [source.js] | ||
function foo() { } | ||
foo.null = true; | ||
function bar() { } | ||
bar.async = true; | ||
bar.normal = false; | ||
function baz() { } | ||
baz.class = true; | ||
baz.normal = false; | ||
|
||
|
||
//// [source.d.ts] | ||
declare function foo(): void; | ||
declare namespace foo { | ||
const _null: boolean; | ||
export { _null as null }; | ||
} | ||
declare function bar(): void; | ||
declare namespace bar { | ||
const async: boolean; | ||
const normal: boolean; | ||
} | ||
declare function baz(): void; | ||
declare namespace baz { | ||
const _class: boolean; | ||
export { _class as class }; | ||
const normal_1: boolean; | ||
export { normal_1 as normal }; | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/jsDeclarationsFunctionKeywordProp.symbols
This file contains hidden or 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/conformance/jsdoc/declarations/source.js === | ||
function foo() {} | ||
>foo : Symbol(foo, Decl(source.js, 0, 0), Decl(source.js, 0, 17)) | ||
|
||
foo.null = true; | ||
>foo.null : Symbol(foo.null, Decl(source.js, 0, 17)) | ||
>foo : Symbol(foo, Decl(source.js, 0, 0), Decl(source.js, 0, 17)) | ||
>null : Symbol(foo.null, Decl(source.js, 0, 17)) | ||
|
||
function bar() {} | ||
>bar : Symbol(bar, Decl(source.js, 1, 16), Decl(source.js, 3, 17), Decl(source.js, 4, 17)) | ||
|
||
bar.async = true; | ||
>bar.async : Symbol(bar.async, Decl(source.js, 3, 17)) | ||
>bar : Symbol(bar, Decl(source.js, 1, 16), Decl(source.js, 3, 17), Decl(source.js, 4, 17)) | ||
>async : Symbol(bar.async, Decl(source.js, 3, 17)) | ||
|
||
bar.normal = false; | ||
>bar.normal : Symbol(bar.normal, Decl(source.js, 4, 17)) | ||
>bar : Symbol(bar, Decl(source.js, 1, 16), Decl(source.js, 3, 17), Decl(source.js, 4, 17)) | ||
>normal : Symbol(bar.normal, Decl(source.js, 4, 17)) | ||
|
||
function baz() {} | ||
>baz : Symbol(baz, Decl(source.js, 5, 19), Decl(source.js, 7, 17), Decl(source.js, 8, 17)) | ||
|
||
baz.class = true; | ||
>baz.class : Symbol(baz.class, Decl(source.js, 7, 17)) | ||
>baz : Symbol(baz, Decl(source.js, 5, 19), Decl(source.js, 7, 17), Decl(source.js, 8, 17)) | ||
>class : Symbol(baz.class, Decl(source.js, 7, 17)) | ||
|
||
baz.normal = false; | ||
>baz.normal : Symbol(baz.normal, Decl(source.js, 8, 17)) | ||
>baz : Symbol(baz, Decl(source.js, 5, 19), Decl(source.js, 7, 17), Decl(source.js, 8, 17)) | ||
>normal : Symbol(baz.normal, Decl(source.js, 8, 17)) | ||
|
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.
While working on this, I found a need for the js declaration emitter to automatically add/strip export modifiers from nested namespace members as needed; so the result of this can be seen in some baseline updates like this - since every member of the containing namespace was
export
ed, there was no need to explicitly have theexport
modifiers. Now they get stripped, consistent with our transform-based declaration emitter.