-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Let and const support #904
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 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
873c1df
Add es6 target
mhegazy 778f101
Add basic parsing support for let and const
mhegazy 979d45e
Disallow let and const declarations outside blocks
mhegazy 6f6f4af
Fix line endings
mhegazy cf89f5c
Add binder support for block scoped variable declarations
mhegazy 1dde985
Do not allow use of block-scoped variable before its definition
mhegazy 318575c
Ensure duplicate let/const declarations accross files are reported
mhegazy cffc62a
Report duplicate identifier errors on all locations for merged declar…
mhegazy f5c2740
Flag assignments to a const
mhegazy 82f5fb4
Flag const declarations shodowed by var redeclarations
mhegazy 3e45601
Allow const in for statements
mhegazy 03a100d
Do not allow let and const declarations to be exported from a module
mhegazy 6154923
Fix emitting for const in for loops
mhegazy e15f4e6
Merge branch 'master' into letAndConst
mhegazy 60bb37b
Add language service support for const
mhegazy fd469d6
Fix search for shadowed const declarations by a var declarations to s…
mhegazy 4ef68b9
Respond to code review comments
mhegazy a5a6c6f
Allow const and let declarations to be exported in modules. Also ensu…
mhegazy 0a59cdd
Treat blockScoped variable declarations as a separate category when i…
mhegazy 0e7d8b6
Merge branch 'master' into letAndConst
mhegazy dd5c89d
Update error messages
mhegazy 91f4098
Simplify the binder logic for managing blockScopeContainer
mhegazy d5fe43b
allow let and const declarations in module bodies under labels
mhegazy dd7ca69
Create a new flag for diagnostics 'isEarly' and disable emit if this …
mhegazy 373dc76
respond to code review comments
mhegazy 9353c11
Merge branch 'master' into letAndConst
mhegazy d1858d0
Merge branch 'master' into letAndConst
mhegazy e4a2084
Ensure let and const declarations in labels are parsed correctelly
mhegazy 67c78a2
Only check for collisions with variabels and not properties
mhegazy 51e101c
Merge branch 'master' into letAndConst
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
Next
Next commit
Add es6 target
- Loading branch information
commit 873c1df74b7c7dcba59eaccc1bb4bd4b0da18a35
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| //// [es6-amd.ts] | ||
|
|
||
| class A | ||
| { | ||
| constructor () | ||
| { | ||
|
|
||
| } | ||
|
|
||
| public B() | ||
| { | ||
| return 42; | ||
| } | ||
| } | ||
|
|
||
| //// [es6-amd.js] | ||
| var A = (function () { | ||
| function A() { | ||
| } | ||
| A.prototype.B = function () { | ||
| return 42; | ||
| }; | ||
| return A; | ||
| })(); | ||
| //# sourceMappingURL=es6-amd.js.map | ||
|
|
||
| //// [es6-amd.d.ts] | ||
| declare class A { | ||
| constructor(); | ||
| B(): number; | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| =================================================================== | ||
| JsFile: es6-amd.js | ||
| mapUrl: es6-amd.js.map | ||
| sourceRoot: | ||
| sources: es6-amd.ts | ||
| =================================================================== | ||
| ------------------------------------------------------------------- | ||
| emittedFile:tests/cases/compiler/es6-amd.js | ||
| sourceFile:es6-amd.ts | ||
| ------------------------------------------------------------------- | ||
| >>>var A = (function () { | ||
| 1 > | ||
| 2 >^^^^ | ||
| 3 > ^ | ||
| 4 > ^^^^^^^^^^^^^^-> | ||
| 1 > | ||
| > | ||
| 2 >class | ||
| 3 > A | ||
| 1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) | ||
| 2 >Emitted(1, 5) Source(2, 7) + SourceIndex(0) | ||
| 3 >Emitted(1, 6) Source(2, 8) + SourceIndex(0) | ||
| --- | ||
| >>> function A() { | ||
| 1->^^^^ | ||
| 2 > ^^^^^^^^^ | ||
| 3 > ^ | ||
| 1-> | ||
| >{ | ||
| > | ||
| 2 > | ||
| 3 > A | ||
| 1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) name (A) | ||
| 2 >Emitted(2, 14) Source(2, 7) + SourceIndex(0) name (A) | ||
| 3 >Emitted(2, 15) Source(2, 8) + SourceIndex(0) name (A) | ||
| --- | ||
| >>> } | ||
| 1 >^^^^ | ||
| 2 > ^ | ||
| 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> | ||
| 1 > | ||
| >{ | ||
| > constructor () | ||
| > { | ||
| > | ||
| > | ||
| 2 > } | ||
| 1 >Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) | ||
| 2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) | ||
| --- | ||
| >>> A.prototype.B = function () { | ||
| 1->^^^^ | ||
| 2 > ^^^^^^^^^^^^^ | ||
| 3 > ^^^ | ||
| 1-> | ||
| > | ||
| > public | ||
| 2 > B | ||
| 3 > | ||
| 1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) | ||
| 2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) | ||
| 3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) | ||
| --- | ||
| >>> return 42; | ||
| 1 >^^^^^^^^ | ||
| 2 > ^^^^^^ | ||
| 3 > ^ | ||
| 4 > ^^ | ||
| 5 > ^ | ||
| 1 >public B() | ||
| > { | ||
| > | ||
| 2 > return | ||
| 3 > | ||
| 4 > 42 | ||
| 5 > ; | ||
| 1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) | ||
| 2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) | ||
| 3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) | ||
| 4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) | ||
| 5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) | ||
| --- | ||
| >>> }; | ||
| 1 >^^^^ | ||
| 2 > ^ | ||
| 3 > ^^^^^^^^^-> | ||
| 1 > | ||
| > | ||
| 2 > } | ||
| 1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) | ||
| 2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) | ||
| --- | ||
| >>> return A; | ||
| 1->^^^^ | ||
| 2 > ^^^^^^^^ | ||
| 1-> | ||
| > | ||
| 2 > } | ||
| 1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) | ||
| 2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) | ||
| --- | ||
| >>>})(); | ||
| 1 > | ||
| 2 >^ | ||
| 3 > | ||
| 4 > ^^^^ | ||
| 5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> | ||
| 1 > | ||
| 2 >} | ||
| 3 > | ||
| 4 > class A | ||
| > { | ||
| > constructor () | ||
| > { | ||
| > | ||
| > } | ||
| > | ||
| > public B() | ||
| > { | ||
| > return 42; | ||
| > } | ||
| > } | ||
| 1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) | ||
| 2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) | ||
| 3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) | ||
| 4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) | ||
| --- | ||
| >>>//# sourceMappingURL=es6-amd.js.map |
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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| === tests/cases/compiler/es6-amd.ts === | ||
|
|
||
| class A | ||
| >A : A | ||
| { | ||
| constructor () | ||
| { | ||
|
|
||
| } | ||
|
|
||
| public B() | ||
| >B : () => number | ||
| { | ||
| return 42; | ||
| } | ||
| } |
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.
indentation.
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.
done