envs icon indicating copy to clipboard operation
envs copied to clipboard

import type

Open l0gicgate opened this issue 4 years ago • 11 comments

Describe the bug

Using the statement import type { SomeType } from './Component.d.ts' throws a parsing error.

I'm not sure if this is related: https://github.com/babel/babel/issues/10981

Steps to Reproduce

  1. Use import type { SomeType } from './Component.d.ts'

Expected Behavior

It should not throw any parsing errors as Typescript 3.8 supports this.

Screenshots, exceptions and logs

When running bit status you get a parsing error as if import type... is not valid synthax: screenshot1

Same goes for when running bit build: screenshot1

If applicable, add screenshots, exceptions, and logs to help explain your problem.

Specifications

  • Bit version: 14.7.6
  • Node version: 12.16.2
  • npm / yarn version: 6.14.4
  • Platform: Windows 10 x64
  • Compiler / Tester (include version): [email protected]

l0gicgate avatar Apr 13 '20 18:04 l0gicgate

@GiladShoham - seems like Bit TS requires upgrading to 3.8

Tallyb avatar Apr 15 '20 04:04 Tallyb

@Tallyb looks like you guys are already on 3.8.3 https://github.com/teambit/envs/blob/master/package.json#L63

But on the babel compiler package you’re on 3.6.2: https://github.com/teambit/envs/blob/master/packages/babel/package.json#L13

I think the issue is related to babel perhaps: https://github.com/babel/babel/issues/10981

l0gicgate avatar Apr 15 '20 14:04 l0gicgate

I'm not sure 3.8.3 is already in production, but we can publish it I think

GiladShoham avatar Apr 15 '20 19:04 GiladShoham

@GiladShoham it would be great, Right now I'm at a standstill because of this and #89 / #2306

l0gicgate avatar Apr 15 '20 20:04 l0gicgate

The compiler is on 3.8.3, but Bit needs also to be on 3.8 for the AST analysis to work correctly.

On Wed, Apr 15, 2020 at 11:36 PM Pierre Bérubé [email protected] wrote:

@GiladShoham https://github.com/GiladShoham it would be great, Right now I'm at a standstill because of this and #89 https://github.com/teambit/envs/issues/89 / #2306 https://github.com/teambit/bit/issues/2306

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/teambit/envs/issues/124#issuecomment-614266762, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYLJDYFQWGK3QQDQZISGW3RMYLELANCNFSM4MHECQFQ .

Tallyb avatar Apr 16 '20 05:04 Tallyb

I just opened a PR for this. https://github.com/teambit/bit/pull/2592

davidfirst avatar Apr 16 '20 17:04 davidfirst

Merged. Hopefully will be released early next week

davidfirst avatar Apr 17 '20 02:04 davidfirst

I've tested the prod branch on a trivial component with import type. It seems like there is a parsing error (both production CLI and prod branch).

                                                       ✔  10313  20:22:01
new components
(use "bit tag --all [version]" to lock a version with all your changes)

     > comp ...  issues found       
       error found while parsing the file (please edit the file and fix the parsing error): 
          comp.ts -> '=' expected.

see troubleshooting at https://docs.bit.dev/docs/add-and-isolate-components#common-isolation-errors

The component still builds thought, so in order to solve this issue it would be great if you can provide some link to example repo or a public bit component @l0gicgate.

qballer avatar Apr 18 '20 17:04 qballer

@qballer provide a repo for what exactly? You reproduced the problem, what do you want me to do?

l0gicgate avatar Apr 18 '20 17:04 l0gicgate

There are two issues here from what I can tell. Bit's parsing has an error that involves the import type syntax and your component doesn't compile. The first might create issues with detecting dependencies but the compiler did manage to compile my component, so I'm wondering how exactly does it fail to compile on your end. A contrived example would do if there is an issue sharing source code.

qballer avatar Apr 18 '20 20:04 qballer

@qballer the component compiles if I remove the import type synthax and simply use import { MyType}

l0gicgate avatar Apr 18 '20 20:04 l0gicgate