Skip to content
Open
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
2 changes: 1 addition & 1 deletion tsc/internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7511,7 +7511,7 @@ func (c *Checker) isUnreferencedTypeParameter(typeParameter *ast.Node) bool {

func (c *Checker) checkUnusedRenamedBindingElements() {
for _, node := range c.renamedBindingElementsInTypes {
if c.symbolReferenceLinks.Get(c.getSymbolOfDeclaration(node)).referenceKinds == 0 {
if c.symbolReferenceLinks.Get(c.getSymbolOfDeclaration(node)).referenceKinds&ast.SymbolFlagsVariable == 0 {
wrappingDeclaration := ast.WalkUpBindingElementsAndPatterns(node)
debug.Assert(ast.IsPartOfParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here")
diagnostic := NewDiagnosticForNode(node.Name(), diagnostics.X_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation, scanner.DeclarationNameToString(node.Name()), scanner.DeclarationNameToString(node.PropertyName()))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
renamingDestructuredPropertyInFunctionType4.ts(1,19): error TS2842: 'A' is an unused renaming of 'a'. Did you intend to use it as a type annotation?
renamingDestructuredPropertyInFunctionType4.ts(2,16): error TS2842: 'A' is an unused renaming of 'a'. Did you intend to use it as a type annotation?
renamingDestructuredPropertyInFunctionType4.ts(4,20): error TS2842: 'A' is an unused renaming of 'a'. Did you intend to use it as a type annotation?
renamingDestructuredPropertyInFunctionType4.ts(6,20): error TS2842: 'A' is an unused renaming of 'a'. Did you intend to use it as a type annotation?
renamingDestructuredPropertyInFunctionType4.ts(8,24): error TS2842: 'A' is an unused renaming of 'a'. Did you intend to use it as a type annotation?


==== renamingDestructuredPropertyInFunctionType4.ts (5 errors) ====
const f0: <A>({a: A}: {a: A}) => void = () => {};
~
!!! error TS2842: 'A' is an unused renaming of 'a'. Did you intend to use it as a type annotation?
const f1: ({a: A}: {a: number}) => void = () => {};
~
!!! error TS2842: 'A' is an unused renaming of 'a'. Did you intend to use it as a type annotation?

type F1 = <A>({ a: A }: { a: A }) => A;
~
!!! error TS2842: 'A' is an unused renaming of 'a'. Did you intend to use it as a type annotation?
type F2 = <A>({ a: A }: { a: A }) => typeof A;
type F3 = <A>({ a: A }: { a: A }) => <A>(value: A) => A;
~
!!! error TS2842: 'A' is an unused renaming of 'a'. Did you intend to use it as a type annotation?
type F4 = <A>({ a: A }: { a: A }) => <A>(value: A) => typeof A;
type F5 = new <A>({ a: A }: { a: A }) => A;
~
!!! error TS2842: 'A' is an unused renaming of 'a'. Did you intend to use it as a type annotation?

function f2<A>({ a: A }: { a: A }) { return A; }
function f3<A>({ a: A }: { a: A }): A { return null!; }

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @noEmit: true
// @noTypesAndSymbols: true
const f0: <A>({a: A}: {a: A}) => void = () => {};
const f1: ({a: A}: {a: number}) => void = () => {};

type F1 = <A>({ a: A }: { a: A }) => A;
type F2 = <A>({ a: A }: { a: A }) => typeof A;
type F3 = <A>({ a: A }: { a: A }) => <A>(value: A) => A;
type F4 = <A>({ a: A }: { a: A }) => <A>(value: A) => typeof A;
type F5 = new <A>({ a: A }: { a: A }) => A;

function f2<A>({ a: A }: { a: A }) { return A; }
function f3<A>({ a: A }: { a: A }): A { return null!; }