Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not remove binding alias in function declarations
- Loading branch information
1 parent
8179321
commit 17b28da
Showing
16 changed files
with
522 additions
and
468 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
43 changes: 43 additions & 0 deletions
43
tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.js
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,43 @@ | ||
//// [tests/cases/compiler/declarationEmitBindingPatternsFunctionExpr.ts] //// | ||
|
||
//// [declarationEmitBindingPatternsFunctionExpr.ts] | ||
type Named = { name: string } | ||
// Tempting to remove alias if unused | ||
let notReferenced = ({ name: alias }: Named) => { } | ||
|
||
// Resons we can't remove aliases that are not used in the function signature: | ||
|
||
// 1.Causes duplicate identifier if we remove alias | ||
const duplicateIndetifiers = ({ name: alias, name: alias2 }: Named) => { } | ||
const duplicateIndetifiers2 = (name: string, { name: alias }: Named) => { } | ||
const duplicateIndetifiers3 = ({ name: alias }: Named, { name: alias2 }: Named) => { } | ||
|
||
let value = ""; | ||
// 2.Can change in meaning for typeof value if we remove alias | ||
const shadowedVariable = ({ value: alias }: { value: string }): typeof value => value; | ||
|
||
//// [declarationEmitBindingPatternsFunctionExpr.js] | ||
// Tempting to remove alias if unused | ||
let notReferenced = ({ name: alias }) => { }; | ||
// Resons we can't remove aliases that are not used in the function signature: | ||
// 1.Causes duplicate identifier if we remove alias | ||
const duplicateIndetifiers = ({ name: alias, name: alias2 }) => { }; | ||
const duplicateIndetifiers2 = (name, { name: alias }) => { }; | ||
const duplicateIndetifiers3 = ({ name: alias }, { name: alias2 }) => { }; | ||
let value = ""; | ||
// 2.Can change in meaning for typeof value if we remove alias | ||
const shadowedVariable = ({ value: alias }) => value; | ||
|
||
|
||
//// [declarationEmitBindingPatternsFunctionExpr.d.ts] | ||
type Named = { | ||
name: string; | ||
}; | ||
declare let notReferenced: ({ name: alias }: Named) => void; | ||
declare const duplicateIndetifiers: ({ name: alias, name: alias2 }: Named) => void; | ||
declare const duplicateIndetifiers2: (name: string, { name: alias }: Named) => void; | ||
declare const duplicateIndetifiers3: ({ name: alias }: Named, { name: alias2 }: Named) => void; | ||
declare let value: string; | ||
declare const shadowedVariable: ({ value: alias }: { | ||
value: string; | ||
}) => typeof value; |
53 changes: 53 additions & 0 deletions
53
tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.symbols
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,53 @@ | ||
//// [tests/cases/compiler/declarationEmitBindingPatternsFunctionExpr.ts] //// | ||
|
||
=== declarationEmitBindingPatternsFunctionExpr.ts === | ||
type Named = { name: string } | ||
>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) | ||
>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) | ||
|
||
// Tempting to remove alias if unused | ||
let notReferenced = ({ name: alias }: Named) => { } | ||
>notReferenced : Symbol(notReferenced, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 2, 3)) | ||
>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) | ||
>alias : Symbol(alias, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 2, 22)) | ||
>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) | ||
|
||
// Resons we can't remove aliases that are not used in the function signature: | ||
|
||
// 1.Causes duplicate identifier if we remove alias | ||
const duplicateIndetifiers = ({ name: alias, name: alias2 }: Named) => { } | ||
>duplicateIndetifiers : Symbol(duplicateIndetifiers, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 7, 5)) | ||
>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) | ||
>alias : Symbol(alias, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 7, 31)) | ||
>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) | ||
>alias2 : Symbol(alias2, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 7, 44)) | ||
>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) | ||
|
||
const duplicateIndetifiers2 = (name: string, { name: alias }: Named) => { } | ||
>duplicateIndetifiers2 : Symbol(duplicateIndetifiers2, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 8, 5)) | ||
>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 8, 31)) | ||
>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) | ||
>alias : Symbol(alias, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 8, 46)) | ||
>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) | ||
|
||
const duplicateIndetifiers3 = ({ name: alias }: Named, { name: alias2 }: Named) => { } | ||
>duplicateIndetifiers3 : Symbol(duplicateIndetifiers3, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 9, 5)) | ||
>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) | ||
>alias : Symbol(alias, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 9, 32)) | ||
>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) | ||
>name : Symbol(name, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 14)) | ||
>alias2 : Symbol(alias2, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 9, 56)) | ||
>Named : Symbol(Named, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 0, 0)) | ||
|
||
let value = ""; | ||
>value : Symbol(value, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 11, 3)) | ||
|
||
// 2.Can change in meaning for typeof value if we remove alias | ||
const shadowedVariable = ({ value: alias }: { value: string }): typeof value => value; | ||
>shadowedVariable : Symbol(shadowedVariable, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 13, 5)) | ||
>value : Symbol(value, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 13, 45)) | ||
>alias : Symbol(alias, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 13, 27)) | ||
>value : Symbol(value, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 13, 45)) | ||
>value : Symbol(value, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 11, 3)) | ||
>value : Symbol(value, Decl(declarationEmitBindingPatternsFunctionExpr.ts, 11, 3)) | ||
|
54 changes: 54 additions & 0 deletions
54
tests/baselines/reference/declarationEmitBindingPatternsFunctionExpr.types
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,54 @@ | ||
//// [tests/cases/compiler/declarationEmitBindingPatternsFunctionExpr.ts] //// | ||
|
||
=== declarationEmitBindingPatternsFunctionExpr.ts === | ||
type Named = { name: string } | ||
>Named : { name: string; } | ||
>name : string | ||
|
||
// Tempting to remove alias if unused | ||
let notReferenced = ({ name: alias }: Named) => { } | ||
>notReferenced : ({ name: alias }: Named) => void | ||
>({ name: alias }: Named) => { } : ({ name: alias }: Named) => void | ||
>name : any | ||
>alias : string | ||
|
||
// Resons we can't remove aliases that are not used in the function signature: | ||
|
||
// 1.Causes duplicate identifier if we remove alias | ||
const duplicateIndetifiers = ({ name: alias, name: alias2 }: Named) => { } | ||
>duplicateIndetifiers : ({ name: alias, name: alias2 }: Named) => void | ||
>({ name: alias, name: alias2 }: Named) => { } : ({ name: alias, name: alias2 }: Named) => void | ||
>name : any | ||
>alias : string | ||
>name : any | ||
>alias2 : string | ||
|
||
const duplicateIndetifiers2 = (name: string, { name: alias }: Named) => { } | ||
>duplicateIndetifiers2 : (name: string, { name: alias }: Named) => void | ||
>(name: string, { name: alias }: Named) => { } : (name: string, { name: alias }: Named) => void | ||
>name : string | ||
>name : any | ||
>alias : string | ||
|
||
const duplicateIndetifiers3 = ({ name: alias }: Named, { name: alias2 }: Named) => { } | ||
>duplicateIndetifiers3 : ({ name: alias }: Named, { name: alias2 }: Named) => void | ||
>({ name: alias }: Named, { name: alias2 }: Named) => { } : ({ name: alias }: Named, { name: alias2 }: Named) => void | ||
>name : any | ||
>alias : string | ||
>name : any | ||
>alias2 : string | ||
|
||
let value = ""; | ||
>value : string | ||
>"" : "" | ||
|
||
// 2.Can change in meaning for typeof value if we remove alias | ||
const shadowedVariable = ({ value: alias }: { value: string }): typeof value => value; | ||
>shadowedVariable : ({ value: alias }: { value: string;}) => typeof value | ||
>({ value: alias }: { value: string }): typeof value => value : ({ value: alias }: { value: string;}) => typeof value | ||
>value : any | ||
>alias : string | ||
>value : string | ||
>value : string | ||
>value : 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
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
Oops, something went wrong.