-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix: suppress TS4055/TS4073 for protected methods using typeof parameter #63222
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
Closed
umeshmore45
wants to merge
3
commits into
microsoft:main
from
umeshmore45:fix/protected-method-typeof-parameter-ts4055-v2
Closed
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
745e209
fix(declaration-emit): suppress TS4055/TS4073 for protected methods u…
umesh-more-cstk c000090
fix(checker): treat typeof parameter as accessible in declaration emit
umesh-more-cstk b7e67fa
fix(checker): narrow accessibility check for typeof parameters in typ…
umesh-more-cstk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/protectedMethodTypeofParameter.d.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| //// [tests/cases/compiler/protectedMethodTypeofParameter.d.ts] //// | ||
|
|
||
| === protectedMethodTypeofParameter.d.ts === | ||
| export interface Properties { | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.d.ts, 0, 0)) | ||
|
|
||
| propertyA: number; | ||
| >propertyA : Symbol(Properties.propertyA, Decl(protectedMethodTypeofParameter.d.ts, 0, 29)) | ||
|
|
||
| propertyB: string; | ||
| >propertyB : Symbol(Properties.propertyB, Decl(protectedMethodTypeofParameter.d.ts, 1, 22)) | ||
| } | ||
| export declare class A { | ||
| >A : Symbol(A, Decl(protectedMethodTypeofParameter.d.ts, 3, 1)) | ||
|
|
||
| getPropertyValue_Ok(properties: Properties, propertyName: keyof Properties): Properties[typeof propertyName]; | ||
| >getPropertyValue_Ok : Symbol(A.getPropertyValue_Ok, Decl(protectedMethodTypeofParameter.d.ts, 4, 24)) | ||
| >properties : Symbol(properties, Decl(protectedMethodTypeofParameter.d.ts, 5, 24)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.d.ts, 0, 0)) | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.d.ts, 5, 47)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.d.ts, 0, 0)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.d.ts, 0, 0)) | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.d.ts, 5, 47)) | ||
|
|
||
| protected getPropertyValue_Protected(properties: Properties, propertyName: keyof Properties): Properties[typeof propertyName]; | ||
| >getPropertyValue_Protected : Symbol(A.getPropertyValue_Protected, Decl(protectedMethodTypeofParameter.d.ts, 5, 113)) | ||
| >properties : Symbol(properties, Decl(protectedMethodTypeofParameter.d.ts, 6, 41)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.d.ts, 0, 0)) | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.d.ts, 6, 64)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.d.ts, 0, 0)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.d.ts, 0, 0)) | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.d.ts, 6, 64)) | ||
|
|
||
| protected setPropertyValue_Protected(properties: Properties, propertyName: keyof Properties, propertyValue: Properties[typeof propertyName]): void; | ||
| >setPropertyValue_Protected : Symbol(A.setPropertyValue_Protected, Decl(protectedMethodTypeofParameter.d.ts, 6, 130)) | ||
| >properties : Symbol(properties, Decl(protectedMethodTypeofParameter.d.ts, 7, 41)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.d.ts, 0, 0)) | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.d.ts, 7, 64)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.d.ts, 0, 0)) | ||
| >propertyValue : Symbol(propertyValue, Decl(protectedMethodTypeofParameter.d.ts, 7, 96)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.d.ts, 0, 0)) | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.d.ts, 7, 64)) | ||
| } | ||
|
|
49 changes: 49 additions & 0 deletions
49
tests/baselines/reference/protectedMethodTypeofParameter.d.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| //// [tests/cases/compiler/protectedMethodTypeofParameter.d.ts] //// | ||
|
|
||
| === protectedMethodTypeofParameter.d.ts === | ||
| export interface Properties { | ||
| propertyA: number; | ||
| >propertyA : number | ||
| > : ^^^^^^ | ||
|
|
||
| propertyB: string; | ||
| >propertyB : string | ||
| > : ^^^^^^ | ||
| } | ||
| export declare class A { | ||
| >A : A | ||
| > : ^ | ||
|
|
||
| getPropertyValue_Ok(properties: Properties, propertyName: keyof Properties): Properties[typeof propertyName]; | ||
| >getPropertyValue_Ok : (properties: Properties, propertyName: keyof Properties) => Properties[typeof propertyName] | ||
| > : ^ ^^ ^^ ^^ ^^^^^ | ||
| >properties : Properties | ||
| > : ^^^^^^^^^^ | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
|
|
||
| protected getPropertyValue_Protected(properties: Properties, propertyName: keyof Properties): Properties[typeof propertyName]; | ||
| >getPropertyValue_Protected : (properties: Properties, propertyName: keyof Properties) => Properties[typeof propertyName] | ||
| > : ^ ^^ ^^ ^^ ^^^^^ | ||
| >properties : Properties | ||
| > : ^^^^^^^^^^ | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
|
|
||
| protected setPropertyValue_Protected(properties: Properties, propertyName: keyof Properties, propertyValue: Properties[typeof propertyName]): void; | ||
| >setPropertyValue_Protected : (properties: Properties, propertyName: keyof Properties, propertyValue: Properties[typeof propertyName]) => void | ||
| > : ^ ^^ ^^ ^^ ^^ ^^ ^^^^^ | ||
| >properties : Properties | ||
| > : ^^^^^^^^^^ | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
| >propertyValue : string | number | ||
| > : ^^^^^^^^^^^^^^^ | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
| } | ||
|
|
61 changes: 61 additions & 0 deletions
61
tests/baselines/reference/protectedMethodTypeofParameter.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| //// [tests/cases/compiler/protectedMethodTypeofParameter.ts] //// | ||
|
|
||
| //// [protectedMethodTypeofParameter.ts] | ||
| export interface Properties { | ||
| propertyA: number; | ||
| propertyB: string; | ||
| } | ||
|
|
||
| export class A { | ||
| public getPropertyValue_Ok( | ||
| properties: Properties, | ||
| propertyName: keyof Properties, | ||
| ): Properties[typeof propertyName] { | ||
| return properties[propertyName]; | ||
| } | ||
|
|
||
| protected getPropertyValue_Protected( | ||
| properties: Properties, | ||
| propertyName: keyof Properties, | ||
| ): Properties[typeof propertyName] { | ||
| return properties[propertyName]; | ||
| } | ||
|
|
||
| protected setPropertyValue_Protected( | ||
| properties: Properties, | ||
| propertyName: keyof Properties, | ||
| propertyValue: Properties[typeof propertyName], | ||
| ): void { | ||
| void properties; | ||
| void propertyName; | ||
| void propertyValue; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| //// [protectedMethodTypeofParameter.js] | ||
| export class A { | ||
| getPropertyValue_Ok(properties, propertyName) { | ||
| return properties[propertyName]; | ||
| } | ||
| getPropertyValue_Protected(properties, propertyName) { | ||
| return properties[propertyName]; | ||
| } | ||
| setPropertyValue_Protected(properties, propertyName, propertyValue) { | ||
| void properties; | ||
| void propertyName; | ||
| void propertyValue; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| //// [protectedMethodTypeofParameter.d.ts] | ||
| export interface Properties { | ||
| propertyA: number; | ||
| propertyB: string; | ||
| } | ||
| export declare class A { | ||
| getPropertyValue_Ok(properties: Properties, propertyName: keyof Properties): Properties[typeof propertyName]; | ||
| protected getPropertyValue_Protected(properties: Properties, propertyName: keyof Properties): Properties[typeof propertyName]; | ||
| protected setPropertyValue_Protected(properties: Properties, propertyName: keyof Properties, propertyValue: Properties[typeof propertyName]): void; | ||
| } |
84 changes: 84 additions & 0 deletions
84
tests/baselines/reference/protectedMethodTypeofParameter.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| //// [tests/cases/compiler/protectedMethodTypeofParameter.ts] //// | ||
|
|
||
| === protectedMethodTypeofParameter.ts === | ||
| export interface Properties { | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.ts, 0, 0)) | ||
|
|
||
| propertyA: number; | ||
| >propertyA : Symbol(Properties.propertyA, Decl(protectedMethodTypeofParameter.ts, 0, 29)) | ||
|
|
||
| propertyB: string; | ||
| >propertyB : Symbol(Properties.propertyB, Decl(protectedMethodTypeofParameter.ts, 1, 20)) | ||
| } | ||
|
|
||
| export class A { | ||
| >A : Symbol(A, Decl(protectedMethodTypeofParameter.ts, 3, 1)) | ||
|
|
||
| public getPropertyValue_Ok( | ||
| >getPropertyValue_Ok : Symbol(A.getPropertyValue_Ok, Decl(protectedMethodTypeofParameter.ts, 5, 16)) | ||
|
|
||
| properties: Properties, | ||
| >properties : Symbol(properties, Decl(protectedMethodTypeofParameter.ts, 6, 29)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.ts, 0, 0)) | ||
|
|
||
| propertyName: keyof Properties, | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.ts, 7, 27)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.ts, 0, 0)) | ||
|
|
||
| ): Properties[typeof propertyName] { | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.ts, 0, 0)) | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.ts, 7, 27)) | ||
|
|
||
| return properties[propertyName]; | ||
| >properties : Symbol(properties, Decl(protectedMethodTypeofParameter.ts, 6, 29)) | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.ts, 7, 27)) | ||
| } | ||
|
|
||
| protected getPropertyValue_Protected( | ||
| >getPropertyValue_Protected : Symbol(A.getPropertyValue_Protected, Decl(protectedMethodTypeofParameter.ts, 11, 3)) | ||
|
|
||
| properties: Properties, | ||
| >properties : Symbol(properties, Decl(protectedMethodTypeofParameter.ts, 13, 39)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.ts, 0, 0)) | ||
|
|
||
| propertyName: keyof Properties, | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.ts, 14, 27)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.ts, 0, 0)) | ||
|
|
||
| ): Properties[typeof propertyName] { | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.ts, 0, 0)) | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.ts, 14, 27)) | ||
|
|
||
| return properties[propertyName]; | ||
| >properties : Symbol(properties, Decl(protectedMethodTypeofParameter.ts, 13, 39)) | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.ts, 14, 27)) | ||
| } | ||
|
|
||
| protected setPropertyValue_Protected( | ||
| >setPropertyValue_Protected : Symbol(A.setPropertyValue_Protected, Decl(protectedMethodTypeofParameter.ts, 18, 3)) | ||
|
|
||
| properties: Properties, | ||
| >properties : Symbol(properties, Decl(protectedMethodTypeofParameter.ts, 20, 39)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.ts, 0, 0)) | ||
|
|
||
| propertyName: keyof Properties, | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.ts, 21, 27)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.ts, 0, 0)) | ||
|
|
||
| propertyValue: Properties[typeof propertyName], | ||
| >propertyValue : Symbol(propertyValue, Decl(protectedMethodTypeofParameter.ts, 22, 35)) | ||
| >Properties : Symbol(Properties, Decl(protectedMethodTypeofParameter.ts, 0, 0)) | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.ts, 21, 27)) | ||
|
|
||
| ): void { | ||
| void properties; | ||
| >properties : Symbol(properties, Decl(protectedMethodTypeofParameter.ts, 20, 39)) | ||
|
|
||
| void propertyName; | ||
| >propertyName : Symbol(propertyName, Decl(protectedMethodTypeofParameter.ts, 21, 27)) | ||
|
|
||
| void propertyValue; | ||
| >propertyValue : Symbol(propertyValue, Decl(protectedMethodTypeofParameter.ts, 22, 35)) | ||
| } | ||
| } | ||
|
|
106 changes: 106 additions & 0 deletions
106
tests/baselines/reference/protectedMethodTypeofParameter.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| //// [tests/cases/compiler/protectedMethodTypeofParameter.ts] //// | ||
|
|
||
| === protectedMethodTypeofParameter.ts === | ||
| export interface Properties { | ||
| propertyA: number; | ||
| >propertyA : number | ||
| > : ^^^^^^ | ||
|
|
||
| propertyB: string; | ||
| >propertyB : string | ||
| > : ^^^^^^ | ||
| } | ||
|
|
||
| export class A { | ||
| >A : A | ||
| > : ^ | ||
|
|
||
| public getPropertyValue_Ok( | ||
| >getPropertyValue_Ok : (properties: Properties, propertyName: keyof Properties) => Properties[typeof propertyName] | ||
| > : ^ ^^ ^^ ^^ ^^^^^ | ||
|
|
||
| properties: Properties, | ||
| >properties : Properties | ||
| > : ^^^^^^^^^^ | ||
|
|
||
| propertyName: keyof Properties, | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
|
|
||
| ): Properties[typeof propertyName] { | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
|
|
||
| return properties[propertyName]; | ||
| >properties[propertyName] : string | number | ||
| > : ^^^^^^^^^^^^^^^ | ||
| >properties : Properties | ||
| > : ^^^^^^^^^^ | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
| } | ||
|
|
||
| protected getPropertyValue_Protected( | ||
| >getPropertyValue_Protected : (properties: Properties, propertyName: keyof Properties) => Properties[typeof propertyName] | ||
| > : ^ ^^ ^^ ^^ ^^^^^ | ||
|
|
||
| properties: Properties, | ||
| >properties : Properties | ||
| > : ^^^^^^^^^^ | ||
|
|
||
| propertyName: keyof Properties, | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
|
|
||
| ): Properties[typeof propertyName] { | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
|
|
||
| return properties[propertyName]; | ||
| >properties[propertyName] : string | number | ||
| > : ^^^^^^^^^^^^^^^ | ||
| >properties : Properties | ||
| > : ^^^^^^^^^^ | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
| } | ||
|
|
||
| protected setPropertyValue_Protected( | ||
| >setPropertyValue_Protected : (properties: Properties, propertyName: keyof Properties, propertyValue: Properties[typeof propertyName]) => void | ||
| > : ^ ^^ ^^ ^^ ^^ ^^ ^^^^^ | ||
|
|
||
| properties: Properties, | ||
| >properties : Properties | ||
| > : ^^^^^^^^^^ | ||
|
|
||
| propertyName: keyof Properties, | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
|
|
||
| propertyValue: Properties[typeof propertyName], | ||
| >propertyValue : string | number | ||
| > : ^^^^^^^^^^^^^^^ | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
|
|
||
| ): void { | ||
| void properties; | ||
| >void properties : undefined | ||
| > : ^^^^^^^^^ | ||
| >properties : Properties | ||
| > : ^^^^^^^^^^ | ||
|
|
||
| void propertyName; | ||
| >void propertyName : undefined | ||
| > : ^^^^^^^^^ | ||
| >propertyName : keyof Properties | ||
| > : ^^^^^^^^^^^^^^^^ | ||
|
|
||
| void propertyValue; | ||
| >void propertyValue : undefined | ||
| > : ^^^^^^^^^ | ||
| >propertyValue : string | number | ||
| > : ^^^^^^^^^^^^^^^ | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| export interface Properties { | ||
| propertyA: number; | ||
| propertyB: string; | ||
| } | ||
| export declare class A { | ||
| getPropertyValue_Ok(properties: Properties, propertyName: keyof Properties): Properties[typeof propertyName]; | ||
| protected getPropertyValue_Protected(properties: Properties, propertyName: keyof Properties): Properties[typeof propertyName]; | ||
| protected setPropertyValue_Protected(properties: Properties, propertyName: keyof Properties, propertyValue: Properties[typeof propertyName]): void; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.