Skip to content

Commit d025d59

Browse files
committed
JS: Add test for underlying types
1 parent 34a9c2f commit d025d59

20 files changed

+222
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as express from 'express';
2+
3+
function getRequest(): express.Request { }
4+
5+
function t1() {
6+
getRequest(); // $ hasUnderlyingType='express'.Request
7+
}
8+
9+
declare function getRequestAmbient(): express.Request;
10+
11+
function t2() {
12+
getRequestAmbient(); // $ MISSING: hasUnderlyingType='express'.Request
13+
}
14+
15+
class C {
16+
method(): express.Request { }
17+
}
18+
19+
function t3(c: C) {
20+
c.method(); // $ hasUnderlyingType='express'.Request
21+
new C().method(); // $ hasUnderlyingType='express'.Request
22+
}
23+
24+
function callback(fn: (req: express.Request) => void) { // $ SPURIOUS: hasUnderlyingType='express'.Request - req seems to be a SourceNode
25+
}
26+
27+
function t4() {
28+
callback(function (
29+
req // $ hasUnderlyingType='express'.Request
30+
) { }
31+
);
32+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from 'express';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Request, Response } from './expressBulkExport';
2+
3+
function t1(req: Request) { // $ hasUnderlyingType='express'.Request
4+
}
5+
6+
function t2(res: Response) { // $ hasUnderlyingType='express'.Response
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import E = require('express');
2+
export = E;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Request } from "./expressExportAssign";
2+
3+
function t1(req: Request) { // $ hasUnderlyingType='express'.Request
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Express = require('express');
2+
namespace Wrapper {
3+
export import E = Express;
4+
}
5+
export = Wrapper;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { E } from "./expressExportAssignWrapper";
2+
3+
function t1(req: E.Request) { // $ hasUnderlyingType='express'.Request
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { Request } from 'express';
2+
export { Response as R } from 'express';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Request, Response, R } from './expressSelectiveExport';
2+
3+
function t1(req: Request) { // $ hasUnderlyingType='express'.Request
4+
}
5+
6+
function t2(res: Response) { // none, not exported
7+
}
8+
9+
function t3(res: R) { // $ hasUnderlyingType='express'.Response
10+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * as wrapper from 'express';

0 commit comments

Comments
 (0)