Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TypeScript 3.8 #7263

Closed
sosukesuzuki opened this issue Jan 11, 2020 · 15 comments 路 Fixed by #7631
Closed

Support TypeScript 3.8 #7263

sosukesuzuki opened this issue Jan 11, 2020 · 15 comments 路 Fixed by #7631
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency

Comments

@sosukesuzuki
Copy link
Member

sosukesuzuki commented Jan 11, 2020

TypeScript 3.8 beta has been released!馃帀馃帀
We should support some syntax will be add via TS 3.8.

There are some syntaxes that can support by just (waiting and) updating typescript-estree(e.g. Top Level await), but there seems to be some that need to be supported on the Prettier side.(e.g. Type only imports exports)

New syntax:

  • import type, export type
  • ECMAScript Private Fields
  • export * as ns
@sosukesuzuki sosukesuzuki added the lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) label Jan 11, 2020
@armano2
Copy link
Contributor

armano2 commented Jan 11, 2020

@sosukesuzuki i will take a look at this next week at typescript-estree site

@thorn0
Copy link
Member

thorn0 commented Jan 11, 2020

A relevant Babel issue: babel/babel#10981 (import type in TypeScript)

@simllll
Copy link

simllll commented Feb 21, 2020

1:14 Parsing error: '=' expected.
  > 1 | import type { IAPIJobForUser } from '@hokify/common';

right now prettier does not handle the new syntax, any progress on this? can I support somehow?

@alexander-akait
Copy link
Member

We wait typescript-eslint/typescript-eslint#1465

bors bot added a commit to neo-one-suite/neo-one that referenced this issue Mar 9, 2020
1984: feat(ts): add TS v3.7/3.8 language features r=spencercorwin a=spencercorwin

### Description of the Change

Upgrades Smart-Contract compiler to support new TS language features:

Features from TS v3.7:
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html
- [x] Optional Chaining
- [x] Nullish Coalescing
  - Added in previous TS PR
- [x] Assertion Functions
  - Not supported?
- [x] `never`-Returning Functions
  - No change needed?
- [x] Recursive Type Aliases
- [x] Uncalled Function Checks
  - Should be supported without change from us?

Features from TS v3.8.1-rc:
https://devblogs.microsoft.com/typescript/announcing-typescript-3-8-rc/
- [x] Type-Only Imports and Exports
- [x] ECMAScript Private Fields
- [x] `export * as ns` Syntax
  - Added in previous TS PR
- [x] Top-Level `await`
  - Not supported?

### Test Plan

- All Unit Tests
  - `rush test`
  - `rush e2e`
- Optional Chaining
  - `rush test -t packages/neo-one-smart-contract-compiler/src/__tests__/compile/expression/CallExpressionCompiler.test.ts`
  - `rush test -t packages/neo-one-smart-contract-compiler/src/__tests__/compile/expression/ElementAccessExpressionCompiler.test.ts`
  - `rush test -t packages/neo-one-smart-contract-compiler/src/__tests__/compile/expression/PropertyAccessExpressionCompiler.test.ts`
- Nullish Coalescing
  - `rush test -t packages/neo-one-smart-contract-compiler/src/__tests__/compile/expression/ToNullishBooleanHelper.test.ts`
- Recursive Type Aliases
  - `rush test -t packages/neo-one-smart-contract-compiler/src/__tests__/compile/declaration/TypeAliasDeclarationCompiler.test.ts`
- Type-Only Imports and Exports
  - `rush test -t packages/neo-one-typescript-concatenator/src/__tests__/concatenate.test.ts`
- ECMAScript Private Fields
  - `rush test -t packages/neo-one-smart-contract-compiler/src/__tests__/compile/declaration/ClassDeclarationCompiler.test.ts`
  - `rush test -t packages/neo-one-smart-contract-compiler/src/__tests__/compile/expression/ObjectLiteralExpressionCompiler.test.ts`
- `export * as ns` Syntax
  - `rush test -t packages/neo-one-typescript-concatenator/src/__tests__/concatenate.test.ts`
- Top-Level `await`
  - `rush test -t packages/neo-one-smart-contract-compiler/src/__tests__/compiler/expression/AwaitExpressionCompiler.test.ts`

### Alternate Designs

None.

### Benefits

- We support the latest language features for writing Smart Contracts in TS.

### Possible Drawbacks

- Prettier doesn't support some TS v3.8 syntax yet, so all Prettier checks will fail on the `neo-one-typescript-concatenator` package until they/we update Prettier. They have an issue open for this [here](prettier/prettier#7263). They are waiting for TS 3.8 support in `typescript-eslint` for the new AST [here](typescript-eslint/typescript-eslint#1465). This is easy to ignore for now.
- Possibly unforeseen problems.

### Applicable Issues

#1889 


Co-authored-by: Spencer Corwin <spencercorwin@icloud.com>
@bradzacher
Copy link

bradzacher commented Mar 10, 2020

Update on this:
We're currently blocked waiting for ESTree to merge the AST for both export * as ns and private class members.
The former is accepted, but not yet merged, and the latter is still under discussion; I probably would expect at least a few weeks for it to progress.

However, I did merge typescript-eslint/typescript-eslint#1697 on the weekend, which adds support for import/export type.

Would it be a good idea for prettier to bump the ts-estree version to v2.23.0 to help users in the interim?

@thorn0
Copy link
Member

thorn0 commented Mar 11, 2020

For private fields, I added temporary hacks in #7631. They seem to be good enough for now. Most probably we'll merge it before releasing 2.0.

@bradzacher
Copy link

bradzacher commented Mar 11, 2020

before releasing 2.0.

Do you have a timeline for release of this?
Not rushing, just asking because I have typescript-eslint/typescript-eslint#1698 ready, which adds support for export * as ns, but it's waiting on estree/estree#205.

I've pinged back on the ESTree side of things, so hopefully soon we can the spec merged, and then merge our PR.

If the timeline is a week, then I would say we can't get it merged before then, but if it's a few weeks out then there's probably a good chance that we can.

@thorn0
Copy link
Member

thorn0 commented Mar 11, 2020

Thanks. It's not a blocker. If we release earlier, we'll add export * as ns in 2.0.1.

@bradzacher
Copy link

Update:
estree/estree#205 was merged, so I have merged typescript-eslint/typescript-eslint#1698.
A canary release will be cut shortly, and it will be released to latest Monday morning PST.

@ljharb
Copy link

ljharb commented Mar 11, 2020

Hopefully you鈥檇 add something only in a minor, not a patch ;-)

@thorn0
Copy link
Member

thorn0 commented Mar 11, 2020

@ljharb I could as well write "we'll fix it in 2.0.1". Same thing, but suddenly a patch is okay now. Magic!

@thorn0
Copy link
Member

thorn0 commented Mar 17, 2020

closed by #7764, #7631

@thorn0 thorn0 closed this as completed Mar 17, 2020
@thorn0 thorn0 unpinned this issue Mar 17, 2020
@stnwk
Copy link

stnwk commented Mar 18, 2020

@thorn0 That's great news, thanks! When do you think we'd be able see this in a release?

@BPScott
Copy link
Member

BPScott commented Mar 18, 2020

@stnwk looks like we're getting fairly close to a 2.0 release: #7778

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jun 26, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants