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

Parser error with mixed type and value imports #289

Closed
fehnomenal opened this issue Apr 25, 2022 · 2 comments
Closed

Parser error with mixed type and value imports #289

fehnomenal opened this issue Apr 25, 2022 · 2 comments

Comments

@fehnomenal
Copy link
Contributor

fehnomenal commented Apr 25, 2022

Since some time kit generates a tsconfig.json with some defaults and forces us to extend from it (https://github.com/sveltejs/kit/blob/60b3e9e9f489befe64d95afc812b1fcb921563e2/packages/kit/src/core/sync/write_tsconfig.js#L82). This file mainly sets

		"importsNotUsedAsValues": "error",
		"isolatedModules": true,
		"preserveValueImports": true

which means types must be imported with import type. The example seems outdated in this regard and just uses a normal value import.

While writing queries/mutations/fragments vscode helpfully suggests the correct imports and I end up with something like

   import { fragment, graphql } from '$houdini';

After writing the gql string I generate and try to add the type and vscode insists on generating

  import { fragment, graphql, type GetMyCartItems } from '$houdini';

ESLint is happy but now preprocessing fails with (originating from the preprocess-esm/index.js file)

Error while preprocessing /.../src/routes/warenkorb.svelte - Unexpected token, expected "," (3:26)

The workaround is simple:

  import type { GetMyCartItems } from '$houdini';
  import { fragment, graphql } from '$houdini';

but I did this so often I can no longer be bothered with this...

Could this be related to the second parsing phase with babel?

@AlecAivazis
Copy link
Collaborator

Hm, interesting. I'll try to find some time to dig into this to see what could be causing it. Babel is configured to parse the file with the typescript parser so I would be surprised if it's causing the issue 🤔

@AlecAivazis
Copy link
Collaborator

Closing this since it's fixed by #299

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

2 participants