mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Merge pull request #8844 from Microsoft/create-symbol-for-assignments-in-javascript-constructors
Symbol for property assignments in Salsa/ES6 constructors
This commit is contained in:
commit
6304d79536
@ -1880,12 +1880,20 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindThisPropertyAssignment(node: BinaryExpression) {
|
||||
// Declare a 'member' in case it turns out the container was an ES5 class
|
||||
if (container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.FunctionDeclaration) {
|
||||
container.symbol.members = container.symbol.members || {};
|
||||
// It's acceptable for multiple 'this' assignments of the same identifier to occur
|
||||
declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property);
|
||||
// Declare a 'member' in case it turns out the container was an ES5 class or ES6 constructor
|
||||
let assignee: Node;
|
||||
if (container.kind === SyntaxKind.FunctionDeclaration || container.kind === SyntaxKind.FunctionDeclaration) {
|
||||
assignee = container;
|
||||
}
|
||||
else if (container.kind === SyntaxKind.Constructor) {
|
||||
assignee = container.parent;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
assignee.symbol.members = assignee.symbol.members || {};
|
||||
// It's acceptable for multiple 'this' assignments of the same identifier to occur
|
||||
declareSymbol(assignee.symbol.members, assignee.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property);
|
||||
}
|
||||
|
||||
function bindPrototypePropertyAssignment(node: BinaryExpression) {
|
||||
|
||||
14
tests/cases/fourslash/renameJsThisProperty03.ts
Normal file
14
tests/cases/fourslash/renameJsThisProperty03.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
////class C {
|
||||
//// constructor(y) {
|
||||
//// this./**/[|x|] = y;
|
||||
//// }
|
||||
////}
|
||||
////var t = new C(12);
|
||||
////t.[|x|] = 11;
|
||||
|
||||
goTo.marker();
|
||||
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
|
||||
14
tests/cases/fourslash/renameJsThisProperty04.ts
Normal file
14
tests/cases/fourslash/renameJsThisProperty04.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
////class C {
|
||||
//// constructor(y) {
|
||||
//// this.[|x|] = y;
|
||||
//// }
|
||||
////}
|
||||
////var t = new C(12);
|
||||
////t./**/[|x|] = 11;
|
||||
|
||||
goTo.marker();
|
||||
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
|
||||
Loading…
x
Reference in New Issue
Block a user