From 03e0722927b1f7597080a8fade2e1a29d5220a2c Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 14 Nov 2014 15:44:06 -0800 Subject: [PATCH] Add test cases and rename test files --- .../objectLiteralShorthandProperties4.js | 12 ---- ...ectLiteralShorthandPropertiesAssignment.js | 25 +++++++ ...LiteralShorthandPropertiesAssignment.types | 53 +++++++++++++++ ...lShorthandPropertiesAssignment2.errors.txt | 13 ---- ...ctLiteralShorthandPropertiesAssignment2.js | 11 --- ...LiteralShorthandPropertiesAssignmentES6.js | 36 ++++++++++ ...eralShorthandPropertiesAssignmentES6.types | 68 +++++++++++++++++++ ...rthandPropertiesAssignmentError.errors.txt | 44 ++++++++++++ ...nmentErrorFromMissingIdentifier.errors.txt | 48 +++++++++++++ .../objectLiteralShorthandPropertiesES6.js | 39 +++++++++++ ...objectLiteralShorthandPropertiesES6.types} | 29 +------- ...rrorFromNoneExistingIdentifier.errors.txt} | 4 +- ...opertiesErrorFromNoneExistingIdentifier.js | 12 ++++ ...iesErrorFromNotUsingIdentifier.errors.txt} | 36 +++++----- ...jectLiteralShorthandPropertiesTargetES6.js | 62 ----------------- ...ctLiteralShorthandPropertiesWithModule.js} | 4 +- ...iteralShorthandPropertiesWithModule.types} | 2 +- ...LiteralShorthandPropertiesWithModuleES6.js | 28 ++++++++ ...eralShorthandPropertiesWithModuleES6.types | 30 ++++++++ ...ectLiteralShorthandPropertiesAssignment.ts | 9 +++ ...ctLiteralShorthandPropertiesAssignment2.ts | 4 -- ...LiteralShorthandPropertiesAssignmentES6.ts | 14 ++++ ...teralShorthandPropertiesAssignmentError.ts | 9 +++ ...iesAssignmentErrorFromMissingIdentifier.ts | 8 +++ .../objectLiteralShorthandPropertiesES6.ts | 20 ++++++ ...pertiesErrorFromNoneExistingIdentifier.ts} | 0 ...dPropertiesErrorFromNotUsingIdentifier.ts} | 0 ...jectLiteralShorthandPropertiesTargetES6.ts | 31 --------- ...ectLiteralShorthandPropertiesWithModule.ts | 14 ++++ ...iteralShorthandPropertiesWithModuleES6.ts} | 2 +- ...tionEntryForShorthandPropertyAssignment.ts | 6 ++ ...etionListForShorthandPropertyAssignment.ts | 7 ++ ...tionListForShorthandPropertyAssignment2.ts | 7 ++ ...dAllRefsWithShorthandPropertyAssignment.ts | 19 ++++++ ...AllRefsWithShorthandPropertyAssignment2.ts | 23 +++++++ 35 files changed, 544 insertions(+), 185 deletions(-) delete mode 100644 tests/baselines/reference/objectLiteralShorthandProperties4.js delete mode 100644 tests/baselines/reference/objectLiteralShorthandPropertiesAssignment2.errors.txt delete mode 100644 tests/baselines/reference/objectLiteralShorthandPropertiesAssignment2.js create mode 100644 tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.js create mode 100644 tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.types create mode 100644 tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt create mode 100644 tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt create mode 100644 tests/baselines/reference/objectLiteralShorthandPropertiesES6.js rename tests/baselines/reference/{objectLiteralShorthandPropertiesTargetES6.types => objectLiteralShorthandPropertiesES6.types} (59%) rename tests/baselines/reference/{objectLiteralShorthandProperties4.errors.txt => objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.errors.txt} (58%) create mode 100644 tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.js rename tests/baselines/reference/{objectLiteralShorthandProperties2.errors.txt => objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.errors.txt} (55%) delete mode 100644 tests/baselines/reference/objectLiteralShorthandPropertiesTargetES6.js rename tests/baselines/reference/{objectLiteralShorthandProperties3.js => objectLiteralShorthandPropertiesWithModule.js} (71%) rename tests/baselines/reference/{objectLiteralShorthandProperties3.types => objectLiteralShorthandPropertiesWithModule.types} (82%) create mode 100644 tests/baselines/reference/objectLiteralShorthandPropertiesWithModuleES6.js create mode 100644 tests/baselines/reference/objectLiteralShorthandPropertiesWithModuleES6.types delete mode 100644 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment2.ts create mode 100644 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentES6.ts create mode 100644 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts create mode 100644 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts create mode 100644 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesES6.ts rename tests/cases/conformance/es6/shorthandPropertyAssignment/{objectLiteralShorthandProperties4.ts => objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.ts} (100%) rename tests/cases/conformance/es6/shorthandPropertyAssignment/{objectLiteralShorthandProperties2.ts => objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts} (100%) delete mode 100644 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesTargetES6.ts create mode 100644 tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesWithModule.ts rename tests/cases/conformance/es6/shorthandPropertyAssignment/{objectLiteralShorthandProperties3.ts => objectLiteralShorthandPropertiesWithModuleES6.ts} (77%) create mode 100644 tests/cases/fourslash/completionEntryForShorthandPropertyAssignment.ts create mode 100644 tests/cases/fourslash/completionListForShorthandPropertyAssignment.ts create mode 100644 tests/cases/fourslash/completionListForShorthandPropertyAssignment2.ts create mode 100644 tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts create mode 100644 tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts diff --git a/tests/baselines/reference/objectLiteralShorthandProperties4.js b/tests/baselines/reference/objectLiteralShorthandProperties4.js deleted file mode 100644 index ed8ee494b1..0000000000 --- a/tests/baselines/reference/objectLiteralShorthandProperties4.js +++ /dev/null @@ -1,12 +0,0 @@ -//// [objectLiteralShorthandProperties4.ts] -var x = { - x, // OK - undefinedVariable // Error -} - - -//// [objectLiteralShorthandProperties4.js] -var x = { - x: x, - undefinedVariable: undefinedVariable // Error -}; diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.js b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.js index 6af0a69a30..2ef29a3708 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.js +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.js @@ -3,9 +3,34 @@ 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); //// [objectLiteralShorthandPropertiesAssignment.js] var id = 10000; var name = "my name"; 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); diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.types b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.types index f7f18c8f0c..91d9e528d6 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.types +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.types @@ -13,3 +13,56 @@ var person: { name: string; id: number } = { name, id }; >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; } + diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment2.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment2.errors.txt deleted file mode 100644 index a3ae961f6e..0000000000 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment2.errors.txt +++ /dev/null @@ -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; }'. - \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment2.js b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment2.js deleted file mode 100644 index f37bb1cd52..0000000000 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment2.js +++ /dev/null @@ -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 diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.js b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.js new file mode 100644 index 0000000000..b2f9004b07 --- /dev/null +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.js @@ -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); diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.types b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.types new file mode 100644 index 0000000000..38791fc1be --- /dev/null +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.types @@ -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; } + diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt new file mode 100644 index 0000000000..2db47d0f7a --- /dev/null +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt @@ -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'. + + \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt new file mode 100644 index 0000000000..708bbb0935 --- /dev/null +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt @@ -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'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesES6.js b/tests/baselines/reference/objectLiteralShorthandPropertiesES6.js new file mode 100644 index 0000000000..b398a23135 --- /dev/null +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesES6.js @@ -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 +}; diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesTargetES6.types b/tests/baselines/reference/objectLiteralShorthandPropertiesES6.types similarity index 59% rename from tests/baselines/reference/objectLiteralShorthandPropertiesTargetES6.types rename to tests/baselines/reference/objectLiteralShorthandPropertiesES6.types index 560ae4af4c..0383a3f5d2 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesTargetES6.types +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesES6.types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesTargetES6.ts === +=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesES6.ts === var a, b, c; >a : 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 - - }; -} diff --git a/tests/baselines/reference/objectLiteralShorthandProperties4.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.errors.txt similarity index 58% rename from tests/baselines/reference/objectLiteralShorthandProperties4.errors.txt rename to tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.errors.txt index 678e18143e..fcd04b2775 100644 --- a/tests/baselines/reference/objectLiteralShorthandProperties4.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.errors.txt @@ -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 = { x, // OK undefinedVariable // Error diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.js b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.js new file mode 100644 index 0000000000..6050e5b756 --- /dev/null +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.js @@ -0,0 +1,12 @@ +//// [objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.ts] +var x = { + x, // OK + undefinedVariable // Error +} + + +//// [objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.js] +var x = { + x: x, + undefinedVariable: undefinedVariable // Error +}; diff --git a/tests/baselines/reference/objectLiteralShorthandProperties2.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.errors.txt similarity index 55% rename from tests/baselines/reference/objectLiteralShorthandProperties2.errors.txt rename to tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.errors.txt index 0e6b9eba61..0a317d70f1 100644 --- a/tests/baselines/reference/objectLiteralShorthandProperties2.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.errors.txt @@ -1,23 +1,23 @@ -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(3,20): error TS1005: ':' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(4,7): error TS1005: ':' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(5,10): error TS1005: '(' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(6,10): error TS1005: '(' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(7,9): error TS1005: ':' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(8,10): error TS1005: ':' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(9,8): error TS1005: ':' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(10,10): error TS1005: ':' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(12,1): error TS1005: ':' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(15,6): error TS1005: ',' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts(16,6): error TS1005: ',' expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.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/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/objectLiteralShorthandProperties2.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/objectLiteralShorthandProperties2.ts(16,5): error TS2300: Duplicate identifier 'a'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(3,20): error TS1005: ':' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(4,7): error TS1005: ':' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(5,10): error TS1005: '(' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(6,10): error TS1005: '(' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(7,9): error TS1005: ':' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(8,10): error TS1005: ':' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(9,8): error TS1005: ':' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(10,10): error TS1005: ':' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(12,1): error TS1005: ':' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,6): error TS1005: ',' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,6): error TS1005: ',' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(17,6): error TS1005: '=' expected. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(18,1): error TS1128: Declaration or statement expected. +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/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,5): error TS2300: Duplicate identifier 'a'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,7): error TS2304: Cannot find name 'b'. +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 var y = { "stringLiteral", diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesTargetES6.js b/tests/baselines/reference/objectLiteralShorthandPropertiesTargetES6.js deleted file mode 100644 index a35fc69770..0000000000 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesTargetES6.js +++ /dev/null @@ -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 = {})); diff --git a/tests/baselines/reference/objectLiteralShorthandProperties3.js b/tests/baselines/reference/objectLiteralShorthandPropertiesWithModule.js similarity index 71% rename from tests/baselines/reference/objectLiteralShorthandProperties3.js rename to tests/baselines/reference/objectLiteralShorthandPropertiesWithModule.js index 0d436efa78..e2eb1fc128 100644 --- a/tests/baselines/reference/objectLiteralShorthandProperties3.js +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesWithModule.js @@ -1,4 +1,4 @@ -//// [objectLiteralShorthandProperties3.ts] +//// [objectLiteralShorthandPropertiesWithModule.ts] // module export module m { @@ -14,7 +14,7 @@ module m { } -//// [objectLiteralShorthandProperties3.js] +//// [objectLiteralShorthandPropertiesWithModule.js] // module export var m; (function (m) { diff --git a/tests/baselines/reference/objectLiteralShorthandProperties3.types b/tests/baselines/reference/objectLiteralShorthandPropertiesWithModule.types similarity index 82% rename from tests/baselines/reference/objectLiteralShorthandProperties3.types rename to tests/baselines/reference/objectLiteralShorthandPropertiesWithModule.types index 5d58532b3d..77e139a342 100644 --- a/tests/baselines/reference/objectLiteralShorthandProperties3.types +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesWithModule.types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties3.ts === +=== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesWithModule.ts === // module export module m { diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesWithModuleES6.js b/tests/baselines/reference/objectLiteralShorthandPropertiesWithModuleES6.js new file mode 100644 index 0000000000..edb4e6c295 --- /dev/null +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesWithModuleES6.js @@ -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 = {})); diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesWithModuleES6.types b/tests/baselines/reference/objectLiteralShorthandPropertiesWithModuleES6.types new file mode 100644 index 0000000000..1030010d6c --- /dev/null +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesWithModuleES6.types @@ -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 + + }; +} + diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment.ts index 44448a26a9..3878210016 100644 --- a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment.ts +++ b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment.ts @@ -2,3 +2,12 @@ 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); diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment2.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment2.ts deleted file mode 100644 index a3f88036dd..0000000000 --- a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment2.ts +++ /dev/null @@ -1,4 +0,0 @@ -var id: number = 10000; -var name: string = "my name"; - -var person: { b: string; id: number } = { name, id }; // error diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentES6.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentES6.ts new file mode 100644 index 0000000000..19fd21b47b --- /dev/null +++ b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentES6.ts @@ -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); diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts new file mode 100644 index 0000000000..b745b93b3c --- /dev/null +++ b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts @@ -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 + diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts new file mode 100644 index 0000000000..6b0943a8d7 --- /dev/null +++ b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts @@ -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); \ No newline at end of file diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesES6.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesES6.ts new file mode 100644 index 0000000000..bf4c2583c0 --- /dev/null +++ b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesES6.ts @@ -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 +}; + diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties4.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.ts similarity index 100% rename from tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties4.ts rename to tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNoneExistingIdentifier.ts diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts similarity index 100% rename from tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties2.ts rename to tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesTargetES6.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesTargetES6.ts deleted file mode 100644 index 21351372de..0000000000 --- a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesTargetES6.ts +++ /dev/null @@ -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 - }; -} diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesWithModule.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesWithModule.ts new file mode 100644 index 0000000000..3f609089e2 --- /dev/null +++ b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesWithModule.ts @@ -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; diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties3.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesWithModuleES6.ts similarity index 77% rename from tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties3.ts rename to tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesWithModuleES6.ts index 005885bb90..f8937625af 100644 --- a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandProperties3.ts +++ b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesWithModuleES6.ts @@ -1,4 +1,4 @@ -// module export +// @target: es6 module m { export var x; diff --git a/tests/cases/fourslash/completionEntryForShorthandPropertyAssignment.ts b/tests/cases/fourslash/completionEntryForShorthandPropertyAssignment.ts new file mode 100644 index 0000000000..dae5762d92 --- /dev/null +++ b/tests/cases/fourslash/completionEntryForShorthandPropertyAssignment.ts @@ -0,0 +1,6 @@ +/// + +//// var person: {name:string; id:number} = {n/**/ + +goTo.marker(); +verify.completionListContains("name", /*text*/ undefined, /*documentation*/ undefined, "property"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListForShorthandPropertyAssignment.ts b/tests/cases/fourslash/completionListForShorthandPropertyAssignment.ts new file mode 100644 index 0000000000..d8262d7104 --- /dev/null +++ b/tests/cases/fourslash/completionListForShorthandPropertyAssignment.ts @@ -0,0 +1,7 @@ +/// + +//// var person: {name:string; id: number} = { n/**/ + +goTo.marker(); +verify.memberListContains('name'); +verify.memberListContains('id'); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListForShorthandPropertyAssignment2.ts b/tests/cases/fourslash/completionListForShorthandPropertyAssignment2.ts new file mode 100644 index 0000000000..d8262d7104 --- /dev/null +++ b/tests/cases/fourslash/completionListForShorthandPropertyAssignment2.ts @@ -0,0 +1,7 @@ +/// + +//// var person: {name:string; id: number} = { n/**/ + +goTo.marker(); +verify.memberListContains('name'); +verify.memberListContains('id'); \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts new file mode 100644 index 0000000000..7a1f7a0225 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts @@ -0,0 +1,19 @@ +/// + +//// 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); diff --git a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts new file mode 100644 index 0000000000..e9bb7bf02a --- /dev/null +++ b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts @@ -0,0 +1,23 @@ +/// + +//// 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);