Address PR comments

This commit is contained in:
Nathan Shively-Sanders 2016-05-25 17:03:33 -07:00
parent 5138e8be8e
commit 42c17e194e
9 changed files with 151 additions and 55 deletions

View File

@ -6036,12 +6036,10 @@ namespace ts {
const resolved = resolveStructuredTypeMembers(type);
if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) ||
resolved.stringIndexInfo ||
(resolved.numberIndexInfo && isNumericLiteralName(name)) ||
getPropertyOfType(type, name)) {
return true;
}
if (resolved.numberIndexInfo) {
return isNumericLiteralName(name);
}
}
else if (type.flags & TypeFlags.UnionOrIntersection) {
for (const t of (<UnionOrIntersectionType>type).types) {

View File

@ -1,22 +1,26 @@
//// [computedPropertyNamesContextualType7_ES5.ts]
interface I<T> {
[s: number]: T;
[n: number]: T;
}
interface J<T> {
[s: string]: T;
}
declare function foo<T>(obj: I<T>): T
declare function foo<T>(obj: I<T>): T;
declare function g<T>(obj: J<T>): T;
foo({
101: "",
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
});
g({ p: "" });
//// [computedPropertyNamesContextualType7_ES5.js]
foo((_a = {
101: "",
0: function () { }
},
_a["hi" + "bye"] = true,
@ -24,4 +28,5 @@ foo((_a = {
_a[+"hi"] = [0],
_a
));
g({ p: "" });
var _a;

View File

@ -3,26 +3,45 @@ interface I<T> {
>I : Symbol(I, Decl(computedPropertyNamesContextualType7_ES5.ts, 0, 0))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 0, 12))
[s: number]: T;
>s : Symbol(s, Decl(computedPropertyNamesContextualType7_ES5.ts, 1, 5))
[n: number]: T;
>n : Symbol(n, Decl(computedPropertyNamesContextualType7_ES5.ts, 1, 5))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 0, 12))
}
interface J<T> {
>J : Symbol(J, Decl(computedPropertyNamesContextualType7_ES5.ts, 2, 1))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 3, 12))
declare function foo<T>(obj: I<T>): T
>foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES5.ts, 2, 1))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 4, 21))
>obj : Symbol(obj, Decl(computedPropertyNamesContextualType7_ES5.ts, 4, 24))
[s: string]: T;
>s : Symbol(s, Decl(computedPropertyNamesContextualType7_ES5.ts, 4, 5))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 3, 12))
}
declare function foo<T>(obj: I<T>): T;
>foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES5.ts, 5, 1))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 7, 21))
>obj : Symbol(obj, Decl(computedPropertyNamesContextualType7_ES5.ts, 7, 24))
>I : Symbol(I, Decl(computedPropertyNamesContextualType7_ES5.ts, 0, 0))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 4, 21))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 4, 21))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 7, 21))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 7, 21))
declare function g<T>(obj: J<T>): T;
>g : Symbol(g, Decl(computedPropertyNamesContextualType7_ES5.ts, 7, 38))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 8, 19))
>obj : Symbol(obj, Decl(computedPropertyNamesContextualType7_ES5.ts, 8, 22))
>J : Symbol(J, Decl(computedPropertyNamesContextualType7_ES5.ts, 2, 1))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 8, 19))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES5.ts, 8, 19))
foo({
>foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES5.ts, 2, 1))
>foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES5.ts, 5, 1))
101: "",
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
});
g({ p: "" });
>g : Symbol(g, Decl(computedPropertyNamesContextualType7_ES5.ts, 7, 38))
>p : Symbol(p, Decl(computedPropertyNamesContextualType7_ES5.ts, 17, 3))

View File

