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: [TS4.7] allow visiting of typeParameters in TSTypeQuery#5166

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
bradzacher merged 2 commits intomainfromfix/visiting-typeParameters-in-typeQuery
Jun 10, 2022
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
3 changes: 3 additions & 0 deletions.prettierignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,9 @@ packages/eslint-plugin/src/configs/*.json
CONTRIBUTORS.md
packages/ast-spec/src/*/*/fixtures/_error_/*/fixture.ts

# Syntax not yet supported
packages/scope-manager/tests/fixtures/type-declaration/type-query-with-parameters.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@@ -739,6 +739,15 @@ export function foo() {
return new Promise<Foo>();
}
`,
// https://github.com/typescript-eslint/typescript-eslint/issues/5152
{
code: noFormat`
function foo<T>(value: T): T {
return { value };
}
export type Foo<T> = typeof foo<T>;
`,
},
// https://github.com/typescript-eslint/typescript-eslint/issues/2331
{
code: `
Expand Down
1 change: 1 addition & 0 deletionspackages/scope-manager/src/referencer/TypeVisitor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -265,6 +265,7 @@ class TypeVisitor extends Visitor {
}
this.#referencer.currentScope().referenceValue(expr);
}
this.visit(node.typeParameters);
}

protected TSTypeAnnotation(node: TSESTree.TSTypeAnnotation): void {
Expand Down
4 changes: 3 additions & 1 deletionpackages/scope-manager/tests/fixtures.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,9 @@ const ONLY = [].join(path.sep);
const FIXTURES_DIR = path.resolve(__dirname, 'fixtures');

const fixtures = glob
.sync(`${FIXTURES_DIR}/**/*.{js,ts,jsx,tsx}`, {
.sync('**/*.{js,ts,jsx,tsx}', {
cwd: FIXTURES_DIR,
absolute: true,
ignore: ['fixtures.test.ts'],
})
.map(absolute => {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
function foo<T>(y: T) {
return { y };
}

export type Foo<T> = typeof foo<T>;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`type-declaration type-query-with-parameters 1`] = `
ScopeManager {
variables: Array [
ImplicitGlobalConstTypeVariable,
Variable$2 {
defs: Array [
FunctionNameDefinition$1 {
name: Identifier<"foo">,
node: FunctionDeclaration$1,
},
],
name: "foo",
references: Array [
Reference$3 {
identifier: Identifier<"foo">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: Variable$2,
},
],
isValueVariable: true,
isTypeVariable: false,
},
Variable$3 {
defs: Array [],
name: "arguments",
references: Array [],
isValueVariable: true,
isTypeVariable: true,
},
Variable$4 {
defs: Array [
ParameterDefinition$2 {
name: Identifier<"y">,
node: FunctionDeclaration$1,
},
],
name: "y",
references: Array [
Reference$2 {
identifier: Identifier<"y">,
isRead: true,
isTypeReference: false,
isValueReference: true,
isWrite: false,
resolved: Variable$4,
},
],
isValueVariable: true,
isTypeVariable: false,
},
Variable$5 {
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$5,
},
],
isValueVariable: false,
isTypeVariable: true,
},
Variable$6 {
defs: Array [
TypeDefinition$4 {
name: Identifier<"Foo">,
node: TSTypeAliasDeclaration$3,
},
],
name: "Foo",
references: Array [],
isValueVariable: false,
isTypeVariable: true,
},
Variable$7 {
defs: Array [
TypeDefinition$5 {
name: Identifier<"T">,
node: TSTypeParameter$4,
},
],
name: "T",
references: Array [
Reference$4 {
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 [],
set: Map {
"const" => ImplicitGlobalConstTypeVariable,
"foo" => Variable$2,
"Foo" => Variable$6,
},
type: "global",
upper: null,
variables: Array [
ImplicitGlobalConstTypeVariable,
Variable$2,
Variable$6,
],
},
FunctionScope$2 {
block: FunctionDeclaration$1,
isStrict: false,
references: Array [
Reference$1,
Reference$2,
],
set: Map {
"arguments" => Variable$3,
"y" => Variable$4,
"T" => Variable$5,
},
type: "function",
upper: GlobalScope$1,
variables: Array [
Variable$3,
Variable$4,
Variable$5,
],
},
TypeScope$3 {
block: TSTypeAliasDeclaration$3,
isStrict: true,
references: Array [
Reference$3,
Reference$4,
],
set: Map {
"T" => Variable$7,
},
type: "type",
upper: GlobalScope$1,
variables: Array [
Variable$7,
],
},
],
}
`;
2 changes: 1 addition & 1 deletionpackages/visitor-keys/src/visitor-keys.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,7 +142,7 @@ const additionalKeys: AdditionalKeys = {
TSTypeParameterDeclaration: ['params'],
TSTypeParameterInstantiation: ['params'],
TSTypePredicate: ['typeAnnotation', 'parameterName'],
TSTypeQuery: ['exprName'],
TSTypeQuery: ['exprName', 'typeParameters'],
TSTypeReference: ['typeName', 'typeParameters'],
TSUndefinedKeyword: [],
TSUnionType: ['types'],
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp