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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript 4.0 Syntax Support #2260

Closed
bradzacher opened this issue Jun 26, 2020 · 17 comments
Closed

TypeScript 4.0 Syntax Support #2260

bradzacher opened this issue Jun 26, 2020 · 17 comments
Labels
AST PRs and Issues about the AST structure dependencies Issue about dependencies of the package New TypeScript Version package: typescript-estree Issues related to @typescript-eslint/typescript-estree

Comments

@bradzacher
Copy link
Member

bradzacher commented Jun 26, 2020

https://devblogs.microsoft.com/typescript/announcing-typescript-4-0-beta/

Variadic Tuple Types (Supported)

type Strings = [string, string];
type Numbers = number[]

// [string, string, ...Array<number | boolean>]
type Unbounded = [...Strings, ...Numbers, boolean];

This is already supported at the AST level - this is a type functionality change only.

Labelled Tuple Elements (Supported #2378)

type Foo = [first: number, second?: string, ...rest: any[]];

This requires AST updates.

Short-Circuiting Assignment Operators (Supported #2307)

// "Or Or Equals" (or, the Mallet operator :wink:)
a ||= b;

// "And And Equals"
a &&= b;

// "QQ Equals"
a ??= b;

This requires AST updates.
AST: estree/estree#212

unknown on catch Clause Bindings (Supported #2306)

try {
    // ...
}
catch (e: unknown) {
    // ...
}

This requires AST updates

@bradzacher bradzacher added enhancement New feature or request package: typescript-estree Issues related to @typescript-eslint/typescript-estree dependencies Issue about dependencies of the package labels Jun 26, 2020
@bradzacher bradzacher pinned this issue Jun 29, 2020
@phiresky
Copy link
Contributor

phiresky commented Jun 30, 2020

Support for the catch (e: unknown) syntax is in #2202 (together with a lint to enforce it)

@felixfbecker
Copy link

unknown on catch Clause Bindings

This would be awesome to have an ESLint rule for to require it! The TS team even alluded to that in their announcement :)

@felixfbecker
Copy link

With that it probably also makes sense to add a rule to enforce the same for Promise .catch() handlers

@bradzacher bradzacher added the breaking change This change will require a new major version to be released label Jul 19, 2020
@bradzacher bradzacher added this to the 4.0.0 milestone Jul 19, 2020
@bradzacher bradzacher added AST PRs and Issues about the AST structure and removed enhancement New feature or request breaking change This change will require a new major version to be released labels Aug 5, 2020
@bradzacher bradzacher removed this from the 4.0.0 milestone Aug 5, 2020
@bradzacher bradzacher unpinned this issue Aug 9, 2020
@bradennapier
Copy link

If v4.0 is live - should the docs be updated? They still say that it only supports TypeScript < 3.10.0

@bradzacher bradzacher linked a pull request Aug 18, 2020 that will close this issue
@bradzacher bradzacher removed a link to a pull request Aug 18, 2020
@tilgovi
Copy link

tilgovi commented Aug 18, 2020

@bradennapier still only v4.0.0-rc, not stable release yet.

@bradennapier
Copy link

bradennapier commented Aug 18, 2020

@bradennapier still only v4.0.0-rc, not stable release yet.

Sweet, thanks! Well the docs on that branch I think still say the support is for < 3.10.0 if i am not mistaken ;-) - just one easy to overlook thing to double check!

Thanks!

@bradzacher
Copy link
Member Author

bradzacher commented Aug 18, 2020

Whilst we support the syntax, we don't officially mark ourselves as supporting the beta/rc versions.
https://github.com/typescript-eslint/typescript-eslint#supported-typescript-version

This release required minimal changes to support, so we were luckily able to add full support ahead of time. 3.9 was similar in that it required no changes, but we waited for the full release before bumping. 3.8 we still don't have full support for because we're waiting on the AST spec for private class members.

Note that our v4 release is entirely unrelated to TS v4 release (I wasn't supposed to link that PR, I wasn't thinking and confused myself).

When TS v4.0 officially releases, there may be some changes since the RC that we need to handle, so we have to wait until it is released before we update all of the docs and version ranges.

@pattrickrice
Copy link

checking in here since I'm doing an upgrade right now and see the warnings from this package in my console
https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/

@bradzacher
Copy link
Member Author

Well yeah, TS4.0 was only released to npm 3 hours ago.......
We'll bump the ranges and it'll be released as part of our standard release cycle.

@felixfbecker
Copy link

Can't wait 😍

@Retsam
Copy link
Contributor

Retsam commented Aug 25, 2020

It looks like TS 4.0 is supported, according to the status of this ticket, but I've upgraded TS to 4.02, and @typescript-eslint/eslint-plugin and @typescript-eslint/parser to 3.10.1, but I'm getting Parsing error: Cannot read property 'map' of undefined on any file that uses tuple type syntax, (with or without labels).

Basically I'm seeing #2098 (but that's been closed and locked, otherwise I'd comment over there).

Am I missing something obvious here?

@bradzacher
Copy link
Member Author

bradzacher commented Aug 25, 2020

likely your versions are out of sync somewhere - either there are multiple versions of our tooling installed locally, or your IDE needs to be restarted to pick up the new versions.

We have passing tests (fixture and snapshot) that are currently running against TS4.0.2, so it's unlikely to be a bug from our end? Unless I missed some syntax.

@neilbryson
Copy link
Contributor

This happened to me as well, first in CI builds only but eventually in my local machine after deleting node_modules and reinstalling packages. Not sure what's wrong.

@bradzacher
Copy link
Member Author

I'm unable to repro. As mentioned it's working fine in master.

Also I just tried a clean install with:

    "@typescript-eslint/parser": "^3.10.1",
    "typescript": "^4.0.2"
// .eslintrc.js
module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    semi: 1
  }
};
// a.ts
type T = [a: string];
$ DEBUG=typescript-eslint:* yarn eslint a.ts
  typescript-eslint:typescript-estree:createIsolatedProgram Getting isolated program in TSX mode for: ./a.ts +0ms
Done in 0.96s.

Check the versions installed in your yarn.lock. Likely there are multiple versions installed in your workspace.

@neilbryson
Copy link
Contributor

Oh yeah, you're right. react-scripts@3.4.3 still depends on ^2.10.0. Tried forcing a yarn resolution on it, and it compiled successfully.

Thanks!

@JohannesKlauss
Copy link

@neilbryson How did you force that resolution on react-scripts?

@bradzacher
Copy link
Member Author

Yarn has this functionality built in

https://classic.yarnpkg.com/en/docs/selective-version-resolutions/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AST PRs and Issues about the AST structure dependencies Issue about dependencies of the package New TypeScript Version package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
Development

No branches or pull requests

9 participants