-
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
Fix visibility checking of mutually recursive exports #19929
Merged
weswigham
merged 5 commits into
microsoft:master
from
weswigham:mutually-recursive-exports
Nov 21, 2017
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
960d114
Do visibility painting from collectLinkedAliases in checker to remove…
weswigham c888ea3
Fix #17085
weswigham 18962c1
Add deeply destructured array to test
weswigham 4c1f9cb
Add test case for #18634
weswigham ea41813
Add PR feedback
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
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
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,77 @@ | ||
//// [tests/cases/compiler/destructuredDeclarationEmit.ts] //// | ||
|
||
//// [foo.ts] | ||
const foo = { bar: 'hello', bat: 'world', bam: { bork: { bar: 'a', baz: 'b' } } }; | ||
const arr: [0, 1, 2, ['a', 'b', 'c', [{def: 'def'}, {sec: 'sec'}]]] = [0, 1, 2, ['a', 'b', 'c', [{def: 'def'}, {sec: 'sec'}]]]; | ||
export { foo, arr }; | ||
//// [index.ts] | ||
import { foo, arr } from './foo'; | ||
export { foo, arr }; | ||
|
||
const { bar: baz, bat, bam: { bork: { bar: ibar, baz: ibaz } } } = foo; | ||
export { baz, ibaz }; | ||
|
||
const [ , one, , [, bee, , [, {sec} ]]] = arr; | ||
export { one, bee, sec }; | ||
|
||
const getFoo = () => ({ | ||
foo: 'foo' | ||
}); | ||
|
||
const { foo: foo2 } = getFoo(); | ||
export { foo2 }; | ||
|
||
|
||
//// [foo.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var foo = { bar: 'hello', bat: 'world', bam: { bork: { bar: 'a', baz: 'b' } } }; | ||
exports.foo = foo; | ||
var arr = [0, 1, 2, ['a', 'b', 'c', [{ def: 'def' }, { sec: 'sec' }]]]; | ||
exports.arr = arr; | ||
//// [index.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var foo_1 = require("./foo"); | ||
exports.foo = foo_1.foo; | ||
exports.arr = foo_1.arr; | ||
var baz = foo_1.foo.bar, bat = foo_1.foo.bat, _a = foo_1.foo.bam.bork, ibar = _a.bar, ibaz = _a.baz; | ||
exports.baz = baz; | ||
exports.ibaz = ibaz; | ||
var one = foo_1.arr[1], _b = foo_1.arr[3], bee = _b[1], _c = _b[3], sec = _c[1].sec; | ||
exports.one = one; | ||
exports.bee = bee; | ||
exports.sec = sec; | ||
var getFoo = function () { return ({ | ||
foo: 'foo' | ||
}); }; | ||
var foo2 = getFoo().foo; | ||
exports.foo2 = foo2; | ||
|
||
|
||
//// [foo.d.ts] | ||
declare const foo: { | ||
bar: string; | ||
bat: string; | ||
bam: { | ||
bork: { | ||
bar: string; | ||
baz: string; | ||
}; | ||
}; | ||
}; | ||
declare const arr: [0, 1, 2, ['a', 'b', 'c', [{ | ||
def: 'def'; | ||
}, { | ||
sec: 'sec'; | ||
}]]]; | ||
export { foo, arr }; | ||
//// [index.d.ts] | ||
import { foo, arr } from './foo'; | ||
export { foo, arr }; | ||
declare const baz: string, ibaz: string; | ||
export { baz, ibaz }; | ||
declare const one: 1, bee: "b", sec: "sec"; | ||
export { one, bee, sec }; | ||
declare const foo2: string; | ||
export { foo2 }; |
73 changes: 73 additions & 0 deletions
73
tests/baselines/reference/destructuredDeclarationEmit.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,73 @@ | ||
=== tests/cases/compiler/foo.ts === | ||
const foo = { bar: 'hello', bat: 'world', bam: { bork: { bar: 'a', baz: 'b' } } }; | ||
>foo : Symbol(foo, Decl(foo.ts, 0, 5)) | ||
>bar : Symbol(bar, Decl(foo.ts, 0, 13)) | ||
>bat : Symbol(bat, Decl(foo.ts, 0, 27)) | ||
>bam : Symbol(bam, Decl(foo.ts, 0, 41)) | ||
>bork : Symbol(bork, Decl(foo.ts, 0, 48)) | ||
>bar : Symbol(bar, Decl(foo.ts, 0, 56)) | ||
>baz : Symbol(baz, Decl(foo.ts, 0, 66)) | ||
|
||
const arr: [0, 1, 2, ['a', 'b', 'c', [{def: 'def'}, {sec: 'sec'}]]] = [0, 1, 2, ['a', 'b', 'c', [{def: 'def'}, {sec: 'sec'}]]]; | ||
>arr : Symbol(arr, Decl(foo.ts, 1, 5)) | ||
>def : Symbol(def, Decl(foo.ts, 1, 39)) | ||
>sec : Symbol(sec, Decl(foo.ts, 1, 53)) | ||
>def : Symbol(def, Decl(foo.ts, 1, 98)) | ||
>sec : Symbol(sec, Decl(foo.ts, 1, 112)) | ||
|
||
export { foo, arr }; | ||
>foo : Symbol(foo, Decl(foo.ts, 2, 8)) | ||
>arr : Symbol(arr, Decl(foo.ts, 2, 13)) | ||
|
||
=== tests/cases/compiler/index.ts === | ||
import { foo, arr } from './foo'; | ||
>foo : Symbol(foo, Decl(index.ts, 0, 8)) | ||
>arr : Symbol(arr, Decl(index.ts, 0, 13)) | ||
|
||
export { foo, arr }; | ||
>foo : Symbol(foo, Decl(index.ts, 1, 8)) | ||
>arr : Symbol(arr, Decl(index.ts, 1, 13)) | ||
|
||
const { bar: baz, bat, bam: { bork: { bar: ibar, baz: ibaz } } } = foo; | ||
>bar : Symbol(bar, Decl(foo.ts, 0, 13)) | ||
>baz : Symbol(baz, Decl(index.ts, 3, 7)) | ||
>bat : Symbol(bat, Decl(index.ts, 3, 17)) | ||
>bam : Symbol(bam, Decl(foo.ts, 0, 41)) | ||
>bork : Symbol(bork, Decl(foo.ts, 0, 48)) | ||
>bar : Symbol(bar, Decl(foo.ts, 0, 56)) | ||
>ibar : Symbol(ibar, Decl(index.ts, 3, 37)) | ||
>baz : Symbol(baz, Decl(foo.ts, 0, 66)) | ||
>ibaz : Symbol(ibaz, Decl(index.ts, 3, 48)) | ||
>foo : Symbol(foo, Decl(index.ts, 0, 8)) | ||
|
||
export { baz, ibaz }; | ||
>baz : Symbol(baz, Decl(index.ts, 4, 8)) | ||
>ibaz : Symbol(ibaz, Decl(index.ts, 4, 13)) | ||
|
||
const [ , one, , [, bee, , [, {sec} ]]] = arr; | ||
>one : Symbol(one, Decl(index.ts, 6, 9)) | ||
>bee : Symbol(bee, Decl(index.ts, 6, 19)) | ||
>sec : Symbol(sec, Decl(index.ts, 6, 31)) | ||
>arr : Symbol(arr, Decl(index.ts, 0, 13)) | ||
|
||
export { one, bee, sec }; | ||
>one : Symbol(one, Decl(index.ts, 7, 8)) | ||
>bee : Symbol(bee, Decl(index.ts, 7, 13)) | ||
>sec : Symbol(sec, Decl(index.ts, 7, 18)) | ||
|
||
const getFoo = () => ({ | ||
>getFoo : Symbol(getFoo, Decl(index.ts, 9, 5)) | ||
|
||
foo: 'foo' | ||
>foo : Symbol(foo, Decl(index.ts, 9, 23)) | ||
|
||
}); | ||
|
||
const { foo: foo2 } = getFoo(); | ||
>foo : Symbol(foo, Decl(index.ts, 9, 23)) | ||
>foo2 : Symbol(foo2, Decl(index.ts, 13, 7)) | ||
>getFoo : Symbol(getFoo, Decl(index.ts, 9, 5)) | ||
|
||
export { foo2 }; | ||
>foo2 : Symbol(foo2, Decl(index.ts, 14, 8)) | ||
|
103 changes: 103 additions & 0 deletions
103
tests/baselines/reference/destructuredDeclarationEmit.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,103 @@ | ||
=== tests/cases/compiler/foo.ts === | ||
const foo = { bar: 'hello', bat: 'world', bam: { bork: { bar: 'a', baz: 'b' } } }; | ||
>foo : { bar: string; bat: string; bam: { bork: { bar: string; baz: string; }; }; } | ||
>{ bar: 'hello', bat: 'world', bam: { bork: { bar: 'a', baz: 'b' } } } : { bar: string; bat: string; bam: { bork: { bar: string; baz: string; }; }; } | ||
>bar : string | ||
>'hello' : "hello" | ||
>bat : string | ||
>'world' : "world" | ||
>bam : { bork: { bar: string; baz: string; }; } | ||
>{ bork: { bar: 'a', baz: 'b' } } : { bork: { bar: string; baz: string; }; } | ||
>bork : { bar: string; baz: string; } | ||
>{ bar: 'a', baz: 'b' } : { bar: string; baz: string; } | ||
>bar : string | ||
>'a' : "a" | ||
>baz : string | ||
>'b' : "b" | ||
|
||
const arr: [0, 1, 2, ['a', 'b', 'c', [{def: 'def'}, {sec: 'sec'}]]] = [0, 1, 2, ['a', 'b', 'c', [{def: 'def'}, {sec: 'sec'}]]]; | ||
>arr : [0, 1, 2, ["a", "b", "c", [{ def: "def"; }, { sec: "sec"; }]]] | ||
>def : "def" | ||
>sec : "sec" | ||
>[0, 1, 2, ['a', 'b', 'c', [{def: 'def'}, {sec: 'sec'}]]] : [0, 1, 2, ["a", "b", "c", [{ def: "def"; }, { sec: "sec"; }]]] | ||
>0 : 0 | ||
>1 : 1 | ||
>2 : 2 | ||
>['a', 'b', 'c', [{def: 'def'}, {sec: 'sec'}]] : ["a", "b", "c", [{ def: "def"; }, { sec: "sec"; }]] | ||
>'a' : "a" | ||
>'b' : "b" | ||
>'c' : "c" | ||
>[{def: 'def'}, {sec: 'sec'}] : [{ def: "def"; }, { sec: "sec"; }] | ||
>{def: 'def'} : { def: "def"; } | ||
>def : string | ||
>'def' : "def" | ||
>{sec: 'sec'} : { sec: "sec"; } | ||
>sec : string | ||
>'sec' : "sec" | ||
|
||
export { foo, arr }; | ||
>foo : { bar: string; bat: string; bam: { bork: { bar: string; baz: string; }; }; } | ||
>arr : [0, 1, 2, ["a", "b", "c", [{ def: "def"; }, { sec: "sec"; }]]] | ||
|
||
=== tests/cases/compiler/index.ts === | ||
import { foo, arr } from './foo'; | ||
>foo : { bar: string; bat: string; bam: { bork: { bar: string; baz: string; }; }; } | ||
>arr : [0, 1, 2, ["a", "b", "c", [{ def: "def"; }, { sec: "sec"; }]]] | ||
|
||
export { foo, arr }; | ||
>foo : { bar: string; bat: string; bam: { bork: { bar: string; baz: string; }; }; } | ||
>arr : [0, 1, 2, ["a", "b", "c", [{ def: "def"; }, { sec: "sec"; }]]] | ||
|
||
const { bar: baz, bat, bam: { bork: { bar: ibar, baz: ibaz } } } = foo; | ||
>bar : any | ||
>baz : string | ||
>bat : string | ||
>bam : any | ||
>bork : any | ||
>bar : any | ||
>ibar : string | ||
>baz : any | ||
>ibaz : string | ||
>foo : { bar: string; bat: string; bam: { bork: { bar: string; baz: string; }; }; } | ||
|
||
export { baz, ibaz }; | ||
>baz : string | ||
>ibaz : string | ||
|
||
const [ , one, , [, bee, , [, {sec} ]]] = arr; | ||
> : undefined | ||
>one : 1 | ||
> : undefined | ||
> : undefined | ||
>bee : "b" | ||
> : undefined | ||
> : undefined | ||
>sec : "sec" | ||
>arr : [0, 1, 2, ["a", "b", "c", [{ def: "def"; }, { sec: "sec"; }]]] | ||
|
||
export { one, bee, sec }; | ||
>one : 1 | ||
>bee : "b" | ||
>sec : "sec" | ||
|
||
const getFoo = () => ({ | ||
>getFoo : () => { foo: string; } | ||
>() => ({ foo: 'foo'}) : () => { foo: string; } | ||
>({ foo: 'foo'}) : { foo: string; } | ||
>{ foo: 'foo'} : { foo: string; } | ||
|
||
foo: 'foo' | ||
>foo : string | ||
>'foo' : "foo" | ||
|
||
}); | ||
|
||
const { foo: foo2 } = getFoo(); | ||
>foo : any | ||
>foo2 : string | ||
>getFoo() : { foo: string; } | ||
>getFoo : () => { foo: string; } | ||
|
||
export { foo2 }; | ||
>foo2 : string | ||
|
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/mutuallyRecursiveInterfaceDeclaration.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,23 @@ | ||
//// [mutuallyRecursiveInterfaceDeclaration.ts] | ||
interface A { | ||
b: B | ||
} | ||
|
||
interface B { | ||
a: A | ||
} | ||
export {A, B} | ||
|
||
//// [mutuallyRecursiveInterfaceDeclaration.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
|
||
|
||
//// [mutuallyRecursiveInterfaceDeclaration.d.ts] | ||
interface A { | ||
b: B; | ||
} | ||
interface B { | ||
a: A; | ||
} | ||
export { A, B }; |
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.
both this comment and the other one seem redundant. And if they're not, then things are actually more complicated than they appear.
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.
They didn't feel redundant before I added the
setVisibility
flag. :(I'll open a PR to remove them.