mirror of
https://github.com/github/codeql.git
synced 2026-04-25 00:35:20 +02:00
JS: Add test for missing type flow through generics
This commit is contained in:
46
javascript/ql/test/library-tests/UnderlyingTypes/generics.ts
Normal file
46
javascript/ql/test/library-tests/UnderlyingTypes/generics.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import * as express from 'express';
|
||||
|
||||
type Box1<T> = {
|
||||
value: T;
|
||||
other: string;
|
||||
};
|
||||
function t1(b: Box1<express.Request>) {
|
||||
b.value; // $ MISSING: hasUnderlyingType='express'.Request
|
||||
b.other;
|
||||
}
|
||||
|
||||
interface Box2<T> {
|
||||
value: T;
|
||||
other: string;
|
||||
}
|
||||
function t2(b: Box2<express.Request>) {
|
||||
b.value; // $ MISSING: hasUnderlyingType='express'.Request
|
||||
b.other;
|
||||
}
|
||||
|
||||
class Box3<T> {
|
||||
value: T;
|
||||
other: string;
|
||||
}
|
||||
function t3(b: Box3<express.Request>) {
|
||||
b.value; // $ MISSING: hasUnderlyingType='express'.Request
|
||||
b.other;
|
||||
}
|
||||
|
||||
abstract class Box4<T> {
|
||||
abstract getValue(): T;
|
||||
abstract getOther(): string;
|
||||
}
|
||||
function t4(b: Box4<express.Request>) {
|
||||
b.getValue(); // $ MISSING: hasUnderlyingType='express'.Request
|
||||
b.getOther();
|
||||
}
|
||||
|
||||
type Box5<T> = {
|
||||
value: T & { blah: string };
|
||||
other: string;
|
||||
};
|
||||
function t5(b: Box5<express.Request>) {
|
||||
b.value; // $ MISSING: hasUnderlyingType='express'.Request
|
||||
b.other;
|
||||
}
|
||||
Reference in New Issue
Block a user