teambit / envs

Component development environments for the Bit community
https://bit.dev/bit/envs
Other
63 stars 9 forks source link

import type #124

Open l0gicgate opened 4 years ago

l0gicgate commented 4 years ago

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

Tallyb commented 4 years ago

@GiladShoham - seems like Bit TS requires upgrading to 3.8

l0gicgate commented 4 years ago

@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

GiladShoham commented 4 years ago

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

l0gicgate commented 4 years ago

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

Tallyb commented 4 years ago

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é notifications@github.com 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 .

davidfirst commented 4 years ago

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

davidfirst commented 4 years ago

Merged. Hopefully will be released early next week

qballer commented 4 years ago

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.

l0gicgate commented 4 years ago

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

qballer commented 4 years ago

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.

l0gicgate commented 4 years ago

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