Skip to content

import type #124

Open
teambit/bit
#2592

Description

@l0gicgate

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:
babel/babel#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): react-typescript@3.1.51

Activity

  1. Tallyb commented on Apr 15, 2020

    @Tallyb
    Contributor

    @GiladShoham - seems like Bit TS requires upgrading to 3.8

  2. l0gicgate commented on Apr 15, 2020

    @l0gicgate
    Author

    @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:
    babel/babel#10981

  3. GiladShoham commented on Apr 15, 2020

    @GiladShoham
    Member

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

  4. l0gicgate commented on Apr 15, 2020

    @l0gicgate
    Author

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

  5. Tallyb commented on Apr 16, 2020

    @Tallyb
    Contributor
  6. davidfirst commented on Apr 16, 2020

    @davidfirst
    Member

    I just opened a PR for this. teambit/bit#2592

  7. davidfirst commented on Apr 17, 2020

    @davidfirst
    Member

    Merged. Hopefully will be released early next week

  8. qballer commented on Apr 18, 2020

    @qballer
    Contributor

    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.

  9. self-assigned this
    on Apr 18, 2020
  10. l0gicgate commented on Apr 18, 2020

    @l0gicgate
    Author

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

  11. qballer commented on Apr 18, 2020

    @qballer
    Contributor

    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.

  12. l0gicgate commented on Apr 18, 2020

    @l0gicgate
    Author

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

  13. removed their assignment
    on Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions