Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(scope-manager): handle typeParameters of TSInstantiationExpression#5355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions.prettierignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,8 @@ packages/ast-spec/src/*/*/fixtures/_error_/*/fixture.ts
# Syntax not yet supported
packages/scope-manager/tests/fixtures/type-declaration/type-query-with-parameters.ts
packages/scope-manager/tests/fixtures/type-declaration/infer-type-constraint.ts
packages/scope-manager/tests/fixtures/instantiation-expressions/type-arguments1.ts
packages/scope-manager/tests/fixtures/instantiation-expressions/type-arguments2.ts

# Ignore CHANGELOG.md files to avoid issues with automated release job
CHANGELOG.md
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -921,6 +921,15 @@ export declare namespace Foo {
}
}
}
`,
noFormat`
class Foo<T> {
value: T;
}
class Bar<T> {
foo = Foo<T>;
}
new Bar();
`,
{
code: `
Expand Down
7 changes: 7 additions & 0 deletionspackages/scope-manager/src/referencer/Referencer.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -692,6 +692,13 @@ class Referencer extends Visitor {
this.close(node);
}

protected TSInstantiationExpression(
node: TSESTree.TSInstantiationExpression,
): void {
this.visitChildren(node, ['typeParameters']);
this.visitType(node.typeParameters);
}

protected TSInterfaceDeclaration(
node: TSESTree.TSInterfaceDeclaration,
): void {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
class Foo<T> {
value: T
}

class Bar<T> {
foo = Foo<T>
}

new Bar()
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`instantiation-expressions type-arguments1 1`] = `
ScopeManager {
variables: Array [
ImplicitGlobalConstTypeVariable,
Variable$2 {
defs: Array [
ClassNameDefinition$1 {
name: Identifier<"Foo">,
node: ClassDeclaration$1,
},
],
name: "Foo",
references: Array [
Reference$2 {
identifier: Identifier<"Foo">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: Variable$2,
},
],
isValueVariable: true,
isTypeVariable: true,
},
Variable$3 {
defs: Array [
ClassNameDefinition$2 {
name: Identifier<"Foo">,
node: ClassDeclaration$1,
},
],
name: "Foo",
references: Array [],
isValueVariable: true,
isTypeVariable: true,
},
Variable$4 {
defs: Array [
TypeDefinition$3 {
name: Identifier<"T">,
node: TSTypeParameter$2,
},
],
name: "T",
references: Array [
Reference$1 {
identifier: Identifier<"T">,
isRead: true,
isTypeReference: true,
isValueReference: false,
isWrite: false,
resolved: Variable$4,
},
],
isValueVariable: false,
isTypeVariable: true,
},
Variable$5 {
defs: Array [
ClassNameDefinition$4 {
name: Identifier<"Bar">,
node: ClassDeclaration$3,
},
],
name: "Bar",
references: Array [
Reference$4 {
identifier: Identifier<"Bar">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: Variable$5,
},
],
isValueVariable: true,
isTypeVariable: true,
},
Variable$6 {
defs: Array [
ClassNameDefinition$5 {
name: Identifier<"Bar">,
node: ClassDeclaration$3,
},
],
name: "Bar",
references: Array [],
isValueVariable: true,
isTypeVariable: true,
},
Variable$7 {
defs: Array [
TypeDefinition$6 {
name: Identifier<"T">,
node: TSTypeParameter$4,
},
],
name: "T",
references: Array [
Reference$3 {
identifier: Identifier<"T">,
isRead: true,
isTypeReference: true,
isValueReference: false,
isWrite: false,
resolved: Variable$7,
},
],
isValueVariable: false,
isTypeVariable: true,
},
],
scopes: Array [
GlobalScope$1 {
block: Program$5,
isStrict: false,
references: Array [
Reference$4,
],
set: Map {
"const" => ImplicitGlobalConstTypeVariable,
"Foo" => Variable$2,
"Bar" => Variable$5,
},
type: "global",
upper: null,
variables: Array [
ImplicitGlobalConstTypeVariable,
Variable$2,
Variable$5,
],
},
ClassScope$2 {
block: ClassDeclaration$1,
isStrict: true,
references: Array [
Reference$1,
],
set: Map {
"Foo" => Variable$3,
"T" => Variable$4,
},
type: "class",
upper: GlobalScope$1,
variables: Array [
Variable$3,
Variable$4,
],
},
ClassScope$3 {
block: ClassDeclaration$3,
isStrict: true,
references: Array [],
set: Map {
"Bar" => Variable$6,
"T" => Variable$7,
},
type: "class",
upper: GlobalScope$1,
variables: Array [
Variable$6,
Variable$7,
],
},
ClassFieldInitializerScope$4 {
block: TSInstantiationExpression$6,
isStrict: true,
references: Array [
Reference$2,
Reference$3,
],
set: Map {},
type: "class-field-initializer",
upper: ClassScope$3,
variables: Array [],
},
],
}
`;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
function makeBox<T>(value: T) {
return { value };
}

type BoxFunc<T> = typeof makeBox<T>;
const makeStringBox = makeBox<string>;
Loading

[8]ページ先頭

©2009-2025 Movatter.jp