JS: Add test for getFieldTypeAnnotation

This commit is contained in:
Asger Feldthaus
2020-10-06 10:01:04 +01:00
parent 8689a9b3b9
commit c31cdaacb2
7 changed files with 24 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
| fields.ts:2:16:2:32 | (x: string) => {} | Foo.m | method |
| fields.ts:12:16:12:32 | (x: string) => {} | Foo.m | method |
| namespace.js:5:32:5:44 | function() {} | Baz.method | method |
| tst2.js:6:9:9:3 | () {\\n ... .x;\\n } | C.method | method |
| tst2.js:11:13:13:3 | () {\\n ... .x;\\n } | C.getter | getter |

View File

@@ -1,4 +1,4 @@
| fields.ts:2:16:2:32 | (x: string) => {} | Foo.m |
| fields.ts:12:16:12:32 | (x: string) => {} | Foo.m |
| namespace.js:5:32:5:44 | function() {} | Baz.method |
| tst2.js:6:9:9:3 | () {\\n ... .x;\\n } | C.method |
| tst2.js:18:14:18:22 | (x) => {} | D.f |

View File

@@ -1,3 +1,4 @@
| fields.ts:5:1:13:1 | class F ... > {};\\n} | Foo | fields.ts:1:1:3:1 | class B ... mber;\\n} | Base |
| tst.js:13:1:13:21 | class A ... ds A {} | A2 | tst.js:3:1:10:1 | class A ... () {}\\n} | A |
| tst.js:15:1:15:15 | function B() {} | B | tst.js:3:1:10:1 | class A ... () {}\\n} | A |
| tst.js:19:1:19:15 | function C() {} | C | tst.js:15:1:15:15 | function B() {} | B |

View File

@@ -1,3 +1,13 @@
class Foo {
class Base {
baseField: number;
}
class Foo extends Base {
constructor(public x: number, private y: string) {
super();
}
z: string[];
public m = (x: string) => {};
}

View File

@@ -1,4 +1,5 @@
| fields.ts:1:1:3:1 | class F ... > {};\\n} | fields.ts:1:11:1:10 | this |
| fields.ts:1:1:3:1 | class B ... mber;\\n} | fields.ts:1:12:1:11 | this |
| fields.ts:5:1:13:1 | class F ... > {};\\n} | fields.ts:6:5:6:4 | this |
| namespace.js:3:15:3:31 | function Baz() {} | namespace.js:3:15:3:14 | this |
| namespace.js:3:15:3:31 | function Baz() {} | namespace.js:5:32:5:31 | this |
| tst2.js:1:1:14:1 | class C ... ;\\n }\\n} | tst2.js:2:14:2:13 | this |

View File

@@ -0,0 +1,4 @@
| fields.ts:1:1:3:1 | class B ... mber;\\n} | baseField | fields.ts:2:16:2:21 | number |
| fields.ts:5:1:13:1 | class F ... > {};\\n} | x | fields.ts:6:27:6:32 | number |
| fields.ts:5:1:13:1 | class F ... > {};\\n} | y | fields.ts:6:46:6:51 | string |
| fields.ts:5:1:13:1 | class F ... > {};\\n} | z | fields.ts:10:8:10:15 | string[] |

View File

@@ -0,0 +1,4 @@
import javascript
from DataFlow::ClassNode cls, string name
select cls, name, cls.getFieldTypeAnnotation(name)