mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Correct tests and update baselines.
A lot of tests used non-numeric property names for object literals that are contextually typed only by a numeric indexer.
This commit is contained in:
parent
41db405f4c
commit
5138e8be8e
@ -6,16 +6,17 @@ interface I<T> {
|
||||
declare function foo<T>(obj: I<T>): T
|
||||
|
||||
foo({
|
||||
p: "",
|
||||
101: "",
|
||||
0: () => { },
|
||||
["hi" + "bye"]: true,
|
||||
[0 + 1]: 0,
|
||||
[+"hi"]: [0]
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//// [computedPropertyNamesContextualType7_ES5.js]
|
||||
foo((_a = {
|
||||
p: "",
|
||||
101: "",
|
||||
0: function () { }
|
||||
},
|
||||
_a["hi" + "bye"] = true,
|
||||
|
||||
@ -19,11 +19,10 @@ declare function foo<T>(obj: I<T>): T
|
||||
foo({
|
||||
>foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES5.ts, 2, 1))
|
||||
|
||||
p: "",
|
||||
>p : Symbol(p, Decl(computedPropertyNamesContextualType7_ES5.ts, 6, 5))
|
||||
|
||||
101: "",
|
||||
0: () => { },
|
||||
["hi" + "bye"]: true,
|
||||
[0 + 1]: 0,
|
||||
[+"hi"]: [0]
|
||||
});
|
||||
|
||||
|
||||
@ -17,12 +17,11 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[]
|
||||
>foo({ 101: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | number | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; [x: number]: (() => void) | number | number[]; 0: () => void; p: string; }
|
||||
>{ 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; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
101: "",
|
||||
>"" : string
|
||||
|
||||
0: () => { },
|
||||
@ -47,3 +46,4 @@ foo({
|
||||
>0 : number
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -6,16 +6,17 @@ interface I<T> {
|
||||
declare function foo<T>(obj: I<T>): T
|
||||
|
||||
foo({
|
||||
p: "",
|
||||
101: "",
|
||||
0: () => { },
|
||||
["hi" + "bye"]: true,
|
||||
[0 + 1]: 0,
|
||||
[+"hi"]: [0]
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//// [computedPropertyNamesContextualType7_ES6.js]
|
||||
foo({
|
||||
p: "",
|
||||
101: "",
|
||||
0: () => { },
|
||||
["hi" + "bye"]: true,
|
||||
[0 + 1]: 0,
|
||||
|
||||
@ -19,11 +19,10 @@ declare function foo<T>(obj: I<T>): T
|
||||
foo({
|
||||
>foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES6.ts, 2, 1))
|
||||
|
||||
p: "",
|
||||
>p : Symbol(p, Decl(computedPropertyNamesContextualType7_ES6.ts, 6, 5))
|
||||
|
||||
101: "",
|
||||
0: () => { },
|
||||
["hi" + "bye"]: true,
|
||||
[0 + 1]: 0,
|
||||
[+"hi"]: [0]
|
||||
});
|
||||
|
||||
|
||||
@ -17,12 +17,11 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[]
|
||||
>foo({ 101: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | number | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; [x: number]: (() => void) | number | number[]; 0: () => void; p: string; }
|
||||
>{ 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; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
101: "",
|
||||
>"" : string
|
||||
|
||||
0: () => { },
|
||||
@ -47,3 +46,4 @@ foo({
|
||||
>0 : number
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -3,15 +3,13 @@ function foo<T>(items: { [index: number]: T }): T { return undefined; }
|
||||
function bar<T>(items: { [index: string]: T }): T { return undefined; }
|
||||
|
||||
var x1 = foo({ 0: 0, 1: 1 }); // type should be number
|
||||
var x2 = foo({ zero: 0, one: 1 });
|
||||
var x3 = bar({ 0: 0, 1: 1 });
|
||||
var x4 = bar({ zero: 0, one: 1 }); // type should be number
|
||||
var x2 = bar({ 0: 0, 1: 1 });
|
||||
var x3 = bar({ zero: 0, one: 1 }); // type should be number
|
||||
|
||||
|
||||
//// [indexSignaturesInferentialTyping.js]
|
||||
function foo(items) { return undefined; }
|
||||
function bar(items) { return undefined; }
|
||||
var x1 = foo({ 0: 0, 1: 1 }); // type should be number
|
||||
var x2 = foo({ zero: 0, one: 1 });
|
||||
var x3 = bar({ 0: 0, 1: 1 });
|
||||
var x4 = bar({ zero: 0, one: 1 }); // type should be number
|
||||
var x2 = bar({ 0: 0, 1: 1 });
|
||||
var x3 = bar({ zero: 0, one: 1 }); // type should be number
|
||||
|
||||
@ -21,19 +21,13 @@ var x1 = foo({ 0: 0, 1: 1 }); // type should be number
|
||||
>x1 : Symbol(x1, Decl(indexSignaturesInferentialTyping.ts, 3, 3))
|
||||
>foo : Symbol(foo, Decl(indexSignaturesInferentialTyping.ts, 0, 0))
|
||||
|
||||
var x2 = foo({ zero: 0, one: 1 });
|
||||
var x2 = bar({ 0: 0, 1: 1 });
|
||||
>x2 : Symbol(x2, Decl(indexSignaturesInferentialTyping.ts, 4, 3))
|
||||
>foo : Symbol(foo, Decl(indexSignaturesInferentialTyping.ts, 0, 0))
|
||||
>zero : Symbol(zero, Decl(indexSignaturesInferentialTyping.ts, 4, 14))
|
||||
>one : Symbol(one, Decl(indexSignaturesInferentialTyping.ts, 4, 23))
|
||||
>bar : Symbol(bar, Decl(indexSignaturesInferentialTyping.ts, 0, 71))
|
||||
|
||||
var x3 = bar({ 0: 0, 1: 1 });
|
||||
var x3 = bar({ zero: 0, one: 1 }); // type should be number
|
||||
>x3 : Symbol(x3, Decl(indexSignaturesInferentialTyping.ts, 5, 3))
|
||||
>bar : Symbol(bar, Decl(indexSignaturesInferentialTyping.ts, 0, 71))
|
||||
|
||||
var x4 = bar({ zero: 0, one: 1 }); // type should be number
|
||||
>x4 : Symbol(x4, Decl(indexSignaturesInferentialTyping.ts, 6, 3))
|
||||
>bar : Symbol(bar, Decl(indexSignaturesInferentialTyping.ts, 0, 71))
|
||||
>zero : Symbol(zero, Decl(indexSignaturesInferentialTyping.ts, 6, 14))
|
||||
>one : Symbol(one, Decl(indexSignaturesInferentialTyping.ts, 6, 23))
|
||||
>zero : Symbol(zero, Decl(indexSignaturesInferentialTyping.ts, 5, 14))
|
||||
>one : Symbol(one, Decl(indexSignaturesInferentialTyping.ts, 5, 23))
|
||||
|
||||
|
||||
@ -25,26 +25,16 @@ var x1 = foo({ 0: 0, 1: 1 }); // type should be number
|
||||
>0 : number
|
||||
>1 : number
|
||||
|
||||
var x2 = foo({ zero: 0, one: 1 });
|
||||
>x2 : {}
|
||||
>foo({ zero: 0, one: 1 }) : {}
|
||||
>foo : <T>(items: { [index: number]: T; }) => T
|
||||
>{ zero: 0, one: 1 } : { zero: number; one: number; }
|
||||
>zero : number
|
||||
>0 : number
|
||||
>one : number
|
||||
>1 : number
|
||||
|
||||
var x3 = bar({ 0: 0, 1: 1 });
|
||||
>x3 : number
|
||||
var x2 = bar({ 0: 0, 1: 1 });
|
||||
>x2 : number
|
||||
>bar({ 0: 0, 1: 1 }) : number
|
||||
>bar : <T>(items: { [index: string]: T; }) => T
|
||||
>{ 0: 0, 1: 1 } : { 0: number; 1: number; }
|
||||
>0 : number
|
||||
>1 : number
|
||||
|
||||
var x4 = bar({ zero: 0, one: 1 }); // type should be number
|
||||
>x4 : number
|
||||
var x3 = bar({ zero: 0, one: 1 }); // type should be number
|
||||
>x3 : number
|
||||
>bar({ zero: 0, one: 1 }) : number
|
||||
>bar : <T>(items: { [index: string]: T; }) => T
|
||||
>{ zero: 0, one: 1 } : { zero: number; one: number; }
|
||||
|
||||
@ -5,9 +5,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(50,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'.
|
||||
Property '2.0' is incompatible with index signature.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(79,5): error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'.
|
||||
Object literal may only specify known properties, and 'a' does not exist in type '{ [x: number]: string; }'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
@ -106,11 +105,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
|
||||
|
||||
// error
|
||||
var b: { [x: number]: string; } = {
|
||||
~
|
||||
!!! error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'.
|
||||
!!! error TS2322: Property '2.0' is incompatible with index signature.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
a: '',
|
||||
~~~~~
|
||||
!!! error TS2322: Type '{ 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: any; X: string; foo(): string; }' is not assignable to type '{ [x: number]: string; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ [x: number]: string; }'.
|
||||
b: 1,
|
||||
c: () => { },
|
||||
"d": '',
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'.
|
||||
Property '3.0' is incompatible with index signature.
|
||||
Type 'number' is not assignable to type 'A'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(44,5): error TS2322: Type '{ 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'.
|
||||
Object literal may only specify known properties, and '"4.0"' does not exist in type '{ [x: number]: A; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts (4 errors) ====
|
||||
@ -52,13 +51,12 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo
|
||||
|
||||
// error
|
||||
var b: { [x: number]: A } = {
|
||||
~
|
||||
!!! error TS2322: Type '{ 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'.
|
||||
!!! error TS2322: Property '3.0' is incompatible with index signature.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'A'.
|
||||
1.0: new A(),
|
||||
2.0: new B(),
|
||||
"2.5": new B(),
|
||||
3.0: 1,
|
||||
"4.0": ''
|
||||
~~~~~~~~~
|
||||
!!! error TS2322: Type '{ 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and '"4.0"' does not exist in type '{ [x: number]: A; }'.
|
||||
}
|
||||
@ -9,7 +9,8 @@ class B extends A {
|
||||
|
||||
var x: {
|
||||
[idx: number]: A;
|
||||
} = { data: new B() }
|
||||
} = { 0: new B() }
|
||||
|
||||
|
||||
//// [numericIndexerConstraint4.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
@ -29,4 +30,4 @@ var B = (function (_super) {
|
||||
}
|
||||
return B;
|
||||
}(A));
|
||||
var x = { data: new B() };
|
||||
var x = { 0: new B() };
|
||||
|
||||
@ -21,7 +21,6 @@ var x: {
|
||||
>idx : Symbol(idx, Decl(numericIndexerConstraint4.ts, 9, 5))
|
||||
>A : Symbol(A, Decl(numericIndexerConstraint4.ts, 0, 0))
|
||||
|
||||
} = { data: new B() }
|
||||
>data : Symbol(data, Decl(numericIndexerConstraint4.ts, 10, 5))
|
||||
} = { 0: new B() }
|
||||
>B : Symbol(B, Decl(numericIndexerConstraint4.ts, 2, 1))
|
||||
|
||||
|
||||
@ -21,9 +21,8 @@ var x: {
|
||||
>idx : number
|
||||
>A : A
|
||||
|
||||
} = { data: new B() }
|
||||
>{ data: new B() } : { data: B; }
|
||||
>data : B
|
||||
} = { 0: new B() }
|
||||
>{ 0: new B() } : { 0: B; }
|
||||
>new B() : B
|
||||
>B : typeof B
|
||||
|
||||
|
||||
@ -2,11 +2,13 @@ tests/cases/compiler/objectLitIndexerContextualType.ts(12,13): error TS2362: The
|
||||
tests/cases/compiler/objectLitIndexerContextualType.ts(12,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/objectLitIndexerContextualType.ts(15,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/objectLitIndexerContextualType.ts(15,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/objectLitIndexerContextualType.ts(18,5): error TS2322: Type '{ s: (t: any) => number; }' is not assignable to type 'J'.
|
||||
Object literal may only specify known properties, and 's' does not exist in type 'J'.
|
||||
tests/cases/compiler/objectLitIndexerContextualType.ts(21,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/objectLitIndexerContextualType.ts(21,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/objectLitIndexerContextualType.ts (6 errors) ====
|
||||
==== tests/cases/compiler/objectLitIndexerContextualType.ts (7 errors) ====
|
||||
interface I {
|
||||
[s: string]: (s: string) => number;
|
||||
}
|
||||
@ -32,7 +34,10 @@ tests/cases/compiler/objectLitIndexerContextualType.ts(21,17): error TS2363: The
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
};
|
||||
y = {
|
||||
s: t => t * t, // Should not error
|
||||
s: t => t * t, // Should error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ s: (t: any) => number; }' is not assignable to type 'J'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 's' does not exist in type 'J'.
|
||||
};
|
||||
y = {
|
||||
0: t => t * t, // Should error
|
||||
@ -40,4 +45,5 @@ tests/cases/compiler/objectLitIndexerContextualType.ts(21,17): error TS2363: The
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
};
|
||||
};
|
||||
|
||||
@ -16,11 +16,12 @@ x = {
|
||||
0: t => t * t, // Should error
|
||||
};
|
||||
y = {
|
||||
s: t => t * t, // Should not error
|
||||
s: t => t * t, // Should error
|
||||
};
|
||||
y = {
|
||||
0: t => t * t, // Should error
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
//// [objectLitIndexerContextualType.js]
|
||||
var x;
|
||||
|
||||
@ -26,7 +26,7 @@ class PB extends B {
|
||||
var a: {
|
||||
[x: number]: string;
|
||||
}
|
||||
var b: { [x: number]: string; } = { foo: '' };
|
||||
var b: { [x: number]: string; } = { 0: '' };
|
||||
|
||||
function foo1(x: A);
|
||||
function foo1(x: A); // error
|
||||
@ -159,7 +159,7 @@ var PB = (function (_super) {
|
||||
return PB;
|
||||
}(B));
|
||||
var a;
|
||||
var b = { foo: '' };
|
||||
var b = { 0: '' };
|
||||
function foo1(x) { }
|
||||
function foo1b(x) { }
|
||||
function foo1c(x) { }
|
||||
|
||||
@ -47,23 +47,22 @@ var a: {
|
||||
[x: number]: string;
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers1.ts, 25, 5))
|
||||
}
|
||||
var b: { [x: number]: string; } = { foo: '' };
|
||||
var b: { [x: number]: string; } = { 0: '' };
|
||||
>b : Symbol(b, Decl(objectTypesIdentityWithNumericIndexers1.ts, 27, 3))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers1.ts, 27, 10))
|
||||
>foo : Symbol(foo, Decl(objectTypesIdentityWithNumericIndexers1.ts, 27, 35))
|
||||
|
||||
function foo1(x: A);
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers1.ts, 27, 46), Decl(objectTypesIdentityWithNumericIndexers1.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers1.ts, 30, 20))
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers1.ts, 27, 44), Decl(objectTypesIdentityWithNumericIndexers1.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers1.ts, 30, 20))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers1.ts, 29, 14))
|
||||
>A : Symbol(A, Decl(objectTypesIdentityWithNumericIndexers1.ts, 0, 0))
|
||||
|
||||
function foo1(x: A); // error
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers1.ts, 27, 46), Decl(objectTypesIdentityWithNumericIndexers1.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers1.ts, 30, 20))
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers1.ts, 27, 44), Decl(objectTypesIdentityWithNumericIndexers1.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers1.ts, 30, 20))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers1.ts, 30, 14))
|
||||
>A : Symbol(A, Decl(objectTypesIdentityWithNumericIndexers1.ts, 0, 0))
|
||||
|
||||
function foo1(x: any) { }
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers1.ts, 27, 46), Decl(objectTypesIdentityWithNumericIndexers1.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers1.ts, 30, 20))
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers1.ts, 27, 44), Decl(objectTypesIdentityWithNumericIndexers1.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers1.ts, 30, 20))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers1.ts, 31, 14))
|
||||
|
||||
function foo1b(x: B);
|
||||
|
||||
@ -47,11 +47,10 @@ var a: {
|
||||
[x: number]: string;
|
||||
>x : number
|
||||
}
|
||||
var b: { [x: number]: string; } = { foo: '' };
|
||||
var b: { [x: number]: string; } = { 0: '' };
|
||||
>b : { [x: number]: string; }
|
||||
>x : number
|
||||
>{ foo: '' } : { foo: string; }
|
||||
>foo : string
|
||||
>{ 0: '' } : { 0: string; }
|
||||
>'' : string
|
||||
|
||||
function foo1(x: A);
|
||||
|
||||
@ -29,7 +29,7 @@ class PB extends B {
|
||||
var a: {
|
||||
[x: number]: Base;
|
||||
}
|
||||
var b: { [x: number]: Derived; } = { foo: <Derived>null };
|
||||
var b: { [x: number]: Derived; } = { 0: <Derived>null };
|
||||
|
||||
function foo1(x: A);
|
||||
function foo1(x: A); // error
|
||||
@ -174,7 +174,7 @@ var PB = (function (_super) {
|
||||
return PB;
|
||||
}(B));
|
||||
var a;
|
||||
var b = { foo: null };
|
||||
var b = { 0: null };
|
||||
function foo1(x) { }
|
||||
function foo1b(x) { }
|
||||
function foo1c(x) { }
|
||||
|
||||
@ -60,25 +60,24 @@ var a: {
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers2.ts, 28, 5))
|
||||
>Base : Symbol(Base, Decl(objectTypesIdentityWithNumericIndexers2.ts, 0, 0))
|
||||
}
|
||||
var b: { [x: number]: Derived; } = { foo: <Derived>null };
|
||||
var b: { [x: number]: Derived; } = { 0: <Derived>null };
|
||||
>b : Symbol(b, Decl(objectTypesIdentityWithNumericIndexers2.ts, 30, 3))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers2.ts, 30, 10))
|
||||
>Derived : Symbol(Derived, Decl(objectTypesIdentityWithNumericIndexers2.ts, 2, 27))
|
||||
>foo : Symbol(foo, Decl(objectTypesIdentityWithNumericIndexers2.ts, 30, 36))
|
||||
>Derived : Symbol(Derived, Decl(objectTypesIdentityWithNumericIndexers2.ts, 2, 27))
|
||||
|
||||
function foo1(x: A);
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers2.ts, 30, 58), Decl(objectTypesIdentityWithNumericIndexers2.ts, 32, 20), Decl(objectTypesIdentityWithNumericIndexers2.ts, 33, 20))
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers2.ts, 30, 56), Decl(objectTypesIdentityWithNumericIndexers2.ts, 32, 20), Decl(objectTypesIdentityWithNumericIndexers2.ts, 33, 20))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers2.ts, 32, 14))
|
||||
>A : Symbol(A, Decl(objectTypesIdentityWithNumericIndexers2.ts, 3, 43))
|
||||
|
||||
function foo1(x: A); // error
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers2.ts, 30, 58), Decl(objectTypesIdentityWithNumericIndexers2.ts, 32, 20), Decl(objectTypesIdentityWithNumericIndexers2.ts, 33, 20))
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers2.ts, 30, 56), Decl(objectTypesIdentityWithNumericIndexers2.ts, 32, 20), Decl(objectTypesIdentityWithNumericIndexers2.ts, 33, 20))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers2.ts, 33, 14))
|
||||
>A : Symbol(A, Decl(objectTypesIdentityWithNumericIndexers2.ts, 3, 43))
|
||||
|
||||
function foo1(x: any) { }
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers2.ts, 30, 58), Decl(objectTypesIdentityWithNumericIndexers2.ts, 32, 20), Decl(objectTypesIdentityWithNumericIndexers2.ts, 33, 20))
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers2.ts, 30, 56), Decl(objectTypesIdentityWithNumericIndexers2.ts, 32, 20), Decl(objectTypesIdentityWithNumericIndexers2.ts, 33, 20))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers2.ts, 34, 14))
|
||||
|
||||
function foo1b(x: B);
|
||||
|
||||
@ -60,12 +60,11 @@ var a: {
|
||||
>x : number
|
||||
>Base : Base
|
||||
}
|
||||
var b: { [x: number]: Derived; } = { foo: <Derived>null };
|
||||
var b: { [x: number]: Derived; } = { 0: <Derived>null };
|
||||
>b : { [x: number]: Derived; }
|
||||
>x : number
|
||||
>Derived : Derived
|
||||
>{ foo: <Derived>null } : { foo: Derived; }
|
||||
>foo : Derived
|
||||
>{ 0: <Derived>null } : { 0: Derived; }
|
||||
><Derived>null : Derived
|
||||
>Derived : Derived
|
||||
>null : null
|
||||
|
||||
@ -26,7 +26,7 @@ class PB extends B {
|
||||
var a: {
|
||||
[x: string]: string;
|
||||
}
|
||||
var b: { [x: number]: string; } = { foo: '' };
|
||||
var b: { [x: number]: string; } = { 0: '' };
|
||||
|
||||
function foo1(x: A);
|
||||
function foo1(x: A); // error
|
||||
@ -159,7 +159,7 @@ var PB = (function (_super) {
|
||||
return PB;
|
||||
}(B));
|
||||
var a;
|
||||
var b = { foo: '' };
|
||||
var b = { 0: '' };
|
||||
function foo1(x) { }
|
||||
function foo1b(x) { }
|
||||
function foo1c(x) { }
|
||||
|
||||
@ -47,23 +47,22 @@ var a: {
|
||||
[x: string]: string;
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers3.ts, 25, 5))
|
||||
}
|
||||
var b: { [x: number]: string; } = { foo: '' };
|
||||
var b: { [x: number]: string; } = { 0: '' };
|
||||
>b : Symbol(b, Decl(objectTypesIdentityWithNumericIndexers3.ts, 27, 3))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers3.ts, 27, 10))
|
||||
>foo : Symbol(foo, Decl(objectTypesIdentityWithNumericIndexers3.ts, 27, 35))
|
||||
|
||||
function foo1(x: A);
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers3.ts, 27, 46), Decl(objectTypesIdentityWithNumericIndexers3.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers3.ts, 30, 20))
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers3.ts, 27, 44), Decl(objectTypesIdentityWithNumericIndexers3.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers3.ts, 30, 20))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers3.ts, 29, 14))
|
||||
>A : Symbol(A, Decl(objectTypesIdentityWithNumericIndexers3.ts, 0, 0))
|
||||
|
||||
function foo1(x: A); // error
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers3.ts, 27, 46), Decl(objectTypesIdentityWithNumericIndexers3.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers3.ts, 30, 20))
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers3.ts, 27, 44), Decl(objectTypesIdentityWithNumericIndexers3.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers3.ts, 30, 20))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers3.ts, 30, 14))
|
||||
>A : Symbol(A, Decl(objectTypesIdentityWithNumericIndexers3.ts, 0, 0))
|
||||
|
||||
function foo1(x: any) { }
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers3.ts, 27, 46), Decl(objectTypesIdentityWithNumericIndexers3.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers3.ts, 30, 20))
|
||||
>foo1 : Symbol(foo1, Decl(objectTypesIdentityWithNumericIndexers3.ts, 27, 44), Decl(objectTypesIdentityWithNumericIndexers3.ts, 29, 20), Decl(objectTypesIdentityWithNumericIndexers3.ts, 30, 20))
|
||||
>x : Symbol(x, Decl(objectTypesIdentityWithNumericIndexers3.ts, 31, 14))
|
||||
|
||||
function foo1b(x: B);
|
||||
|
||||
@ -47,11 +47,10 @@ var a: {
|
||||
[x: string]: string;
|
||||
>x : string
|
||||
}
|
||||
var b: { [x: number]: string; } = { foo: '' };
|
||||
var b: { [x: number]: string; } = { 0: '' };
|
||||
>b : { [x: number]: string; }
|
||||
>x : number
|
||||
>{ foo: '' } : { foo: string; }
|
||||
>foo : string
|
||||
>{ 0: '' } : { 0: string; }
|
||||
>'' : string
|
||||
|
||||
function foo1(x: A);
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(11,55): error TS2322: Type '{ 3: string; 'three': string; }' is not assignable to type '{ [n: number]: string; }'.
|
||||
Object literal may only specify known properties, and ''three'' does not exist in type '{ [n: number]: string; }'.
|
||||
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(45,14): error TS2339: Property 'qqq' does not exist on type '{ 10: string; x: string; y: number; z: { n: string; m: number; o: () => boolean; }; 'literal property': number; }'.
|
||||
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(80,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(117,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts (4 errors) ====
|
||||
==== tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts (5 errors) ====
|
||||
class A {
|
||||
a: number;
|
||||
}
|
||||
@ -16,6 +18,9 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er
|
||||
}
|
||||
|
||||
var numIndex: { [n: number]: string } = { 3: 'three', 'three': 'three' };
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ 3: string; 'three': string; }' is not assignable to type '{ [n: number]: string; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and ''three'' does not exist in type '{ [n: number]: string; }'.
|
||||
var strIndex: { [n: string]: Compass } = { 'N': Compass.North, 'E': Compass.East };
|
||||
var bothIndex:
|
||||
{
|
||||
|
||||
@ -2,6 +2,5 @@ function foo<T>(items: { [index: number]: T }): T { return undefined; }
|
||||
function bar<T>(items: { [index: string]: T }): T { return undefined; }
|
||||
|
||||
var x1 = foo({ 0: 0, 1: 1 }); // type should be number
|
||||
var x2 = foo({ zero: 0, one: 1 });
|
||||
var x3 = bar({ 0: 0, 1: 1 });
|
||||
var x4 = bar({ zero: 0, one: 1 }); // type should be number
|
||||
var x2 = bar({ 0: 0, 1: 1 });
|
||||
var x3 = bar({ zero: 0, one: 1 }); // type should be number
|
||||
|
||||
@ -8,4 +8,4 @@ class B extends A {
|
||||
|
||||
var x: {
|
||||
[idx: number]: A;
|
||||
} = { data: new B() }
|
||||
} = { 0: new B() }
|
||||
|
||||
@ -15,8 +15,8 @@ x = {
|
||||
0: t => t * t, // Should error
|
||||
};
|
||||
y = {
|
||||
s: t => t * t, // Should not error
|
||||
s: t => t * t, // Should error
|
||||
};
|
||||
y = {
|
||||
0: t => t * t, // Should error
|
||||
};
|
||||
};
|
||||
|
||||
@ -6,9 +6,9 @@ interface I<T> {
|
||||
declare function foo<T>(obj: I<T>): T
|
||||
|
||||
foo({
|
||||
p: "",
|
||||
101: "",
|
||||
0: () => { },
|
||||
["hi" + "bye"]: true,
|
||||
[0 + 1]: 0,
|
||||
[+"hi"]: [0]
|
||||
});
|
||||
});
|
||||
|
||||
@ -6,9 +6,9 @@ interface I<T> {
|
||||
declare function foo<T>(obj: I<T>): T
|
||||
|
||||
foo({
|
||||
p: "",
|
||||
101: "",
|
||||
0: () => { },
|
||||
["hi" + "bye"]: true,
|
||||
[0 + 1]: 0,
|
||||
[+"hi"]: [0]
|
||||
});
|
||||
});
|
||||
|
||||
@ -25,7 +25,7 @@ class PB extends B {
|
||||
var a: {
|
||||
[x: number]: string;
|
||||
}
|
||||
var b: { [x: number]: string; } = { foo: '' };
|
||||
var b: { [x: number]: string; } = { 0: '' };
|
||||
|
||||
function foo1(x: A);
|
||||
function foo1(x: A); // error
|
||||
|
||||
@ -28,7 +28,7 @@ class PB extends B {
|
||||
var a: {
|
||||
[x: number]: Base;
|
||||
}
|
||||
var b: { [x: number]: Derived; } = { foo: <Derived>null };
|
||||
var b: { [x: number]: Derived; } = { 0: <Derived>null };
|
||||
|
||||
function foo1(x: A);
|
||||
function foo1(x: A); // error
|
||||
|
||||
@ -25,7 +25,7 @@ class PB extends B {
|
||||
var a: {
|
||||
[x: string]: string;
|
||||
}
|
||||
var b: { [x: number]: string; } = { foo: '' };
|
||||
var b: { [x: number]: string; } = { 0: '' };
|
||||
|
||||
function foo1(x: A);
|
||||
function foo1(x: A); // error
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user