-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for class method default parameters that use 'this'
- Loading branch information
1 parent
75ce770
commit b9e64d7
Showing
4 changed files
with
36 additions
and
1 deletion.
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,2 @@ | ||
[options] | ||
no_flowlib=false |
8 changes: 8 additions & 0 deletions
8
tests/class_method_default_parameters/class_method_default_parameters.exp
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,8 @@ | ||
class_method_default_parameters.js:17 | ||
17: h(i: number = this.b) { // error | ||
^^^^^^ string. This type is incompatible with | ||
17: h(i: number = this.b) { // error | ||
^^^^^^ number | ||
|
||
|
||
Found 1 error |
21 changes: 21 additions & 0 deletions
21
tests/class_method_default_parameters/class_method_default_parameters.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,21 @@ | ||
class A { | ||
|
||
b: string; | ||
|
||
c(d = this.b) { // ok - can use `this` in function default parameter values | ||
|
||
} | ||
|
||
e() { | ||
return this.b; | ||
} | ||
|
||
f(g = this.e()) { // ok - can use `this` in function default parameter values | ||
|
||
} | ||
|
||
h(i: number = this.b) { // error | ||
|
||
} | ||
|
||
} |