kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/typescript/testdata/interface.ts (about) 1 /** 2 * @fileoverview File that test that interface properties are indexed correctly. 3 */ 4 5 interface Person { 6 //- @name defines/binding Name 7 name: string; 8 //- @getAge defines/binding GetAge 9 getAge(): void; 10 } 11 12 const p: Person = { 13 //- @name ref/id Name 14 name: 'Alice', 15 //- @getAge ref/id GetAge 16 getAge() {} 17 }; 18 19 const p2 = { 20 //- @name ref/id Name 21 name: 'Alice', 22 //- @getAge ref/id GetAge 23 getAge() {} 24 } as Person; 25 26 //- @name ref Name 27 p.name; 28 29 //- @getAge ref GetAge 30 p.getAge(); 31 32 //- @getAge ref/id GetAge 33 const {getAge} = p; 34 35 //- @name ref/id Name 36 //- @getAge ref/id GetAge 37 function takesPerson({name, getAge: newGetAge}: Person) {} 38 39 //- @name ref/id Name 40 //- @getAge ref/id GetAge 41 takesPerson({name: 'Alice', getAge() {}}); 42 43 class PersonTaker { 44 constructor(p: Person) {} 45 } 46 47 //- @name ref/id Name 48 //- @getAge ref/id GetAge 49 new PersonTaker({name: 'Alice', getAge() {}}); 50 51 function returnPerson(): Person { 52 //- @name ref/id Name 53 //- @getAge ref/id GetAge 54 return {name: 'Alice', getAge() {}}; 55 } 56 57 // test property shorthands 58 { 59 const name = 'Alice'; 60 const getAge = () = {}; 61 //- @name ref/id Name 62 //- @getAge ref/id GetAge 63 const p3: Person = {name, getAge}; 64 }