π Search Terms
binding element alias declaration files
π Version & Regression Information
- This changed between versions 4.7 and 4.8
β― Playground Link
https://www.typescriptlang.org/play?ts=5.2.2#code/PTAEhRyUFgCgVAygCwPYFcA2ATUA7FALqAEYCmoA1qQA5ECGuOAlgM6gBOpAtigG6lZYAMzS4AxgSYpcoFqkxYAcoQDSpGqAAUAbzx0upAFyg6GJnTYBfY7tz6jsguya4A5qEsBKUNtih-0DCWsLDwgDLkoWAAgmYWoKygaCwC8TIESOQi4pLSJGhE+EQuoOnkLEyudgRonJGI8th4hCTkVLSpoFikYhh07HQ5uGxxTEXDMkxc1BjcpLgEA1IyXQtMGHUsAJ5cxCgYAHSsAEqkQqSc4ikJSSkA7khMYkigT90UbJxnF2Kk45v351I+2EogkS1kDSUqnU1AAQvkAJIsNTtHR6AzGUzmKw2dEOFhOFzuLy+GABDikarsGRYiywYIwOrgOoAVWSzBknCpaU21HImjE6EafNA1D69gI5zYBF5vxMbFupAwGG8LBQ8SIciFODIlBoBBB2XBWrQWAwag0aLsGJMsRxPjxxgJzjcHk8xhlfJQQlt2J8fgCXJqNLt9KAA
π» Code
// β
// Should not be kept and is removed
function shouldNotKeep ({ name: alias }: { name: string }) {
}
// β
// Alias is used in the function but not in the signature
// Should not be kept in declarations as it is an implementation detail
// symbol.isReferenced is used which checks references anywhere.
function shouldNotKeepButIsKept ({ name: alias }: { name: string }){
return alias
}
// β
// Used in return type (could pe parameters types as well) so it should be kept
function shoudlKeep ({ name: alias }: { name: string }): typeof alias {
return alias
}
π Actual behavior
alias is kept in declaration files for shouldNotKeepButIsKept
π Expected behavior
Either alias is removed from declaration file for shouldNotKeepButIsKept, or alias is also kept for shouldNotKeep.
Additional information about the issue
Seems like declaration emit is using isReferenced of the symbol. But this tracks usage of the symbol anywhere in the scope, we would need usage of the symbol in the function signature.
π Search Terms
binding element alias declaration files
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.2.2#code/PTAEhRyUFgCgVAygCwPYFcA2ATUA7FALqAEYCmoA1qQA5ECGuOAlgM6gBOpAtigG6lZYAMzS4AxgSYpcoFqkxYAcoQDSpGqAAUAbzx0upAFyg6GJnTYBfY7tz6jsguya4A5qEsBKUNtih-0DCWsLDwgDLkoWAAgmYWoKygaCwC8TIESOQi4pLSJGhE+EQuoOnkLEyudgRonJGI8th4hCTkVLSpoFikYhh07HQ5uGxxTEXDMkxc1BjcpLgEA1IyXQtMGHUsAJ5cxCgYAHSsAEqkQqSc4ikJSSkA7khMYkigT90UbJxnF2Kk45v351I+2EogkS1kDSUqnU1AAQvkAJIsNTtHR6AzGUzmKw2dEOFhOFzuLy+GABDikarsGRYiywYIwOrgOoAVWSzBknCpaU21HImjE6EafNA1D69gI5zYBF5vxMbFupAwGG8LBQ8SIciFODIlBoBBB2XBWrQWAwag0aLsGJMsRxPjxxgJzjcHk8xhlfJQQlt2J8fgCXJqNLt9KAA
π» Code
π Actual behavior
aliasis kept in declaration files forshouldNotKeepButIsKeptπ Expected behavior
Either
aliasis removed from declaration file forshouldNotKeepButIsKept, oraliasis also kept forshouldNotKeep.Additional information about the issue
Seems like declaration emit is using
isReferencedof the symbol. But this tracks usage of the symbol anywhere in the scope, we would need usage of the symbol in the function signature.