Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit f5de9b0

Browse files
committed
add typeof-in-call-signature fixture
1 parent efeda57 commit f5de9b0

File tree

3 files changed

+245
-1
lines changed

3 files changed

+245
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const obj = { value: 1 }
2+
interface A {
3+
<T extends typeof obj>(a: typeof obj, b: T): typeof obj
4+
new <T extends typeof obj>(a: typeof obj, b: T): typeof obj
5+
}

tests/lib/__snapshots__/scope-analysis.js.snap

+238
Original file line numberDiff line numberDiff line change
@@ -4464,6 +4464,244 @@ Object {
44644464
}
44654465
`;
44664466

4467+
exports[`TypeScript scope analysis tests/fixtures/scope-analysis/typeof-in-call-signature.ts 1`] = `
4468+
Object {
4469+
"$id": 8,
4470+
"block": Object {
4471+
"range": Array [
4472+
0,
4473+
165,
4474+
],
4475+
"type": "Program",
4476+
},
4477+
"childScopes": Array [],
4478+
"functionExpressionScope": false,
4479+
"isStrict": false,
4480+
"references": Array [
4481+
Object {
4482+
"$id": 1,
4483+
"from": Object {
4484+
"$ref": 8,
4485+
},
4486+
"identifier": Object {
4487+
"name": "obj",
4488+
"range": Array [
4489+
6,
4490+
9,
4491+
],
4492+
"type": "Identifier",
4493+
},
4494+
"kind": "w",
4495+
"resolved": Object {
4496+
"$ref": 0,
4497+
},
4498+
"writeExpr": Object {
4499+
"range": Array [
4500+
12,
4501+
24,
4502+
],
4503+
"type": "ObjectExpression",
4504+
},
4505+
},
4506+
Object {
4507+
"$id": 2,
4508+
"from": Object {
4509+
"$ref": 8,
4510+
},
4511+
"identifier": Object {
4512+
"name": "obj",
4513+
"range": Array [
4514+
61,
4515+
64,
4516+
],
4517+
"type": "Identifier",
4518+
},
4519+
"kind": "r",
4520+
"resolved": Object {
4521+
"$ref": 0,
4522+
},
4523+
"writeExpr": undefined,
4524+
},
4525+
Object {
4526+
"$id": 3,
4527+
"from": Object {
4528+
"$ref": 8,
4529+
},
4530+
"identifier": Object {
4531+
"name": "obj",
4532+
"range": Array [
4533+
76,
4534+
79,
4535+
],
4536+
"type": "Identifier",
4537+
},
4538+
"kind": "r",
4539+
"resolved": Object {
4540+
"$ref": 0,
4541+
},
4542+
"writeExpr": undefined,
4543+
},
4544+
Object {
4545+
"$id": 4,
4546+
"from": Object {
4547+
"$ref": 8,
4548+
},
4549+
"identifier": Object {
4550+
"name": "obj",
4551+
"range": Array [
4552+
95,
4553+
98,
4554+
],
4555+
"type": "Identifier",
4556+
},
4557+
"kind": "r",
4558+
"resolved": Object {
4559+
"$ref": 0,
4560+
},
4561+
"writeExpr": undefined,
4562+
},
4563+
Object {
4564+
"$id": 5,
4565+
"from": Object {
4566+
"$ref": 8,
4567+
},
4568+
"identifier": Object {
4569+
"name": "obj",
4570+
"range": Array [
4571+
125,
4572+
128,
4573+
],
4574+
"type": "Identifier",
4575+
},
4576+
"kind": "r",
4577+
"resolved": Object {
4578+
"$ref": 0,
4579+
},
4580+
"writeExpr": undefined,
4581+
},
4582+
Object {
4583+
"$id": 6,
4584+
"from": Object {
4585+
"$ref": 8,
4586+
},
4587+
"identifier": Object {
4588+
"name": "obj",
4589+
"range": Array [
4590+
140,
4591+
143,
4592+
],
4593+
"type": "Identifier",
4594+
},
4595+
"kind": "r",
4596+
"resolved": Object {
4597+
"$ref": 0,
4598+
},
4599+
"writeExpr": undefined,
4600+
},
4601+
Object {
4602+
"$id": 7,
4603+
"from": Object {
4604+
"$ref": 8,
4605+
},
4606+
"identifier": Object {
4607+
"name": "obj",
4608+
"range": Array [
4609+
159,
4610+
162,
4611+
],
4612+
"type": "Identifier",
4613+
},
4614+
"kind": "r",
4615+
"resolved": Object {
4616+
"$ref": 0,
4617+
},
4618+
"writeExpr": undefined,
4619+
},
4620+
],
4621+
"throughReferences": Array [],
4622+
"type": "global",
4623+
"upperScope": null,
4624+
"variableMap": Object {
4625+
"obj": Object {
4626+
"$ref": 0,
4627+
},
4628+
},
4629+
"variableScope": Object {
4630+
"$ref": 8,
4631+
},
4632+
"variables": Array [
4633+
Object {
4634+
"$id": 0,
4635+
"defs": Array [
4636+
Object {
4637+
"name": Object {
4638+
"name": "obj",
4639+
"range": Array [
4640+
6,
4641+
9,
4642+
],
4643+
"type": "Identifier",
4644+
},
4645+
"node": Object {
4646+
"range": Array [
4647+
6,
4648+
24,
4649+
],
4650+
"type": "VariableDeclarator",
4651+
},
4652+
"parent": Object {
4653+
"range": Array [
4654+
0,
4655+
24,
4656+
],
4657+
"type": "VariableDeclaration",
4658+
},
4659+
"type": "Variable",
4660+
},
4661+
],
4662+
"eslintUsed": undefined,
4663+
"identifiers": Array [
4664+
Object {
4665+
"name": "obj",
4666+
"range": Array [
4667+
6,
4668+
9,
4669+
],
4670+
"type": "Identifier",
4671+
},
4672+
],
4673+
"name": "obj",
4674+
"references": Array [
4675+
Object {
4676+
"$ref": 1,
4677+
},
4678+
Object {
4679+
"$ref": 2,
4680+
},
4681+
Object {
4682+
"$ref": 3,
4683+
},
4684+
Object {
4685+
"$ref": 4,
4686+
},
4687+
Object {
4688+
"$ref": 5,
4689+
},
4690+
Object {
4691+
"$ref": 6,
4692+
},
4693+
Object {
4694+
"$ref": 7,
4695+
},
4696+
],
4697+
"scope": Object {
4698+
"$ref": 8,
4699+
},
4700+
},
4701+
],
4702+
}
4703+
`;
4704+
44674705
exports[`TypeScript scope analysis tests/fixtures/scope-analysis/typeof-in-return-type.ts 1`] = `
44684706
Object {
44694707
"$id": 5,

visitor-keys.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ module.exports = Evk.unionWith({
3131
TSArrayType: ["elementType"],
3232
TSAsyncKeyword: [],
3333
TSBooleanKeyword: [],
34+
TSCallSignature: ["typeParameters", "parameters", "typeAnnotation"],
35+
TSConstructSignature: ["typeParameters", "params", "typeAnnotation"],
3436
TSConstructorType: ["typeAnnotation", "parameters"],
35-
TSConstructSignature: ["typeAnnotation", "typeParameters"],
3637
TSDeclareKeyword: [],
3738
TSEmptyBodyDeclareFunction: ["id", "typeParameters", "params", "returnType"],
3839
TSEmptyBodyFunctionDeclaration: ["id", "typeParameters", "params", "returnType"],

0 commit comments

Comments
 (0)