Add test cases and rename test files
This commit is contained in:
parent
8bd7aae869
commit
03e0722927
35 changed files with 544 additions and 185 deletions
|
@ -1,12 +0,0 @@
|
||||||
//// [objectLiteralShorthandProperties4.ts]
|
|
||||||
var x = {
|
|
||||||
x, // OK
|
|
||||||
undefinedVariable // Error
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//// [objectLiteralShorthandProperties4.js]
|
|
||||||
var x = {
|
|
||||||
x: x,
|
|
||||||
undefinedVariable: undefinedVariable // Error
|
|
||||||
};
|
|
|
@ -3,9 +3,34 @@ var id: number = 10000;
|
||||||
var name: string = "my name";
|
var name: string = "my name";
|
||||||
|
|
||||||
var person: { name: string; id: number } = { name, id };
|
var person: { name: string; id: number } = { name, id };
|
||||||
|
function foo( obj:{ name: string }): void { };
|
||||||
|
function bar(name: string, id: number) { return { name, id }; }
|
||||||
|
function bar1(name: string, id: number) { return { name }; }
|
||||||
|
function baz(name: string, id: number): { name: string; id: number } { return { name, id }; }
|
||||||
|
|
||||||
|
foo(person);
|
||||||
|
var person1 = bar("Hello", 5);
|
||||||
|
var person2: { name: string } = bar("Hello", 5);
|
||||||
|
var person3: { name: string; id:number } = bar("Hello", 5);
|
||||||
|
|
||||||
|
|
||||||
//// [objectLiteralShorthandPropertiesAssignment.js]
|
//// [objectLiteralShorthandPropertiesAssignment.js]
|
||||||
var id = 10000;
|
var id = 10000;
|
||||||
var name = "my name";
|
var name = "my name";
|
||||||
var person = { name: name, id: id };
|
var person = { name: name, id: id };
|
||||||
|
function foo(obj) {
|
||||||
|
}
|
||||||
|
;
|
||||||
|
function bar(name, id) {
|
||||||
|
return { name: name, id: id };
|
||||||
|
}
|
||||||
|
function bar1(name, id) {
|
||||||
|
return { name: name };
|
||||||
|
}
|
||||||
|
function baz(name, id) {
|
||||||
|
return { name: name, id: id };
|
||||||
|
}
|
||||||
|
foo(person);
|
||||||
|
var person1 = bar("Hello", 5);
|
||||||
|
var person2 = bar("Hello", 5);
|
||||||
|
var person3 = bar("Hello", 5);
|
||||||
|
|
|
@ -13,3 +13,56 @@ var person: { name: string; id: number } = { name, id };
|
||||||
>name : string
|
>name : string
|
||||||
>id : number
|
>id : number
|
||||||
|
|
||||||
|
function foo( obj:{ name: string }): void { };
|
||||||
|
>foo : (obj: { name: string; }) => void
|
||||||
|
>obj : { name: string; }
|
||||||
|
>name : string
|
||||||
|
|
||||||
|
function bar(name: string, id: number) { return { name, id }; }
|
||||||
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
>{ name, id } : { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
|
||||||
|
function bar1(name: string, id: number) { return { name }; }
|
||||||
|
>bar1 : (name: string, id: number) => { name: string; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
>{ name } : { name: string; }
|
||||||
|
>name : string
|
||||||
|
|
||||||
|
function baz(name: string, id: number): { name: string; id: number } { return { name, id }; }
|
||||||
|
>baz : (name: string, id: number) => { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
>{ name, id } : { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
|
||||||
|
foo(person);
|
||||||
|
>foo(person) : void
|
||||||
|
>foo : (obj: { name: string; }) => void
|
||||||
|
>person : { name: string; id: number; }
|
||||||
|
|
||||||
|
var person1 = bar("Hello", 5);
|
||||||
|
>person1 : { name: string; id: number; }
|
||||||
|
>bar("Hello", 5) : { name: string; id: number; }
|
||||||
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
||||||
|
|
||||||
|
var person2: { name: string } = bar("Hello", 5);
|
||||||
|
>person2 : { name: string; }
|
||||||
|
>name : string
|
||||||
|
>bar("Hello", 5) : { name: string; id: number; }
|
||||||
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
||||||
|
|
||||||
|
var person3: { name: string; id:number } = bar("Hello", 5);
|
||||||
|
>person3 : { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
>bar("Hello", 5) : { name: string; id: number; }
|
||||||
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
||||||
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment2.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
|
||||||
Property 'b' is missing in type '{ name: string; id: number; }'.
|
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment2.ts (1 errors) ====
|
|
||||||
var id: number = 10000;
|
|
||||||
var name: string = "my name";
|
|
||||||
|
|
||||||
var person: { b: string; id: number } = { name, id }; // error
|
|
||||||
~~~~~~
|
|
||||||
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
|
||||||
!!! error TS2322: Property 'b' is missing in type '{ name: string; id: number; }'.
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
//// [objectLiteralShorthandPropertiesAssignment2.ts]
|
|
||||||
var id: number = 10000;
|
|
||||||
var name: string = "my name";
|
|
||||||
|
|
||||||
var person: { b: string; id: number } = { name, id }; // error
|
|
||||||
|
|
||||||
|
|
||||||
//// [objectLiteralShorthandPropertiesAssignment2.js]
|
|
||||||
var id = 10000;
|
|
||||||
var name = "my name";
|
|
||||||
var person = { name: name, id: id }; // error
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
//// [objectLiteralShorthandPropertiesAssignmentES6.ts]
|
||||||
|
var id: number = 10000;
|
||||||
|
var name: string = "my name";
|
||||||
|
|
||||||
|
var person: { name: string; id: number } = { name, id };
|
||||||
|
function foo(obj: { name: string }): void { };
|
||||||
|
function bar(name: string, id: number) { return { name, id }; }
|
||||||
|
function bar1(name: string, id: number) { return { name }; }
|
||||||
|
function baz(name: string, id: number): { name: string; id: number } { return { name, id }; }
|
||||||
|
|
||||||
|
foo(person);
|
||||||
|
var person1 = bar("Hello", 5);
|
||||||
|
var person2: { name: string } = bar("Hello", 5);
|
||||||
|
var person3: { name: string; id: number } = bar("Hello", 5);
|
||||||
|
|
||||||
|
|
||||||
|
//// [objectLiteralShorthandPropertiesAssignmentES6.js]
|
||||||
|
var id = 10000;
|
||||||
|
var name = "my name";
|
||||||
|
var person = { name, id };
|
||||||
|
function foo(obj) {
|
||||||
|
}
|
||||||
|
;
|
||||||
|
function bar(name, id) {
|
||||||
|
return { name, id };
|
||||||
|
}
|
||||||
|
function bar1(name, id) {
|
||||||
|
return { name };
|
||||||
|
}
|
||||||
|
function baz(name, id) {
|
||||||
|
return { name, id };
|
||||||
|
}
|
||||||
|
foo(person);
|
||||||
|
var person1 = bar("Hello", 5);
|
||||||
|
var person2 = bar("Hello", 5);
|
||||||
|
var person3 = bar("Hello", 5);
|
|
@ -0,0 +1,68 @@
|
||||||
|
=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentES6.ts ===
|
||||||
|
var id: number = 10000;
|
||||||
|
>id : number
|
||||||
|
|
||||||
|
var name: string = "my name";
|
||||||
|
>name : string
|
||||||
|
|
||||||
|
var person: { name: string; id: number } = { name, id };
|
||||||
|
>person : { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
>{ name, id } : { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
|
||||||
|
function foo(obj: { name: string }): void { };
|
||||||
|
>foo : (obj: { name: string; }) => void
|
||||||
|
>obj : { name: string; }
|
||||||
|
>name : string
|
||||||
|
|
||||||
|
function bar(name: string, id: number) { return { name, id }; }
|
||||||
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
>{ name, id } : { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
|
||||||
|
function bar1(name: string, id: number) { return { name }; }
|
||||||
|
>bar1 : (name: string, id: number) => { name: string; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
>{ name } : { name: string; }
|
||||||
|
>name : string
|
||||||
|
|
||||||
|
function baz(name: string, id: number): { name: string; id: number } { return { name, id }; }
|
||||||
|
>baz : (name: string, id: number) => { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
>{ name, id } : { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
|
||||||
|
foo(person);
|
||||||
|
>foo(person) : void
|
||||||
|
>foo : (obj: { name: string; }) => void
|
||||||
|
>person : { name: string; id: number; }
|
||||||
|
|
||||||
|
var person1 = bar("Hello", 5);
|
||||||
|
>person1 : { name: string; id: number; }
|
||||||
|
>bar("Hello", 5) : { name: string; id: number; }
|
||||||
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
||||||
|
|
||||||
|
var person2: { name: string } = bar("Hello", 5);
|
||||||
|
>person2 : { name: string; }
|
||||||
|
>name : string
|
||||||
|
>bar("Hello", 5) : { name: string; id: number; }
|
||||||
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
||||||
|
|
||||||
|
var person3: { name: string; id: number } = bar("Hello", 5);
|
||||||
|
>person3 : { name: string; id: number; }
|
||||||
|
>name : string
|
||||||
|
>id : number
|
||||||
|
>bar("Hello", 5) : { name: string; id: number; }
|
||||||
|
>bar : (name: string, id: number) => { name: string; id: number; }
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,16): error TS1131: Property or signature expected.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,25): error TS1128: Declaration or statement expected.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,53): error TS1005: ';' expected.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
||||||
|
Property 'b' is missing in type '{ name: string; id: number; }'.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'.
|
||||||
|
Types of property 'id' are incompatible.
|
||||||
|
Type 'number' is not assignable to type 'string'.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(8,5): error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'.
|
||||||
|
Types of property 'id' are incompatible.
|
||||||
|
Type 'number' is not assignable to type 'boolean'.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts (7 errors) ====
|
||||||
|
var id: number = 10000;
|
||||||
|
var name: string = "my name";
|
||||||
|
|
||||||
|
var person: { b: string; id: number } = { name, id }; // error
|
||||||
|
~~~~~~
|
||||||
|
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
||||||
|
!!! error TS2322: Property 'b' is missing in type '{ name: string; id: number; }'.
|
||||||
|
var person1: { name, id }; // error: can't use short-hand property assignment in type position
|
||||||
|
~~~~
|
||||||
|
!!! error TS1131: Property or signature expected.
|
||||||
|
~
|
||||||
|
!!! error TS1128: Declaration or statement expected.
|
||||||
|
~~
|
||||||
|
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||||
|
function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error
|
||||||
|
~
|
||||||
|
!!! error TS1005: ';' expected.
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'.
|
||||||
|
!!! error TS2322: Types of property 'id' are incompatible.
|
||||||
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||||
|
function bar(obj: { name: string; id: boolean }) { }
|
||||||
|
bar({ name, id }); // error
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
!!! error TS2345: Argument of type '{ name: string; id: number; }' is not assignable to parameter of type '{ name: string; id: boolean; }'.
|
||||||
|
!!! error TS2345: Types of property 'id' are incompatible.
|
||||||
|
!!! error TS2345: Type 'number' is not assignable to type 'boolean'.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,55): error TS1005: ';' expected.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(6,55): error TS1005: ';' expected.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,16): error TS1131: Property or signature expected.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,25): error TS1128: Declaration or statement expected.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(8,28): error TS1005: ';' expected.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
||||||
|
Property 'b' is missing in type '{ name: string; id: number; }'.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'.
|
||||||
|
Types of property 'name' are incompatible.
|
||||||
|
Type 'string' is not assignable to type 'number'.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||||
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(8,5): error TS2322: Type '{ name: number; id: string; }' is not assignable to type '{ name: string; id: number; }'.
|
||||||
|
Types of property 'name' are incompatible.
|
||||||
|
Type 'number' is not assignable to type 'string'.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts (9 errors) ====
|
||||||
|
var id: number = 10000;
|
||||||
|
var name: string = "my name";
|
||||||
|
|
||||||
|
var person: { b: string; id: number } = { name, id }; // error
|
||||||
|
~~~~~~
|
||||||
|
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
||||||
|
!!! error TS2322: Property 'b' is missing in type '{ name: string; id: number; }'.
|
||||||
|
function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error
|
||||||
|
~
|
||||||
|
!!! error TS1005: ';' expected.
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'.
|
||||||
|
!!! error TS2322: Types of property 'name' are incompatible.
|
||||||
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||||
|
function foo(name: string, id: number): { name: string, id: number } { return { name, id }; } // error
|
||||||
|
~
|
||||||
|
!!! error TS1005: ';' expected.
|
||||||
|
var person1: { name, id }; // error : Can't use shorthand in the type position
|
||||||
|
~~~~
|
||||||
|
!!! error TS1131: Property or signature expected.
|
||||||
|
~
|
||||||
|
!!! error TS1128: Declaration or statement expected.
|
||||||
|
~~
|
||||||
|
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||||
|
var person2: { name: string, id: number } = bar("hello", 5);
|
||||||
|
~
|
||||||
|
!!! error TS1005: ';' expected.
|
||||||
|
~~~~~~~
|
||||||
|
!!! error TS2322: Type '{ name: number; id: string; }' is not assignable to type '{ name: string; id: number; }'.
|
||||||
|
!!! error TS2322: Types of property 'name' are incompatible.
|
||||||
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
@ -0,0 +1,39 @@
|
||||||
|
//// [objectLiteralShorthandPropertiesES6.ts]
|
||||||
|
var a, b, c;
|
||||||
|
|
||||||
|
var x1 = {
|
||||||
|
a
|
||||||
|
};
|
||||||
|
|
||||||
|
var x2 = {
|
||||||
|
a,
|
||||||
|
}
|
||||||
|
|
||||||
|
var x3 = {
|
||||||
|
a: 0,
|
||||||
|
b,
|
||||||
|
c,
|
||||||
|
d() { },
|
||||||
|
x3,
|
||||||
|
parent: x3
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//// [objectLiteralShorthandPropertiesES6.js]
|
||||||
|
var a, b, c;
|
||||||
|
var x1 = {
|
||||||
|
a
|
||||||
|
};
|
||||||
|
var x2 = {
|
||||||
|
a,
|
||||||
|
};
|
||||||
|
var x3 = {
|
||||||
|
a: 0,
|
||||||
|
b,
|
||||||
|
c,
|
||||||
|
d: function () {
|
||||||
|
},
|
||||||
|
x3,
|
||||||
|
parent: x3
|
||||||
|
};
|
|
@ -1,4 +1,4 @@
|
||||||
=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesTargetES6.ts ===
|
=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesES6.ts ===
|
||||||
var a, b, c;
|
var a, b, c;
|
||||||
>a : any
|
>a : any
|
||||||
>b : any
|
>b : any
|
||||||
|
@ -47,31 +47,4 @@ var x3 = {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module m {
|
|
||||||
>m : typeof m
|
|
||||||
|
|
||||||
export var x;
|
|
||||||
>x : any
|
|
||||||
}
|
|
||||||
|
|
||||||
module m {
|
|
||||||
>m : typeof m
|
|
||||||
|
|
||||||
var z = x;
|
|
||||||
>z : any
|
|
||||||
>x : any
|
|
||||||
|
|
||||||
var y = {
|
|
||||||
>y : { a: any; x: any; }
|
|
||||||
>{ a: x, x } : { a: any; x: any; }
|
|
||||||
|
|
||||||
a: x,
|
|
||||||
>a : any
|
|
||||||
>x : any
|
|
||||||
|
|
||||||
x
|
|
||||||
>x : any
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties4.ts(3,5): error TS2304: Cannot find name 'undefinedVariable'.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.ts(3,5): error TS2304: Cannot find name 'undefinedVariable'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties4.ts (1 errors) ====
|
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.ts (1 errors) ====
|
||||||
var x = {
|
var x = {
|
||||||
x, // OK
|
x, // OK
|
||||||
undefinedVariable // Error
|
undefinedVariable // Error
|
|
@ -0,0 +1,12 @@
|
||||||
|
//// [objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.ts]
|
||||||
|
var x = {
|
||||||
|
x, // OK
|
||||||
|
undefinedVariable // Error
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//// [objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.js]
|
||||||
|
var x = {
|
||||||
|
x: x,
|
||||||
|
undefinedVariable: undefinedVariable // Error
|
||||||
|
};
|
|
@ -1,23 +1,23 @@
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(3,20): error TS1005: ':' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(3,20): error TS1005: ':' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(4,7): error TS1005: ':' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(4,7): error TS1005: ':' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(5,10): error TS1005: '(' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(5,10): error TS1005: '(' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(6,10): error TS1005: '(' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(6,10): error TS1005: '(' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(7,9): error TS1005: ':' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(7,9): error TS1005: ':' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(8,10): error TS1005: ':' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(8,10): error TS1005: ':' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(9,8): error TS1005: ':' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(9,8): error TS1005: ':' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(10,10): error TS1005: ':' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(10,10): error TS1005: ':' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(12,1): error TS1005: ':' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(12,1): error TS1005: ':' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(15,6): error TS1005: ',' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,6): error TS1005: ',' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(16,6): error TS1005: ',' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,6): error TS1005: ',' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(17,6): error TS1005: '=' expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(17,6): error TS1005: '=' expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(18,1): error TS1128: Declaration or statement expected.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(18,1): error TS1128: Declaration or statement expected.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(15,5): error TS2300: Duplicate identifier 'a'.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,5): error TS2300: Duplicate identifier 'a'.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(15,7): error TS2304: Cannot find name 'b'.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,7): error TS2304: Cannot find name 'b'.
|
||||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(16,5): error TS2300: Duplicate identifier 'a'.
|
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,5): error TS2300: Duplicate identifier 'a'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts (17 errors) ====
|
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts (17 errors) ====
|
||||||
// errors
|
// errors
|
||||||
var y = {
|
var y = {
|
||||||
"stringLiteral",
|
"stringLiteral",
|
|
@ -1,62 +0,0 @@
|
||||||
//// [objectLiteralShorthandPropertiesTargetES6.ts]
|
|
||||||
var a, b, c;
|
|
||||||
|
|
||||||
var x1 = {
|
|
||||||
a
|
|
||||||
};
|
|
||||||
|
|
||||||
var x2 = {
|
|
||||||
a,
|
|
||||||
}
|
|
||||||
|
|
||||||
var x3 = {
|
|
||||||
a: 0,
|
|
||||||
b,
|
|
||||||
c,
|
|
||||||
d() { },
|
|
||||||
x3,
|
|
||||||
parent: x3
|
|
||||||
};
|
|
||||||
|
|
||||||
module m {
|
|
||||||
export var x;
|
|
||||||
}
|
|
||||||
|
|
||||||
module m {
|
|
||||||
var z = x;
|
|
||||||
var y = {
|
|
||||||
a: x,
|
|
||||||
x
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//// [objectLiteralShorthandPropertiesTargetES6.js]
|
|
||||||
var a, b, c;
|
|
||||||
var x1 = {
|
|
||||||
a
|
|
||||||
};
|
|
||||||
var x2 = {
|
|
||||||
a,
|
|
||||||
};
|
|
||||||
var x3 = {
|
|
||||||
a: 0,
|
|
||||||
b,
|
|
||||||
c,
|
|
||||||
d: function () {
|
|
||||||
},
|
|
||||||
x3,
|
|
||||||
parent: x3
|
|
||||||
};
|
|
||||||
var m;
|
|
||||||
(function (m) {
|
|
||||||
m.x;
|
|
||||||
})(m || (m = {}));
|
|
||||||
var m;
|
|
||||||
(function (m) {
|
|
||||||
var z = m.x;
|
|
||||||
var y = {
|
|
||||||
a: m.x,
|
|
||||||
x: m.x
|
|
||||||
};
|
|
||||||
})(m || (m = {}));
|
|
|
@ -1,4 +1,4 @@
|
||||||
//// [objectLiteralShorthandProperties3.ts]
|
//// [objectLiteralShorthandPropertiesWithModule.ts]
|
||||||
// module export
|
// module export
|
||||||
|
|
||||||
module m {
|
module m {
|
||||||
|
@ -14,7 +14,7 @@ module m {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//// [objectLiteralShorthandProperties3.js]
|
//// [objectLiteralShorthandPropertiesWithModule.js]
|
||||||
// module export
|
// module export
|
||||||
var m;
|
var m;
|
||||||
(function (m) {
|
(function (m) {
|
|
@ -1,4 +1,4 @@
|
||||||
=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties3.ts ===
|
=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesWithModule.ts ===
|
||||||
// module export
|
// module export
|
||||||
|
|
||||||
module m {
|
module m {
|
|
@ -0,0 +1,28 @@
|
||||||
|
//// [objectLiteralShorthandPropertiesWithModuleES6.ts]
|
||||||
|
|
||||||
|
module m {
|
||||||
|
export var x;
|
||||||
|
}
|
||||||
|
|
||||||
|
module m {
|
||||||
|
var z = x;
|
||||||
|
var y = {
|
||||||
|
a: x,
|
||||||
|
x
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//// [objectLiteralShorthandPropertiesWithModuleES6.js]
|
||||||
|
var m;
|
||||||
|
(function (m) {
|
||||||
|
m.x;
|
||||||
|
})(m || (m = {}));
|
||||||
|
var m;
|
||||||
|
(function (m) {
|
||||||
|
var z = m.x;
|
||||||
|
var y = {
|
||||||
|
a: m.x,
|
||||||
|
x: m.x
|
||||||
|
};
|
||||||
|
})(m || (m = {}));
|
|
@ -0,0 +1,30 @@
|
||||||
|
=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesWithModuleES6.ts ===
|
||||||
|
|
||||||
|
module m {
|
||||||
|
>m : typeof m
|
||||||
|
|
||||||
|
export var x;
|
||||||
|
>x : any
|
||||||
|
}
|
||||||
|
|
||||||
|
module m {
|
||||||
|
>m : typeof m
|
||||||
|
|
||||||
|
var z = x;
|
||||||
|
>z : any
|
||||||
|
>x : any
|
||||||
|
|
||||||
|
var y = {
|
||||||
|
>y : { a: any; x: any; }
|
||||||
|
>{ a: x, x } : { a: any; x: any; }
|
||||||
|
|
||||||
|
a: x,
|
||||||
|
>a : any
|
||||||
|
>x : any
|
||||||
|
|
||||||
|
x
|
||||||
|
>x : any
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -2,3 +2,12 @@
|
||||||
var name: string = "my name";
|
var name: string = "my name";
|
||||||
|
|
||||||
var person: { name: string; id: number } = { name, id };
|
var person: { name: string; id: number } = { name, id };
|
||||||
|
function foo( obj:{ name: string }): void { };
|
||||||
|
function bar(name: string, id: number) { return { name, id }; }
|
||||||
|
function bar1(name: string, id: number) { return { name }; }
|
||||||
|
function baz(name: string, id: number): { name: string; id: number } { return { name, id }; }
|
||||||
|
|
||||||
|
foo(person);
|
||||||
|
var person1 = bar("Hello", 5);
|
||||||
|
var person2: { name: string } = bar("Hello", 5);
|
||||||
|
var person3: { name: string; id:number } = bar("Hello", 5);
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
var id: number = 10000;
|
|
||||||
var name: string = "my name";
|
|
||||||
|
|
||||||
var person: { b: string; id: number } = { name, id }; // error
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
// @target: es6
|
||||||
|
var id: number = 10000;
|
||||||
|
var name: string = "my name";
|
||||||
|
|
||||||
|
var person: { name: string; id: number } = { name, id };
|
||||||
|
function foo(obj: { name: string }): void { };
|
||||||
|
function bar(name: string, id: number) { return { name, id }; }
|
||||||
|
function bar1(name: string, id: number) { return { name }; }
|
||||||
|
function baz(name: string, id: number): { name: string; id: number } { return { name, id }; }
|
||||||
|
|
||||||
|
foo(person);
|
||||||
|
var person1 = bar("Hello", 5);
|
||||||
|
var person2: { name: string } = bar("Hello", 5);
|
||||||
|
var person3: { name: string; id: number } = bar("Hello", 5);
|
|
@ -0,0 +1,9 @@
|
||||||
|
var id: number = 10000;
|
||||||
|
var name: string = "my name";
|
||||||
|
|
||||||
|
var person: { b: string; id: number } = { name, id }; // error
|
||||||
|
var person1: { name, id }; // error: can't use short-hand property assignment in type position
|
||||||
|
function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error
|
||||||
|
function bar(obj: { name: string; id: boolean }) { }
|
||||||
|
bar({ name, id }); // error
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
var id: number = 10000;
|
||||||
|
var name: string = "my name";
|
||||||
|
|
||||||
|
var person: { b: string; id: number } = { name, id }; // error
|
||||||
|
function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error
|
||||||
|
function foo(name: string, id: number): { name: string, id: number } { return { name, id }; } // error
|
||||||
|
var person1: { name, id }; // error : Can't use shorthand in the type position
|
||||||
|
var person2: { name: string, id: number } = bar("hello", 5);
|
|
@ -0,0 +1,20 @@
|
||||||
|
// @target: es6
|
||||||
|
var a, b, c;
|
||||||
|
|
||||||
|
var x1 = {
|
||||||
|
a
|
||||||
|
};
|
||||||
|
|
||||||
|
var x2 = {
|
||||||
|
a,
|
||||||
|
}
|
||||||
|
|
||||||
|
var x3 = {
|
||||||
|
a: 0,
|
||||||
|
b,
|
||||||
|
c,
|
||||||
|
d() { },
|
||||||
|
x3,
|
||||||
|
parent: x3
|
||||||
|
};
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
// @target: es6
|
|
||||||
var a, b, c;
|
|
||||||
|
|
||||||
var x1 = {
|
|
||||||
a
|
|
||||||
};
|
|
||||||
|
|
||||||
var x2 = {
|
|
||||||
a,
|
|
||||||
}
|
|
||||||
|
|
||||||
var x3 = {
|
|
||||||
a: 0,
|
|
||||||
b,
|
|
||||||
c,
|
|
||||||
d() { },
|
|
||||||
x3,
|
|
||||||
parent: x3
|
|
||||||
};
|
|
||||||
|
|
||||||
module m {
|
|
||||||
export var x;
|
|
||||||
}
|
|
||||||
|
|
||||||
module m {
|
|
||||||
var z = x;
|
|
||||||
var y = {
|
|
||||||
a: x,
|
|
||||||
x
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
// module export
|
||||||
|
var x = "Foo";
|
||||||
|
module m {
|
||||||
|
export var x;
|
||||||
|
}
|
||||||
|
|
||||||
|
module m {
|
||||||
|
var z = 10000;
|
||||||
|
export var y = {
|
||||||
|
x
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
m.y.x;
|
|
@ -1,4 +1,4 @@
|
||||||
// module export
|
// @target: es6
|
||||||
|
|
||||||
module m {
|
module m {
|
||||||
export var x;
|
export var x;
|
|
@ -0,0 +1,6 @@
|
||||||
|
///<reference path="fourslash.ts" />
|
||||||
|
|
||||||
|
//// var person: {name:string; id:number} = {n/**/
|
||||||
|
|
||||||
|
goTo.marker();
|
||||||
|
verify.completionListContains("name", /*text*/ undefined, /*documentation*/ undefined, "property");
|
|
@ -0,0 +1,7 @@
|
||||||
|
/// <reference path="fourslash.ts" />
|
||||||
|
|
||||||
|
//// var person: {name:string; id: number} = { n/**/
|
||||||
|
|
||||||
|
goTo.marker();
|
||||||
|
verify.memberListContains('name');
|
||||||
|
verify.memberListContains('id');
|
|
@ -0,0 +1,7 @@
|
||||||
|
/// <reference path="fourslash.ts" />
|
||||||
|
|
||||||
|
//// var person: {name:string; id: number} = { n/**/
|
||||||
|
|
||||||
|
goTo.marker();
|
||||||
|
verify.memberListContains('name');
|
||||||
|
verify.memberListContains('id');
|
|
@ -0,0 +1,19 @@
|
||||||
|
/// <reference path='fourslash.ts'/>
|
||||||
|
|
||||||
|
//// var /*1*/name = "Foo";
|
||||||
|
////
|
||||||
|
//// var obj = { /*2*/name };
|
||||||
|
//// var obj1 = { /*3*/name:name };
|
||||||
|
//// obj./*4*/name;
|
||||||
|
|
||||||
|
goTo.marker('1');
|
||||||
|
verify.referencesCountIs(3);
|
||||||
|
|
||||||
|
goTo.marker('2');
|
||||||
|
verify.referencesCountIs(4);
|
||||||
|
|
||||||
|
goTo.marker('3');
|
||||||
|
verify.referencesCountIs(1);
|
||||||
|
|
||||||
|
goTo.marker('4');
|
||||||
|
verify.referencesCountIs(2);
|
|
@ -0,0 +1,23 @@
|
||||||
|
/// <reference path='fourslash.ts'/>
|
||||||
|
|
||||||
|
//// var /*1*/dx = "Foo";
|
||||||
|
////
|
||||||
|
//// module M { export var /*2*/dx; }
|
||||||
|
//// module M {
|
||||||
|
//// var z = 100;
|
||||||
|
//// export var y = { /*3*/dx, z };
|
||||||
|
//// }
|
||||||
|
//// M.y./*4*/dx;
|
||||||
|
|
||||||
|
goTo.marker('1');
|
||||||
|
debugger;
|
||||||
|
verify.referencesCountIs(1);
|
||||||
|
|
||||||
|
goTo.marker('2');
|
||||||
|
verify.referencesCountIs(2);
|
||||||
|
|
||||||
|
goTo.marker('3');
|
||||||
|
verify.referencesCountIs(3);
|
||||||
|
|
||||||
|
goTo.marker('4');
|
||||||
|
verify.referencesCountIs(2);
|
Loading…
Reference in a new issue