mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Address PR comments
This commit is contained in:
parent
5138e8be8e
commit
42c17e194e
@ -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) {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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))
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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: "" });
|
||||
|
||||
@ -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))
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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: "" });
|
||||
|
||||
@ -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: "" });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user