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): allow visiting of constraint in infer type#5331

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 3 commits intomainfromfix/scope-manager-visiting-infer-contraint
Jul 18, 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
1 change: 1 addition & 0 deletions.prettierignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ 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

# Ignore CHANGELOG.md files to avoid issues with automated release job
CHANGELOG.md
Expand Down
2 changes: 2 additions & 0 deletionspackages/scope-manager/src/referencer/TypeVisitor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -167,6 +167,8 @@ class TypeVisitor extends Visitor {
typeParameter.name,
new TypeDefinition(typeParameter.name, typeParameter),
);

this.visit(typeParameter.constraint);
}

protected TSInterfaceDeclaration(
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
type X = string | number;
type Id<T> = T extends { id: infer Id extends X } ? Id : never;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`type-declaration infer-type-constraint 1`] = `
ScopeManager {
variables: Array [
ImplicitGlobalConstTypeVariable,
Variable$2 {
defs: Array [
TypeDefinition$1 {
name: Identifier<"X">,
node: TSTypeAliasDeclaration$1,
},
],
name: "X",
references: Array [
Reference$2 {
identifier: Identifier<"X">,
isRead: true,
isTypeReference: true,
isValueReference: false,
isWrite: false,
resolved: Variable$2,
},
Comment on lines +16 to +23
Copy link
CollaboratorAuthor

@armano2armano2Jul 10, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

X has now correct reference

pmer reacted with thumbs up emoji
],
isValueVariable: false,
isTypeVariable: true,
},
Variable$3 {
defs: Array [
TypeDefinition$2 {
name: Identifier<"Id">,
node: TSTypeAliasDeclaration$2,
},
],
name: "Id",
references: Array [],
isValueVariable: false,
isTypeVariable: true,
},
Variable$4 {
defs: Array [
TypeDefinition$3 {
name: Identifier<"T">,
node: TSTypeParameter$3,
},
],
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 [
TypeDefinition$4 {
name: Identifier<"Id">,
node: TSTypeParameter$4,
},
],
name: "Id",
references: Array [
Reference$3 {
identifier: Identifier<"Id">,
isRead: true,
isTypeReference: true,
isValueReference: false,
isWrite: false,
resolved: Variable$5,
},
],
isValueVariable: false,
isTypeVariable: true,
},
],
scopes: Array [
GlobalScope$1 {
block: Program$5,
isStrict: false,
references: Array [],
set: Map {
"const" => ImplicitGlobalConstTypeVariable,
"X" => Variable$2,
"Id" => Variable$3,
},
type: "global",
upper: null,
variables: Array [
ImplicitGlobalConstTypeVariable,
Variable$2,
Variable$3,
],
},
TypeScope$2 {
block: TSTypeAliasDeclaration$2,
isStrict: true,
references: Array [],
set: Map {
"T" => Variable$4,
},
type: "type",
upper: GlobalScope$1,
variables: Array [
Variable$4,
],
},
ConditionalTypeScope$3 {
block: TSConditionalType$6,
isStrict: true,
references: Array [
Reference$1,
Reference$2,
Reference$3,
],
set: Map {
"Id" => Variable$5,
},
type: "conditionalType",
upper: TypeScope$2,
variables: Array [
Variable$5,
],
},
],
}
`;

[8]ページ先頭

©2009-2025 Movatter.jp