You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportinterfaceProperties{propertyA: number;propertyB: string;}exportfunctiongetPropertyValue_Ok(properties: Properties,propertyName: keyofProperties,): Properties[typeofpropertyName]{returnproperties[propertyName];}exportclassA{publicgetPropertyValue_Ok(properties: Properties,propertyName: keyofProperties,): Properties[typeofpropertyName]{returnproperties[propertyName];}// error TS4055: Return type of public method from exported class has or is using private name 'propertyName'.protectedgetPropertyValue_Error(properties: Properties,propertyName: keyofProperties,): Properties[typeofpropertyName]{returnproperties[propertyName];}// error TS4073: Parameter 'propertyValue' of public method from exported class has or is using private name 'propertyName'.protectedsetPropertyValue_Error(properties: Properties,propertyName: keyofProperties,propertyValue: Properties[typeofpropertyName],){// TODO}}
π Actual behavior
The protected methods fail to generate declaration with TS4055 or TS4073.
π Expected behavior
The protected methods should be able to generate declaration similar to the public method or function.
Additional information about the issue
I wonder if there's a way to temporarily suppress this error, becuase ts-ignore doesn't seem to work when generating declaration.
The text was updated successfully, but these errors were encountered:
This is a bug but there's also no reason to write this code in the first place. Doing typeof propertyName doesn't create a generic link between the call and the return type; it's identical to if you had written
This is a bug but there's also no reason to write this code in the first place. Doing typeof propertyName doesn't create a generic link between the call and the return type; it's identical to if you had written
You are absolutely right. The reason I did it was mostly that when my actual interface name for Properties is much longer, writing typeof propertyName makes it shorter.
zhanghai
added a commit
to zhanghai/vnmark-player
that referenced
this issue
Apr 18, 2025
π Search Terms
TS4055 declaration protected return typeof parameter
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.8.3#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgBSgjDRgWAGc4BvAKDjjCJNgE8BBALjiQFcBbAEZoA3PUbNSrAELcKMKMgDmYgL61aoSLDjpeSbGQhI4S4DELEpANUwAbXsAD6AeQDWACnFMrschW5LFjJKABpvSTYAOUx+YG43YFYIdAJIkIpwgEpA9P8AbRhWEhSJXyKYuIBdGnEoc14oEx9ggpapSuAqtQ0taHhsO0wKKnZahjBeQTsEbFNzIJt7R1dPcQm8ylzy-3CGDfLWToSk0sW-MPEctJ3KQuLgUvbo2K7x-fqYRubNinzniqvbridTiAD0YLgaCIUDgABUAMoAFgADABWNHcABKDSacCKJDgTymMzmcRgAAsIAATXREfhQ8D9YC0wbDKgU4ZE2EIKi8CjKCQIABumFQPFecAA5ACjq8pQA6CIQVCGFnzCzpVi2BzOACiUBhXn2ZVaWxuZsy61NHVeJ2SqXOGT2cGuToKBMeqVlnRqdBNn2+Noufx9QLEDFBDAhUMN0HhyJRAHYAMyBTBQV6oWEyrU6xxSonekmzODkqm09D0xnaVCsoYjOCcqjx3lwfmCpgisV4JCS3OHTqK5WqutwCgLPPLfVxqDG-YA-zbS0ug7BOVxe1nX6r4NFfPxC2kD0PJ5a30urLvaOQuEuAAiLhBtHUQA
π» Code
π Actual behavior
The protected methods fail to generate declaration with TS4055 or TS4073.
π Expected behavior
The protected methods should be able to generate declaration similar to the public method or function.
Additional information about the issue
I wonder if there's a way to temporarily suppress this error, becuase ts-ignore doesn't seem to work when generating declaration.
The text was updated successfully, but these errors were encountered: