-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test case for property used in destructuring variable declaration
- Loading branch information
1 parent
7b34b61
commit 116c878
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,18 @@ | ||
tests/cases/compiler/unusedLocalProperty.ts(3,25): error TS6138: Property 'species' is declared but never used. | ||
|
||
|
||
==== tests/cases/compiler/unusedLocalProperty.ts (1 errors) ==== | ||
declare var console: { log(msg: any): void; } | ||
class Animal { | ||
constructor(private species: string) { | ||
~~~~~~~ | ||
!!! error TS6138: Property 'species' is declared but never used. | ||
} | ||
|
||
printSpecies() { | ||
let { species } = this; | ||
console.log(species); | ||
} | ||
} | ||
|
||
|
This file contains 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,25 @@ | ||
//// [unusedLocalProperty.ts] | ||
declare var console: { log(msg: any): void; } | ||
class Animal { | ||
constructor(private species: string) { | ||
} | ||
|
||
printSpecies() { | ||
let { species } = this; | ||
console.log(species); | ||
} | ||
} | ||
|
||
|
||
|
||
//// [unusedLocalProperty.js] | ||
var Animal = (function () { | ||
function Animal(species) { | ||
this.species = species; | ||
} | ||
Animal.prototype.printSpecies = function () { | ||
var species = this.species; | ||
console.log(species); | ||
}; | ||
return Animal; | ||
}()); |
This file contains 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,12 @@ | ||
//@noUnusedLocals:true | ||
declare var console: { log(msg: any): void; } | ||
class Animal { | ||
constructor(private species: string) { | ||
} | ||
|
||
printSpecies() { | ||
let { species } = this; | ||
console.log(species); | ||
} | ||
} | ||
|