kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/typescript/testdata/schema.ts (about)

     1  // Tests TypeScript indexer VName schema.
     2  
     3  // SourceFile
     4  //- FileModule=VName("module", _, _, "testdata/schema", "typescript").node/kind record
     5  //- FileModuleAnchor.node/kind anchor
     6  //- FileModuleAnchor./kythe/loc/start 0
     7  //- FileModuleAnchor./kythe/loc/end 0
     8  //- FileModuleAnchor defines/implicit FileModule
     9  
    10  // NamespaceImport
    11  //- @NspI defines/binding VName("NspI", _, _, "testdata/schema", "typescript")
    12  import * as NspI from './declaration_group/declaration';
    13  
    14  // ExportAssignment
    15  //- @default defines/binding VName("default", _, _, "testdata/schema", "typescript")
    16  export default NspI;
    17  
    18  // ClassDeclaration
    19  //- @C defines/binding VName("C#type", _, _, "testdata/schema", "typescript")
    20  class C {
    21    // PropertyDeclaration instance member
    22    //- @property defines/binding VName("C#type.property", _, _, "testdata/schema", "typescript")
    23    property = 0;
    24  
    25    // PropertyDeclarartion string literal
    26    //- @"'propliteral'" defines/binding VName("C#type.\"propliteral\"", _, _, "testdata/schema", "typescript")
    27    'propliteral' = 0;
    28  
    29    // PropertyDeclaration static member
    30    //- @property defines/binding VName("C.property", _, _, "testdata/schema", "typescript")
    31    static property = 0;
    32  
    33    // MethodDeclaration
    34    //- @method defines/binding VName("C#type.method", _, _, "testdata/schema", "typescript")
    35    method() {}
    36  
    37    // Constructor, ParameterPropertyDeclaration
    38    //- @constructor defines/binding VName("C", _, _, "testdata/schema", "typescript")
    39    //- @cprop defines/binding VName("C#type.cprop", _, _, "testdata/schema", "typescript")
    40    constructor(private cprop: number) {}
    41  
    42    // GetAccessor
    43    //- @prop defines/binding VName("C#type.prop:getter", _, _, "testdata/schema", "typescript")
    44    //- @prop defines/binding VName("C#type.prop", _, _, "testdata/schema", "typescript")
    45    get prop() {
    46      return this.property;
    47    }
    48  
    49    // SetAccessor
    50    //- @prop defines/binding VName("C#type.prop:setter", _, _, "testdata/schema", "typescript")
    51    set prop(nProp) {
    52      this.property = nProp;
    53    }
    54  }
    55  
    56  // ClassDeclaration with no ctor
    57  //- @CC defines/binding VName("CC#type", _, _, "testdata/schema", "typescript")
    58  //- @CC defines/binding VName("CC", _, _, "testdata/schema", "typescript")
    59  class CC {}
    60  
    61  // EnumDeclaration
    62  //- @E defines/binding VName("E", _, _, "testdata/schema", "typescript")
    63  //- @E defines/binding VName("E#type", _, _, "testdata/schema", "typescript")
    64  enum E {
    65    // EnumMember
    66    //- @EnumMember defines/binding VName("E.EnumMember", _, _, "testdata/schema", "typescript")
    67    EnumMember = 0
    68  }
    69  
    70  // FunctionDeclaration
    71  //- @#1"fun" defines/binding VName("fun", _, _, "testdata/schema", "typescript")
    72  function fun(
    73      // Parameter
    74      //- @param defines/binding VName("fun.param", _, _, "testdata/schema", "typescript")
    75      param: number) {}
    76  
    77  // InterfaceDeclaration
    78  //- @B defines/binding VName("B#type", _, _, "testdata/schema", "typescript")
    79  interface B {
    80    // PropertySignature
    81    //- @pSig defines/binding VName("B.pSig", _, _, "testdata/schema", "typescript")
    82    pSig: number;
    83  
    84    // MethodSignature
    85    //- @mSig defines/binding VName("B.mSig", _, _, "testdata/schema", "typescript")
    86    mSig(): void;
    87  }
    88  
    89  // VariableDeclaration
    90  //- @v defines/binding VName("v", _, _, "testdata/schema", "typescript")
    91  let v = {
    92    // PropertyAssignment
    93    // TODO: the signature here should be something like `block0.prop`, but
    94    // anonymous block names are not well-defined by the spec yet.
    95    //- @prop defines/binding VName(_, _, _, "testdata/schema", "typescript")
    96    prop: 0
    97  };
    98  
    99  // TypeAliasDeclaration
   100  //- @AliasArray defines/binding VName("AliasArray#type", _, _, "testdata/schema", "typescript")
   101  type AliasArray<
   102      // TypeParameter
   103      //- @#0"T" defines/binding VName("AliasArray.T#mtype", _, _, "testdata/schema", "typescript")
   104      T> = Array<T>;
   105  
   106  //- @arrowFun defines/binding VName("arrowFun", _, _, "testdata/schema", "typescript")
   107  const arrowFun = () => {
   108    // Arrow function scope name is not well-defined.
   109    //- @anonArrowFunDecl defines/binding VName(_, _, _, "testdata/schema", "typescript")
   110    let anonArrowFunDecl;
   111  };
   112  
   113  {
   114    // Anonymous block scope name is not well-defined.
   115    //- @anonBlockDecl defines/binding VName(_, _, _, "testdata/schema", "typescript")
   116    let anonBlockDecl;
   117  }