-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Function and class properties #13648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b8329a0
basic support for declaring properties on funcitons
mhegazy 39b3ecb
Handel defining properties on function and class expressions in .js f…
mhegazy e8a2173
Use variable name for class and function expressions names
mhegazy 793d8be
Check for undefined symbols
mhegazy 1eb7b91
Merge branch 'master' of https://github.com/Microsoft/TypeScript
mhegazy 67957f0
Merge branch 'master' into functionAndClassProperties
mhegazy 4b8396b
Merge branch 'master' into functionAndClassProperties
mhegazy 0aa8a6e
Consolidate bindProperty logic in one function
mhegazy 90eef89
accept baseline change
mhegazy db0e376
Merge remote-tracking branch 'origin/master' into functionAndClassPro…
mhegazy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -1402,10 +1402,10 @@ namespace ts { | |
* Returns true if the node is a variable declaration whose initializer is a function expression. | ||
* This function does not test if the node is in a JavaScript file or not. | ||
*/ | ||
export function isDeclarationOfFunctionExpression(s: Symbol) { | ||
export function isDeclarationOfFunctionOrClassExpression(s: Symbol) { | ||
if (s.valueDeclaration && s.valueDeclaration.kind === SyntaxKind.VariableDeclaration) { | ||
const declaration = s.valueDeclaration as VariableDeclaration; | ||
return declaration.initializer && declaration.initializer.kind === SyntaxKind.FunctionExpression; | ||
return declaration.initializer && (declaration.initializer.kind === SyntaxKind.FunctionExpression || declaration.initializer.kind === SyntaxKind.ClassExpression); | ||
} | ||
return false; | ||
} | ||
|
@@ -1434,6 +1434,10 @@ namespace ts { | |
// module.exports = expr | ||
return SpecialPropertyAssignmentKind.ModuleExports; | ||
} | ||
else { | ||
// F.x = expr | ||
return SpecialPropertyAssignmentKind.Property; | ||
} | ||
} | ||
else if (lhs.expression.kind === SyntaxKind.ThisKeyword) { | ||
return SpecialPropertyAssignmentKind.ThisProperty; | ||
|
@@ -1453,6 +1457,7 @@ namespace ts { | |
} | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't need this extra whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope |
||
return SpecialPropertyAssignmentKind.None; | ||
} | ||
|
||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
=== tests/cases/conformance/classes/classExpressions/classExpression4.ts === | ||
let C = class { | ||
>C : typeof (Anonymous class) | ||
>class { foo() { return new C(); }} : typeof (Anonymous class) | ||
>C : typeof C | ||
>class { foo() { return new C(); }} : typeof C | ||
|
||
foo() { | ||
>foo : () => (Anonymous class) | ||
>foo : () => C | ||
|
||
return new C(); | ||
>new C() : (Anonymous class) | ||
>C : typeof (Anonymous class) | ||
>new C() : C | ||
>C : typeof C | ||
} | ||
}; | ||
let x = (new C).foo(); | ||
>x : (Anonymous class) | ||
>(new C).foo() : (Anonymous class) | ||
>(new C).foo : () => (Anonymous class) | ||
>(new C) : (Anonymous class) | ||
>new C : (Anonymous class) | ||
>C : typeof (Anonymous class) | ||
>foo : () => (Anonymous class) | ||
>x : C | ||
>(new C).foo() : C | ||
>(new C).foo : () => C | ||
>(new C) : C | ||
>new C : C | ||
>C : typeof C | ||
>foo : () => C | ||
|
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is not updated on line 1402
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.