forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request microsoft#11998 from Microsoft/unusedProperty
Mark property referenced in the destructuring as referenced
- Loading branch information
Showing
5 changed files
with
113 additions
and
11 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
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,29 @@ | ||
=== tests/cases/compiler/unusedLocalProperty.ts === | ||
declare var console: { log(msg: any): void; } | ||
>console : Symbol(console, Decl(unusedLocalProperty.ts, 0, 11)) | ||
>log : Symbol(log, Decl(unusedLocalProperty.ts, 0, 22)) | ||
>msg : Symbol(msg, Decl(unusedLocalProperty.ts, 0, 27)) | ||
|
||
class Animal { | ||
>Animal : Symbol(Animal, Decl(unusedLocalProperty.ts, 0, 45)) | ||
|
||
constructor(private species: string) { | ||
>species : Symbol(Animal.species, Decl(unusedLocalProperty.ts, 2, 16)) | ||
} | ||
|
||
printSpecies() { | ||
>printSpecies : Symbol(Animal.printSpecies, Decl(unusedLocalProperty.ts, 3, 5)) | ||
|
||
let { species } = this; | ||
>species : Symbol(species, Decl(unusedLocalProperty.ts, 6, 13)) | ||
>this : Symbol(Animal, Decl(unusedLocalProperty.ts, 0, 45)) | ||
|
||
console.log(species); | ||
>console.log : Symbol(log, Decl(unusedLocalProperty.ts, 0, 22)) | ||
>console : Symbol(console, Decl(unusedLocalProperty.ts, 0, 11)) | ||
>log : Symbol(log, Decl(unusedLocalProperty.ts, 0, 22)) | ||
>species : Symbol(species, Decl(unusedLocalProperty.ts, 6, 13)) | ||
} | ||
} | ||
|
||
|
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,30 @@ | ||
=== tests/cases/compiler/unusedLocalProperty.ts === | ||
declare var console: { log(msg: any): void; } | ||
>console : { log(msg: any): void; } | ||
>log : (msg: any) => void | ||
>msg : any | ||
|
||
class Animal { | ||
>Animal : Animal | ||
|
||
constructor(private species: string) { | ||
>species : string | ||
} | ||
|
||
printSpecies() { | ||
>printSpecies : () => void | ||
|
||
let { species } = this; | ||
>species : string | ||
>this : this | ||
|
||
console.log(species); | ||
>console.log(species) : void | ||
>console.log : (msg: any) => void | ||
>console : { log(msg: any): void; } | ||
>log : (msg: any) => void | ||
>species : string | ||
} | ||
} | ||
|
||
|
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); | ||
} | ||
} | ||
|