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

Snackager having issues with TypeScript type imports #383

Open
wKovacs64 opened this issue Jan 17, 2023 · 0 comments
Open

Snackager having issues with TypeScript type imports #383

wKovacs64 opened this issue Jan 17, 2023 · 0 comments

Comments

@wKovacs64
Copy link

Summary

I was about to release a new version of a library I maintain after converting it to TypeScript, but I noticed it no longer works in Snack (but works fine in a local app).

Snackager error (truncated):

package.json (3:5)Failed to resolve dependency '[email protected]' (Module build failed (from ../../../../../../../node_modules/babel-loader/lib/index.js):

SyntaxError: /tmp/snackager/snackager/buildStatus/1/[email protected],android,web/package/src/index.tsx: Unexpected token, expected "," (4:7)

  2 | import {
  3 |   useResponsiveImageView,
> 4 |   type ResponsiveImageViewProps,
    |        ^
  5 | } from './useResponsiveImageView';
  6 |
  7 | function defaultOnLoad() {}

I'm using react-native-builder-bob so my package.json looks like so:

  "main": "dist/commonjs/index.js",
  "module": "dist/module/index.js",
  "types": "dist/typescript/src/index.d.ts",
  "react-native": "src/index.tsx",
  "source": "src/index.tsx",

The react-native-builder-bob docs state the following:

It's usually good to point to your source code with the react-native field to make debugging easier. Metro already supports compiling a lot of new syntaxes including JSX, Flow and TypeScript and it will use this field if present.

But as I understand it, Snackager is not Metro. I guess it's reading the react-native field and struggling with the fact that it's TS? I did see previous issue #319 but it's closed as fixed in #327.

What platform(s) does this occur on?

Android, iOS, Web

SDK Version

47

Reproducible demo or steps to reproduce from a blank project

https://snack.expo.dev/@wkovacs64/rnriv-typescript

gmsgowtham added a commit to gmsgowtham/react-native-marked that referenced this issue Mar 22, 2023
Snack is unable to resolve import type statements
ref: expo/snack#383
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

1 participant