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

SyntaxError: '=' expected #301

Closed
PaulRBerg opened this issue Nov 9, 2020 · 13 comments
Closed

SyntaxError: '=' expected #301

PaulRBerg opened this issue Nov 9, 2020 · 13 comments

Comments

@PaulRBerg
Copy link
Contributor

Description

I saw the recent v4 release and I wanted to upgrade to it in my solidity-template, but there is no CHANGELOG explaining what changed since v2 or v3.

Simply installing typechain@4.0.0 and @typechain/ethers-v5@3.0.0 gets me this error:

SyntaxError: '=' expected. (8:15)
   6 |   import { Contract, ContractFactory, Overrides } from "@ethersproject/contracts";
   7 |
>  8 |   import type { Greeter } from "./Greeter";
     |               ^
   9 |
  10 |   export class GreeterFactory extends ContractFactory {

See the full stack trace here.

How to Reproduce

  1. Clone paulrberg/solidity-template
  2. Switch to the typechain-v4 branch
  3. Install dependencies with yarn
  4. Run yarn typechain
@quezak
Copy link
Contributor

quezak commented Nov 9, 2020

@PaulRBerg do the typechain package release notes include the necessary info?

@krzkaczor we should add release notes for target packages too

@PaulRBerg
Copy link
Contributor Author

Do the typechain package release notes include the necessary info?

Not really. It's not clear from either the following statement:

Do not camel case contract names

Or #293 what exactly I should do to make the upgrade to TypeChain v4.

@krzkaczor
Copy link
Member

It's was actually a previous release: https://github.com/ethereum-ts/TypeChain/releases/tag/typechain%403.0.0

You are running an old TS version (i think before 3.7) that doesn't support type imports (export type syntax). Upgrading typescript should fix this problem.

Please reopen if it still doesn't work.

@PaulRBerg
Copy link
Contributor Author

PaulRBerg commented Nov 9, 2020

Thanks @krzkaczor! I think it'd be worth it to mention in the release notes that TypeChain v4 only works with TypeScript v4. Lots of people are still using TypeScript v3.

@quezak
Copy link
Contributor

quezak commented Nov 9, 2020

@PaulRBerg which TS version did you try before? I think it only requires TS3.7. There is a peer dependency for typechain: ^4.0.0, I was also confused by that at first 😄

Anyway, we'll add a peer dependency on typescript too so you'll get warned if your version is too old.

@PaulRBerg
Copy link
Contributor Author

@krzkaczor
Copy link
Member

Fixed in: 0f661c6 (#300)

Btw. bonus q: is it possible in semver to say that everything above 3.8 including next major is fine?

@PaulRBerg
Copy link
Contributor Author

Btw. bonus q: is it possible in semver to say that everything above 3.8 including next major is fine?

I think that ^3.8.x should do the trick:

https://jubianchi.github.io/semver-check/#/constraint/^3.8.x

@quezak
Copy link
Contributor

quezak commented Nov 10, 2020

^3.8.x allows 3.9 -- I think @krzkaczor wanted to allow 4.0 too. I don't think that's possible with a single operator if you still want to not allow 5.0.

@PaulRBerg
Copy link
Contributor Author

Oh, yes. That doesn't look like it's possible:

semver/semver#395

@krzkaczor
Copy link
Member

Just to clarify - I want to match 3.8, 3.9, 4.x even future 5.x and 21.x releases.

I think it's simply not possible because this is not how semver works :/ Obviously, TS doesn't comfort to semver spec so it is what it is.

@quezak
Copy link
Contributor

quezak commented Nov 10, 2020

@krzkaczor can't you just specify >=3.8.0 then?

@krzkaczor
Copy link
Member

Oh, actually it seems that it works (at least according to: https://jubianchi.github.io/semver-check/#/%3E%3D3.8.0/5 ) KISS! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants