Skip to content

Always consider type parameters in scope visible to the node builder #58078

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 6 additions & 4 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8672,10 +8672,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const meaning = getMeaningOfEntityNameReference(node);
const sym = resolveEntityName(leftmost, meaning, /*ignoreErrors*/ true, /*dontResolveAlias*/ true);
if (sym) {
if (isSymbolAccessible(sym, context.enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== SymbolAccessibility.Accessible) {
if (!isDeclarationName(node)) {
introducesError = true;
}
if (
!(sym.flags & SymbolFlags.TypeParameter) && // Type parameters are visible in the curent context if they are are resolvable
!isDeclarationName(node) &&
isSymbolAccessible(sym, context.enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== SymbolAccessibility.Accessible
) {
introducesError = true;
}
else {
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/1.0lib-noErrors.types
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@ interface Array<T> {
}
declare var Array: {
>Array : { (arrayLength?: number): any[]; <T>(arrayLength: number): T[]; <T_1>(...items: T_1[]): T_1[]; new (arrayLength?: number): any[]; new <T_2>(arrayLength: number): T_2[]; new <T_3>(...items: T_3[]): T_3[]; isArray(arg: any): boolean; prototype: Array<any>; }
> : ^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^ ^^^
> : ^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^ ^^^

new (arrayLength?: number): any[];
>arrayLength : number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module Errors {

(x: {
>x : { <T extends Derived>(a: T): T; <T_1 extends Base>(a: T_1): T_1; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

<T extends Derived>(a: T): T;
>a : T
Expand All @@ -173,7 +173,7 @@ module Errors {
}): any[];
(x: {
>x : { <T extends Derived2>(a: T): T; <T_1 extends Base>(a: T_1): T_1; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

<T extends Derived2>(a: T): T;
>a : T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var a16: <T extends Base>(x: { a: T; b: T }) => T[];

var a17: {
>a17 : { <T extends Derived>(x: (a: T) => T): T[]; <T_1 extends Base>(x: (a: T_1) => T_1): T_1[]; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

<T extends Derived>(x: (a: T) => T): T[];
>x : (a: T) => T
Expand All @@ -132,7 +132,7 @@ var a18: {

(x: {
>x : { <T extends Derived>(a: T): T; <T_1 extends Base>(a: T_1): T_1; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

<T extends Derived>(a: T): T;
>a : T
Expand All @@ -145,7 +145,7 @@ var a18: {
}): any[];
(x: {
>x : { <T extends Derived2>(a: T): T; <T_1 extends Base>(a: T_1): T_1; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

<T extends Derived2>(a: T): T;
>a : T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module Errors {

new (x: {
>x : { new <T extends Derived>(a: T): T; new <T_1 extends Base>(a: T_1): T_1; }
> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

new <T extends Derived>(a: T): T;
>a : T
Expand All @@ -173,7 +173,7 @@ module Errors {
}): any[];
new (x: {
>x : { new <T extends Derived2>(a: T): T; new <T_1 extends Base>(a: T_1): T_1; }
> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

new <T extends Derived2>(a: T): T;
>a : T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var a16: new <T extends Base>(x: { a: T; b: T }) => T[];

var a17: {
>a17 : { new <T extends Derived>(x: new (a: T) => T): T[]; new <T_1 extends Base>(x: new (a: T_1) => T_1): T_1[]; }
> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

new <T extends Derived>(x: new (a: T) => T): T[];
>x : new (a: T) => T
Expand All @@ -132,7 +132,7 @@ var a18: {

new (x: {
>x : { new <T extends Derived>(a: T): T; new <T_1 extends Base>(a: T_1): T_1; }
> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

new <T extends Derived>(a: T): T;
>a : T
Expand All @@ -145,7 +145,7 @@ var a18: {
}): any[];
new (x: {
>x : { new <T extends Derived2>(a: T): T; new <T_1 extends Base>(a: T_1): T_1; }
> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

new <T extends Derived2>(a: T): T;
>a : T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module Errors {

(x: {
>x : { <T extends Derived>(a: T): T; <T_1 extends Base>(a: T_1): T_1; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

<T extends Derived>(a: T): T;
>a : T
Expand All @@ -173,7 +173,7 @@ module Errors {
}): any[];
(x: {
>x : { <T extends Derived2>(a: T): T; <T_1 extends Base>(a: T_1): T_1; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

<T extends Derived2>(a: T): T;
>a : T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ interface A { // T

a17: {
>a17 : { <T extends Derived>(x: (a: T) => T): T[]; <T_1 extends Base>(x: (a: T_1) => T_1): T_1[]; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

<T extends Derived>(x: (a: T) => T): T[];
>x : (a: T) => T
Expand All @@ -134,7 +134,7 @@ interface A { // T

(x: {
>x : { <T extends Derived>(a: T): T; <T_1 extends Base>(a: T_1): T_1; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

<T extends Derived>(a: T): T;
>a : T
Expand All @@ -147,7 +147,7 @@ interface A { // T
}): any[];
(x: {
>x : { <T extends Derived2>(a: T): T; <T_1 extends Base>(a: T_1): T_1; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^ ^^^^^^^^^^^^^^^^^^ ^^^ ^^^

<T extends Derived2>(a: T): T;
>a : T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var a: {

var a2: {
>a2 : { <T>(x: T): number; <T_1>(x: T_1): string; }
> : ^^^ ^^^^^ ^^^ ^^^ ^^^^^^^^^^^ ^^^
> : ^^^ ^^^^^ ^^^ ^^^ ^^^^^ ^^^ ^^^

<T>(x: T): number;
>x : T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ class Foo<Elements extends readonly unknown[]> {

public readonly elements: { [P in keyof Elements]: { bar: Elements[P] } };
>elements : { [P in keyof Elements]: { bar: Elements[P]; }; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
>bar : Elements[P]
> : ^^^^^^^^^^^

public constructor(
...elements: { [P in keyof Elements]: { bar: Elements[P] } }
>elements : { [P in keyof Elements]: { bar: Elements[P]; }; }
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
>bar : Elements[P]
> : ^^^^^^^^^^^

Expand Down
Loading