@ -3,12 +3,20 @@ interface I<T> {
>I : I<T>
>T : T
[s: number]: T;
>s : number
[n: number]: T;
>n : number
>T : T
}
interface J<T> {
>J : J<T>
>T : T
[s: string]: T;
>s : string
>T : T
}
declare function foo<T>(obj: I<T>): T
declare function foo<T>(obj: I<T>): T;
>foo : <T>(obj: I<T>) => T
>T : T
>obj : I<T>
@ -16,13 +24,18 @@ declare function foo<T>(obj: I<T>): T
>T : T
>T : T
foo({
>foo({ 101: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | number | number[]
>foo : <T>(obj: I<T>) => T
>{ 101: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; [x: number]: string | (() => void) | number | number[]; 0: () => void; 101: string; }
declare function g<T>(obj: J<T>): T;
>g : <T>(obj: J<T>) => T
>T : T
>obj : J<T>
>J : J<T>
>T : T
>T : T
101: "",
>"" : string
foo({
>foo({ 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[]
>foo : <T>(obj: I<T>) => T
>{ 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: (() => void) | boolean | number | number[]; [x: number]: (() => void) | number | number[]; 0: () => void; }
0: () => { },
>() => { } : () => void
@ -47,3 +60,10 @@ foo({
});
g({ p: "" });
>g({ p: "" }) : string
>g : <T>(obj: J<T>) => T
>{ p: "" } : { p: string; }
>p : string
>"" : string

View File

@ -1,24 +1,29 @@
//// [computedPropertyNamesContextualType7_ES6.ts]
interface I<T> {
[s: number]: T;
[n: number]: T;
}
interface J<T> {
[s: string]: T;
}
declare function foo<T>(obj: I<T>): T
declare function foo<T>(obj: I<T>): T;
declare function g<T>(obj: J<T>): T;
foo({
101: "",
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
});
g({ p: "" });
//// [computedPropertyNamesContextualType7_ES6.js]
foo({
101: "",
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
});
g({ p: "" });

View File

@ -3,26 +3,45 @@ interface I<T> {
>I : Symbol(I, Decl(computedPropertyNamesContextualType7_ES6.ts, 0, 0))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 0, 12))
[s: number]: T;
>s : Symbol(s, Decl(computedPropertyNamesContextualType7_ES6.ts, 1, 5))
[n: number]: T;
>n : Symbol(n, Decl(computedPropertyNamesContextualType7_ES6.ts, 1, 5))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 0, 12))
}
interface J<T> {
>J : Symbol(J, Decl(computedPropertyNamesContextualType7_ES6.ts, 2, 1))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 3, 12))
declare function foo<T>(obj: I<T>): T
>foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES6.ts, 2, 1))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 4, 21))
>obj : Symbol(obj, Decl(computedPropertyNamesContextualType7_ES6.ts, 4, 24))
[s: string]: T;
>s : Symbol(s, Decl(computedPropertyNamesContextualType7_ES6.ts, 4, 5))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 3, 12))
}
declare function foo<T>(obj: I<T>): T;
>foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES6.ts, 5, 1))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 7, 21))
>obj : Symbol(obj, Decl(computedPropertyNamesContextualType7_ES6.ts, 7, 24))
>I : Symbol(I, Decl(computedPropertyNamesContextualType7_ES6.ts, 0, 0))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 4, 21))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 4, 21))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 7, 21))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 7, 21))
declare function g<T>(obj: J<T>): T;
>g : Symbol(g, Decl(computedPropertyNamesContextualType7_ES6.ts, 7, 38))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 8, 19))
>obj : Symbol(obj, Decl(computedPropertyNamesContextualType7_ES6.ts, 8, 22))
>J : Symbol(J, Decl(computedPropertyNamesContextualType7_ES6.ts, 2, 1))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 8, 19))
>T : Symbol(T, Decl(computedPropertyNamesContextualType7_ES6.ts, 8, 19))
foo({
>foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES6.ts, 2, 1))
>foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES6.ts, 5, 1))
101: "",
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
});
g({ p: "" });
>g : Symbol(g, Decl(computedPropertyNamesContextualType7_ES6.ts, 7, 38))
>p : Symbol(p, Decl(computedPropertyNamesContextualType7_ES6.ts, 17, 3))

View File

@ -3,12 +3,20 @@ interface I<T> {
>I : I<T>
>T : T
[s: number]: T;
>s : number
[n: number]: T;
>n : number
>T : T
}
interface J<T> {
>J : J<T>
>T : T
[s: string]: T;
>s : string
>T : T
}
declare function foo<T>(obj: I<T>): T
declare function foo<T>(obj: I<T>): T;
>foo : <T>(obj: I<T>) => T
>T : T
>obj : I<T>
@ -16,13 +24,18 @@ declare function foo<T>(obj: I<T>): T
>T : T
>T : T
foo({
>foo({ 101: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | number | number[]
>foo : <T>(obj: I<T>) => T
>{ 101: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; [x: number]: string | (() => void) | number | number[]; 0: () => void; 101: string; }
declare function g<T>(obj: J<T>): T;
>g : <T>(obj: J<T>) => T
>T : T
>obj : J<T>
>J : J<T>
>T : T
>T : T
101: "",
>"" : string
foo({
>foo({ 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[]
>foo : <T>(obj: I<T>) => T
>{ 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: (() => void) | boolean | number | number[]; [x: number]: (() => void) | number | number[]; 0: () => void; }
0: () => { },
>() => { } : () => void
@ -47,3 +60,10 @@ foo({
});
g({ p: "" });
>g({ p: "" }) : string
>g : <T>(obj: J<T>) => T
>{ p: "" } : { p: string; }
>p : string
>"" : string

View File

@ -1,14 +1,19 @@
// @target: es5
interface I<T> {
[s: number]: T;
[n: number]: T;
}
interface J<T> {
[s: string]: T;
}
declare function foo<T>(obj: I<T>): T
declare function foo<T>(obj: I<T>): T;
declare function g<T>(obj: J<T>): T;
foo({
101: "",
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
});
g({ p: "" });

View File

@ -1,14 +1,19 @@
// @target: es6
interface I<T> {
[s: number]: T;
[n: number]: T;
}
interface J<T> {
[s: string]: T;
}
declare function foo<T>(obj: I<T>): T
declare function foo<T>(obj: I<T>): T;
declare function g<T>(obj: J<T>): T;
foo({
101: "",
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
});
g({ p: "" });