Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Readonly arrays and readonly tuples #437

Closed
aleclarson opened this issue Mar 18, 2019 · 1 comment · Fixed by #440
Closed

Readonly arrays and readonly tuples #437

aleclarson opened this issue Mar 18, 2019 · 1 comment · Fixed by #440

Comments

@aleclarson
Copy link
Contributor

aleclarson commented Mar 18, 2019

Coming in TypeScript 3.4.0 (link)

type A = readonly string[]
type B = readonly [string]

Playground link

@alangpierce
Copy link
Owner

Thanks for flagging! Looks like Babel updated everything on its end ( babel/babel#9502 ) so it should just be a matter of porting over all recent Babel parser changes. (No Sucrase transform changes should be needed since it all falls under the existing "remove all type tokens" rule.)

alangpierce added a commit that referenced this issue Mar 31, 2019
Progress toward #437

Notes about each change:
4e1d6e7ff v7.1.6
🚫 Release only.

a2afb974b Fix parsing typescript function types with destructuring (#9035)
🚫 Already fixed with #278.

445b14148 Better error for disallowed trailing commas/parameters after rest elements (#9046)
🚫 Just error reporting.

e7f0c065c Bump some deps (#9056)
🚫 Nothing to do.

4f16a12c0 Fix bug with parsing TS generic async arrow function (#9055)
🚫 Sucrase seems unaffected by bug.

d2971a195 Fix compatibility between typescript and jsx plugins in interface declarations (#9058)
🚫 Sucrase seems unaffected by bug.

856edbf95 [flow] Allow type casts in array patterns inside arrow parameters (#9069)
🚫 Bug caused by error reporting, doesn't affect Sucrase.

61f2aed5b Disallow await inside arrow functions (#9074)
🚫 Error handling out of scope for Sucrase.

07eaa3c63 Ignore empty fixture directories and fix fixtures in the parser (#9113)
🚫 Test-only.

393283053 Parse non-octals with leading zeros in non strict mode correctly (#9114)
🚫 Sucrase assumes strict mode, so this doesn't apply.

fa9df678a Move tests from babylon to babel-parser and enable one test that works now
🚫 Test-only.

fdc869ce1 Merge pull request #8289 from valtech-nyc/implement-smart-pipeline-in-parser
✅ Almost all logic was for error-reporting and complexity around node creation, but
   I did add # as a valid expression.

282129ea6 v7.2.0
🚫 Release only.

4ca35ef8b Fix running flow on travis and update flow (#9128)
🚫 Types only.

72471aff6 Handle flow comments with leading spaces (#9168)
🚫 Sucrase doesn't do anything special for flow comments.

c1499b13a v7.2.2
🚫 Release only.

5cb38995c Allow keywords to be used in type annotations (#9184)
✅ I also fixed this for TypeScript.

0bb720401 v7.2.3
🚫 Release only.

b5177ce29 babel-parser: typescript: add missing bigint keyword (#9230)
🚫 Test only.

60ffe1d10 parser, smart pipes: Add test for async–await
🚫 Test only.

c586d4e8c parser, smart pipes: Add support for yield in pipeline bodies
🚫 Only validation change, startsExpr was removed from Sucrase.

a58893d1e Ensure modifiers are included in TSParameterProperty ranges (#9276)
🚫 AST only.

e43777bb5 Fix location for typescript type assertions in AST (#9284)
🚫 AST only, wasn't a problem in Sucrase tokens.

03022d169 Throw error if TypeScript class has empty implements (#9292)
🚫 Error handling only.

46e3f6df1 @babel/parser: include leading character into range of generic ArrowFunctionExpression (#9295)
🚫 AST only.

2cc037675 @babel/parser(ts): Add parsing of type import (#9302)
🚫 Already done in #380.

9764718c3 Disallow trailing comma after rest (#9311)
🚫 Error handling only.

5889620a6 Disallow `new import(x)` and `import(x,)` (#9313)
🚫 Error handling only.

3e4b608a8 Parse class heritage as strict mode code (#9315)
🚫 Sucrase is always in strict mode.

694e3fd8c Merge declaration and init of props in parser's state (#9312)
🚫 Refactor that isn't relevant to Sucrase.

e8038863c Fix range on TypeScript this type predicate (#9339)
🚫 AST only.

34c9890f4 Fix range on TypeScript index signature parameters (#9335)
🚫 AST only.

aaec2cd51 Fix handling newline with TypeScript declare and abstract classes (#9328)
✅ Implemented newline checking in various places.

0a88230ec Disallow async functions as loop bodies (#9314)
🚫 Error handling only.

a2e6d8e96 Disallow usage of invalid keyword after export abstract statement in Typescript (#9336)
🚫 Error handling only.

96a734314 Merge pull request #9348 from danez/perf
🚫 Nothing stood out as being valuable to incorporate.

f6ee26c3d v7.3.0
🚫 Release only.

af88e63df fix new keyword broken by recent refactoring (#9377)
🚫 Not relevant in Sucrase.

f2af6c117 v7.3.1
🚫 Release only.

f77c450cd Bump prettier (#9373)
🚫 Tooling only.

65febdd13 Refactor import and export parsing (#9326)
🚫 Skipping refactor for now since it's not clear that I'll need it.

93e1b5e61 Merge pull request #9375 from danez/contextual-let
🚫 Not necessary for strict mode.

8bc9f9a05 fix: Allow toplevel await when option true and correctly mark await keyword as unexpected (#9371)
🚫 Error handling only.

42c5d3fc4 Correctly fail for invalid yield in for (#9398)
🚫 Error handling only.

46ba5940c Make yield a contextual keyword (#9400)
🚫 Not necessary for strict mode.

7dc157f9b Fix location/range on TypeScript ExportNamedDeclarations (#9406)
🚫 AST only.
alangpierce added a commit that referenced this issue Mar 31, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Progress toward #437

Notes about each change:
4e1d6e7ff v7.1.6
🚫 Release only.

a2afb974b Fix parsing typescript function types with destructuring (#9035)
🚫 Already fixed with #278.

445b14148 Better error for disallowed trailing commas/parameters after rest elements (#9046)
🚫 Just error reporting.

e7f0c065c Bump some deps (#9056)
🚫 Nothing to do.

4f16a12c0 Fix bug with parsing TS generic async arrow function (#9055)
🚫 Sucrase seems unaffected by bug.

d2971a195 Fix compatibility between typescript and jsx plugins in interface declarations (#9058)
🚫 Sucrase seems unaffected by bug.

856edbf95 [flow] Allow type casts in array patterns inside arrow parameters (#9069)
🚫 Bug caused by error reporting, doesn't affect Sucrase.

61f2aed5b Disallow await inside arrow functions (#9074)
🚫 Error handling out of scope for Sucrase.

07eaa3c63 Ignore empty fixture directories and fix fixtures in the parser (#9113)
🚫 Test-only.

393283053 Parse non-octals with leading zeros in non strict mode correctly (#9114)
🚫 Sucrase assumes strict mode, so this doesn't apply.

fa9df678a Move tests from babylon to babel-parser and enable one test that works now
🚫 Test-only.

fdc869ce1 Merge pull request #8289 from valtech-nyc/implement-smart-pipeline-in-parser
✅ Almost all logic was for error-reporting and complexity around node creation, but
   I did add # as a valid expression.

282129ea6 v7.2.0
🚫 Release only.

4ca35ef8b Fix running flow on travis and update flow (#9128)
🚫 Types only.

72471aff6 Handle flow comments with leading spaces (#9168)
🚫 Sucrase doesn't do anything special for flow comments.

c1499b13a v7.2.2
🚫 Release only.

5cb38995c Allow keywords to be used in type annotations (#9184)
✅ I also fixed this for TypeScript.

0bb720401 v7.2.3
🚫 Release only.

b5177ce29 babel-parser: typescript: add missing bigint keyword (#9230)
🚫 Test only.

60ffe1d10 parser, smart pipes: Add test for async–await
🚫 Test only.

c586d4e8c parser, smart pipes: Add support for yield in pipeline bodies
🚫 Only validation change, startsExpr was removed from Sucrase.

a58893d1e Ensure modifiers are included in TSParameterProperty ranges (#9276)
🚫 AST only.

e43777bb5 Fix location for typescript type assertions in AST (#9284)
🚫 AST only, wasn't a problem in Sucrase tokens.

03022d169 Throw error if TypeScript class has empty implements (#9292)
🚫 Error handling only.

46e3f6df1 @babel/parser: include leading character into range of generic ArrowFunctionExpression (#9295)
🚫 AST only.

2cc037675 @babel/parser(ts): Add parsing of type import (#9302)
🚫 Already done in #380.

9764718c3 Disallow trailing comma after rest (#9311)
🚫 Error handling only.

5889620a6 Disallow `new import(x)` and `import(x,)` (#9313)
🚫 Error handling only.

3e4b608a8 Parse class heritage as strict mode code (#9315)
🚫 Sucrase is always in strict mode.

694e3fd8c Merge declaration and init of props in parser's state (#9312)
🚫 Refactor that isn't relevant to Sucrase.

e8038863c Fix range on TypeScript this type predicate (#9339)
🚫 AST only.

34c9890f4 Fix range on TypeScript index signature parameters (#9335)
🚫 AST only.

aaec2cd51 Fix handling newline with TypeScript declare and abstract classes (#9328)
✅ Implemented newline checking in various places.

0a88230ec Disallow async functions as loop bodies (#9314)
🚫 Error handling only.

a2e6d8e96 Disallow usage of invalid keyword after export abstract statement in Typescript (#9336)
🚫 Error handling only.

96a734314 Merge pull request #9348 from danez/perf
🚫 Nothing stood out as being valuable to incorporate.

f6ee26c3d v7.3.0
🚫 Release only.

af88e63df fix new keyword broken by recent refactoring (#9377)
🚫 Not relevant in Sucrase.

f2af6c117 v7.3.1
🚫 Release only.

f77c450cd Bump prettier (#9373)
🚫 Tooling only.

65febdd13 Refactor import and export parsing (#9326)
🚫 Skipping refactor for now since it's not clear that I'll need it.

93e1b5e61 Merge pull request #9375 from danez/contextual-let
🚫 Not necessary for strict mode.

8bc9f9a05 fix: Allow toplevel await when option true and correctly mark await keyword as unexpected (#9371)
🚫 Error handling only.

42c5d3fc4 Correctly fail for invalid yield in for (#9398)
🚫 Error handling only.

46ba5940c Make yield a contextual keyword (#9400)
🚫 Not necessary for strict mode.

7dc157f9b Fix location/range on TypeScript ExportNamedDeclarations (#9406)
🚫 AST only.
alangpierce added a commit that referenced this issue Mar 31, 2019
Fixes #437

Details:
828169e61 Fix line continuation with Unicode line terminators (#9403)
🚫 We don't do escape parsing anyway.

4c4c22a31 Run prettier
🚫 Tools only.

00c3e3c8e Fixed link to @babel/parser's issues in README (#9427)
🚫 Docs only.

9eb010da5 Unify reserved word checking and update error messages (#9402)
🚫 Error handling only.

344d35bbe Simplify await and yield tracking in params (#9405)
🚫 Error handling only.

d896ce2b5 v7.3.2
🚫 Release only.

e03e5ba01 Add TypeScript definitions for parser plugin options. (#9457)
🚫 Types only.

07b0f22a3 Fix range for TypeScript optional parameter in arrow function (#9463)
🚫 AST only.

d1514f57b Typescript function destructured params (#9431)
🚫 Already fixed in my code (with a fix that I think is better).

2817844e8 Fix regression with let (#9477)
🚫 This doesn't seem to affect Sucrase.

d349b74a4 Better error output in parser tests (#9491)
🚫 Test only.

4ba998c5d Add importKind to spec
🚫 Types only.

d1fe2d05f v7.3.3
🚫 Release only.

058f05742 Also check AssignmentPatterns for export name (#9521)
🚫 Error handling only.

a1ea765b9 Make tests spec compliant and avoid duplicate declarations in input files (#9522)
🚫 Test only.

dd8b700a2 Parenthesized expressions (#8025)
🚫 New feature that won't go into Sucrase.

9f3457797 Fix TypeScript parsers missing token check (#9571) (#9572)
✅ Added new check with test.

fc1ea7f49 Revert "Parenthesized expressions (#8025)"
🚫 New feature that won't go into Sucrase.

1f6454cc9 v7.3.4
🚫 Release only.

a7391144b Introduce scope tracking in the parser (#9493)
🚫 Looks like this is just for error handling.

e6c1065d1 Fix strict mode prescanning with EmptyStatement (#9585)
🚫 We don't detect strict mode.

d0e196d21 Treat for loop body as part of loop scope (#9586)
🚫 Scopes not tracked in Sucrase in the same way.

0345c1bc1 Use `for..of Object.keys` instead of `for..in` (#9518)
🚫 Not relevant for Sucrase.

244e4580e Remove always false param allowExpressionBody (#9591)
✅ Removed, plus removed some other unnecessary params.

a029071b8 [TS] Correctly forget `await`s after parsing async arrows with type args (#9593)
🚫 Doesn't come up in Sucrase.

e883ff295 Merge pull request #9597 from danez/Update-charcodes
🚫 Mostly just changes in types.

43eed1ac9 Check exported bindings are defined (#9589)
🚫 Error handling only.

5cb280f98 Fix scope check for 2nd+ lexical bindings (#9600)
🚫 Error handling only.

208195f42 Disallow duplicate params in methods (#9599)
🚫 Error handling only.

98ab1b642 Refactor parsing object members (#9607)
🚫 I won't try to port this refactor for now.

f13f4adcb [TS] Disallow type casts in arrow parameters (#9612)
🚫 Error handling only.

17f4195bc Allow any reserved word in `export {} from` specifiers (#9616)
🚫 Already works in Sucrase.

c60c4dd37 Partial Application Syntax: Stage 1 (#9343)
✅ Added basic parsing for ? expression.

d832c0f43 Add parser support for placeholders (#9364)
🚫 I won't include this feature in Sucrase.

54ba6d80c Update identifier parsing per Unicode v12 (#9637)
🚫 Sucrase doesn't need this validation.

29999007f Disallow escape sequences in contextual keywords (#9618)
🚫 We don't support identifier escape sequences in the first place.

fba5655a4 Parenthesized expressions (#8025)
🚫 I won't include this feature in Sucrase.

e53be4b38 [TS] Allow context type annotation on getters/setters (#9641)
🚫 Bug in validation that Sucrase doesn't do.

d8a532983 Reorganize token types and use a map for them (#9645)
🚫 Not really relevant for current Sucrase code.

cf4bd8bb8 Remove input and length from state (#9646)
🚫 Not relevant for Sucrase.

29cd27b54 Partial application plugin (#9474)
🚫 Tests only.

25a3825a1 TypeScript Constant contexts (#9534)
✅ Added test, already works from previous change to make it an identifier.

cc4560842 Add `readonly` to TypeScript type modifier (#9529)
✅ Added new case with test.

48d66eb64 Correctly parse TS TypeAssertions around arrow functions (#9699)
🚫 AST only, I think.

f1328fb91 v7.4.0
🚫 Release only.

ab41cb2cd Fix scope checks with enabled flow plugin (#9719)
🚫 Scope code doesn't exist in Sucrase.

2201fd839 Modules might be in loose mode when checking for undecl exports (#9725)
🚫 Sucrase always uses strict mode.

7dea0f23d v7.4.2
🚫 Release only.

ef0722b4b Fix compatibility between estree and TS plugin (#9700)
🚫 Sucrase doesn't support estree mode.

aaefc83a6 Allow HTML comments on first line (#9760)
🚫 Unclear what this is needed for, but doesn't seem important in Sucrase.

d720c6cff Explicit labels for tokenTypes (#9761)
🚫 Internal change.

444daf922 Optimize parseBindingAtom code to get better error messages (#9762)
🚫 Error checking only.

2867bbf19 [typescript] parsing template literal as type (#9748)
✅ Added new case with test.

7f4427432 Parse right-hand-side of for/of as an assignment expression (#9767)
🚫 Error checking only.

6bc9e7ebd Correctly check for-in and for-of loop for invalid left-hand side (#9768)
🚫 Error checking only.

60d7e940e Fix merge error
🚫 Not relevant to Sucrase.
alangpierce added a commit that referenced this issue Mar 31, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Fixes #437

Details:
828169e61 Fix line continuation with Unicode line terminators (#9403)
🚫 We don't do escape parsing anyway.

4c4c22a31 Run prettier
🚫 Tools only.

00c3e3c8e Fixed link to @babel/parser's issues in README (#9427)
🚫 Docs only.

9eb010da5 Unify reserved word checking and update error messages (#9402)
🚫 Error handling only.

344d35bbe Simplify await and yield tracking in params (#9405)
🚫 Error handling only.

d896ce2b5 v7.3.2
🚫 Release only.

e03e5ba01 Add TypeScript definitions for parser plugin options. (#9457)
🚫 Types only.

07b0f22a3 Fix range for TypeScript optional parameter in arrow function (#9463)
🚫 AST only.

d1514f57b Typescript function destructured params (#9431)
🚫 Already fixed in my code (with a fix that I think is better).

2817844e8 Fix regression with let (#9477)
🚫 This doesn't seem to affect Sucrase.

d349b74a4 Better error output in parser tests (#9491)
🚫 Test only.

4ba998c5d Add importKind to spec
🚫 Types only.

d1fe2d05f v7.3.3
🚫 Release only.

058f05742 Also check AssignmentPatterns for export name (#9521)
🚫 Error handling only.

a1ea765b9 Make tests spec compliant and avoid duplicate declarations in input files (#9522)
🚫 Test only.

dd8b700a2 Parenthesized expressions (#8025)
🚫 New feature that won't go into Sucrase.

9f3457797 Fix TypeScript parsers missing token check (#9571) (#9572)
✅ Added new check with test.

fc1ea7f49 Revert "Parenthesized expressions (#8025)"
🚫 New feature that won't go into Sucrase.

1f6454cc9 v7.3.4
🚫 Release only.

a7391144b Introduce scope tracking in the parser (#9493)
🚫 Looks like this is just for error handling.

e6c1065d1 Fix strict mode prescanning with EmptyStatement (#9585)
🚫 We don't detect strict mode.

d0e196d21 Treat for loop body as part of loop scope (#9586)
🚫 Scopes not tracked in Sucrase in the same way.

0345c1bc1 Use `for..of Object.keys` instead of `for..in` (#9518)
🚫 Not relevant for Sucrase.

244e4580e Remove always false param allowExpressionBody (#9591)
✅ Removed, plus removed some other unnecessary params.

a029071b8 [TS] Correctly forget `await`s after parsing async arrows with type args (#9593)
🚫 Doesn't come up in Sucrase.

e883ff295 Merge pull request #9597 from danez/Update-charcodes
🚫 Mostly just changes in types.

43eed1ac9 Check exported bindings are defined (#9589)
🚫 Error handling only.

5cb280f98 Fix scope check for 2nd+ lexical bindings (#9600)
🚫 Error handling only.

208195f42 Disallow duplicate params in methods (#9599)
🚫 Error handling only.

98ab1b642 Refactor parsing object members (#9607)
🚫 I won't try to port this refactor for now.

f13f4adcb [TS] Disallow type casts in arrow parameters (#9612)
🚫 Error handling only.

17f4195bc Allow any reserved word in `export {} from` specifiers (#9616)
🚫 Already works in Sucrase.

c60c4dd37 Partial Application Syntax: Stage 1 (#9343)
✅ Added basic parsing for ? expression.

d832c0f43 Add parser support for placeholders (#9364)
🚫 I won't include this feature in Sucrase.

54ba6d80c Update identifier parsing per Unicode v12 (#9637)
🚫 Sucrase doesn't need this validation.

29999007f Disallow escape sequences in contextual keywords (#9618)
🚫 We don't support identifier escape sequences in the first place.

fba5655a4 Parenthesized expressions (#8025)
🚫 I won't include this feature in Sucrase.

e53be4b38 [TS] Allow context type annotation on getters/setters (#9641)
🚫 Bug in validation that Sucrase doesn't do.

d8a532983 Reorganize token types and use a map for them (#9645)
🚫 Not really relevant for current Sucrase code.

cf4bd8bb8 Remove input and length from state (#9646)
🚫 Not relevant for Sucrase.

29cd27b54 Partial application plugin (#9474)
🚫 Tests only.

25a3825a1 TypeScript Constant contexts (#9534)
✅ Added test, already works from previous change to make it an identifier.

cc4560842 Add `readonly` to TypeScript type modifier (#9529)
✅ Added new case with test.

48d66eb64 Correctly parse TS TypeAssertions around arrow functions (#9699)
🚫 AST only, I think.

f1328fb91 v7.4.0
🚫 Release only.

ab41cb2cd Fix scope checks with enabled flow plugin (#9719)
🚫 Scope code doesn't exist in Sucrase.

2201fd839 Modules might be in loose mode when checking for undecl exports (#9725)
🚫 Sucrase always uses strict mode.

7dea0f23d v7.4.2
🚫 Release only.

ef0722b4b Fix compatibility between estree and TS plugin (#9700)
🚫 Sucrase doesn't support estree mode.

aaefc83a6 Allow HTML comments on first line (#9760)
🚫 Unclear what this is needed for, but doesn't seem important in Sucrase.

d720c6cff Explicit labels for tokenTypes (#9761)
🚫 Internal change.

444daf922 Optimize parseBindingAtom code to get better error messages (#9762)
🚫 Error checking only.

2867bbf19 [typescript] parsing template literal as type (#9748)
✅ Added new case with test.

7f4427432 Parse right-hand-side of for/of as an assignment expression (#9767)
🚫 Error checking only.

6bc9e7ebd Correctly check for-in and for-of loop for invalid left-hand side (#9768)
🚫 Error checking only.

60d7e940e Fix merge error
🚫 Not relevant to Sucrase.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants