Unexpected token ‘export’ (意外的令牌 ‘export’)

huangapple go评论170阅读模式
英文:

node_modules\expo\AppEntry.js: Unexpected token 'export'

问题

I have expo project and i use tamagui and react-native. I am working with Github. When I run npm uninstall expo-font, I got node_modules\expo\AppEntry.js: Unexpected token 'export' issue and f in YStack and jc in Paragraph give error.

  1. f error: Type '{ children: Element[]; f: number; jc: string; ai: string; backgroundColor: "$backgroundSoft"; }' is not assignable to type 'IntrinsicAttributes & Omit<ViewProps, "display" | "children" | "style" | "onLayout" | keyof GestureResponderHandlers> & ... 10 more ... & RefAttributes<...>'.
  2. Property 'f' does not exist on type 'IntrinsicAttributes & Omit<ViewProps, "display" | "children" | "style" | "onLayout" | keyof GestureResponderHandlers> & ... 10 more ... & RefAttributes<...>'. jc error: Type 'string' is not assignable to type 'undefined'.ts(2322)

As far as I know, terms like f and jc are defined in Tamagui's own tokens by default.
My codes:

This is App.tsx:

  1. import { useFonts } from "expo-font";
  2. import React from "react";
  3. import { StatusBar } from "expo-status-bar";
  4. import { useColorScheme } from "react-native";
  5. import { Paragraph, TamaguiProvider, Theme, YStack } from "tamagui";
  6. import config from "./tamagui.config";
  7. export default function App() {
  8. const colorScheme = useColorScheme();
  9. const [loaded] = useFonts({
  10. Urbanist: require("./assets/fonts/Urbanist-Bold.otf"),
  11. UrbanistSemibold: require("./assets/fonts/Urbanist-SemiBold.otf"),
  12. UrbanistMedium: require("./assets/fonts/Urbanist-Medium.otf"),
  13. UrbanistRegular: require("./assets/fonts/Urbanist-Regular.otf"),
  14. });
  15. if (!loaded) {
  16. return null;
  17. }
  18. return (
  19. <TamaguiProvider config={config}>
  20. <Theme name={colorScheme === "dark" ? "dark" : "light"}>
  21. <YStack
  22. f={1}
  23. jc="center"
  24. ai="center"
  25. backgroundColor="$backgroundSoft"
  26. >
  27. <Paragraph color="$color" jc="center">
  28. {colorScheme}
  29. </Paragraph>
  30. <StatusBar style="auto" />
  31. </YStack>
  32. </Theme>
  33. </TamaguiProvider>
  34. );
  35. }

This is package.json:

  1. "dependencies": {
  2. "@tamagui/animations-react-native": "^1.43.13",
  3. "@tamagui/babel-plugin": "^1.43.13",
  4. "@tamagui/config": "^1.43.13",
  5. "@tamagui/font-inter": "^1.43.13",
  6. "@tamagui/theme-base": "^1.43.13",
  7. "babel-plugin-transform-inline-environment-variables": "^0.4.4",
  8. "expo": "~48.0.18",
  9. "expo-font": "~11.1.1",
  10. "expo-status-bar": "~1.4.4",
  11. "react": "18.2.0",
  12. "react-dom": "^18.2.0",
  13. "react-native": "0.71.8",
  14. "react-native-reanimated": "~2.14.4",
  15. "react-native-web": "^0.19.6",
  16. "tamagui": "^1.43.13"
  17. },
  18. "devDependencies": {
  19. "@babel/core": "^7.20.0",
  20. "@types/react": "~18.0.14",
  21. "@typescript-eslint/eslint-plugin": "^5.62.0",
  22. "eslint": "^8.46.0",
  23. "eslint-config-prettier": "^9.0.0",
  24. "eslint-config-standard-with-typescript": "^37.0.0",
  25. "eslint-plugin-import": "^2.28.0",
  26. "eslint-plugin-n": "^16.0.1",
  27. "eslint-plugin-prettier": "^5.0.0",
  28. "eslint-plugin-promise": "^6.1.1",
  29. "eslint-plugin-react": "^7.33.1",
  30. "husky": "^8.0.3",
  31. "prettier": "3.0.1",
  32. "typescript": "^4.9.5"
  33. },
  34. "private": true,
  35. "lint-staged": {
  36. "*.{ts,js,jsx,tsx}": [
  37. "eslint --ignore-path .gitignore --fix --max-warnings 0",
  38. "prettier --ignore-path .gitignore --write"
  39. ]
  40. }
  41. }

I deleted node_modules and reinstalled but it didn't work. I run npx expo install expo-font but it didn't work. I cleared the cache(npm cache clean --force ) but it didn't work. I merged main and theme branches.

英文:

I have expo project and i use tamagui and react-native.I am working with Github. When I run npm uninstall expo-font, I got node_modules\expo\AppEntry.js: Unexpected token &#39;export&#39; issue and f in YStack and jc in Paragraph give error.

  1. f error : Type &#39;{ children: Element[]; f: number; jc: string; ai: string; backgroundColor: &quot;$backgroundSoft&quot;; }&#39;** is not assignable to type **&#39;IntrinsicAttributes &amp; Omit&lt;ViewProps, &quot;display&quot; | &quot;children&quot; | &quot;style&quot; | &quot;onLayout&quot; | keyof GestureResponderHandlers&gt; &amp; ... 10 more ... &amp; RefAttributes&lt;...&gt;&#39;.**
  2. Property &#39;f&#39; does not exist on type **&#39;IntrinsicAttributes &amp; Omit&lt;ViewProps, &quot;display&quot; | &quot;children&quot; | &quot;style&quot; | &quot;onLayout&quot; | keyof GestureResponderHandlers&gt; &amp; ... 10 more ... &amp; RefAttributes&lt;...&gt;&#39;**. jc error : Type &#39;string&#39; is not assignable to type **&#39;undefined&#39;.ts(2322)**

As far as I know, terms like f and jc are defined in Tamagui's own tokens by default.
My codes :
This is App.tsx:

  1. import { useFonts } from &quot;expo-font&quot;
  2. import React from &quot;react&quot;
  3. import { StatusBar } from &quot;expo-status-bar&quot;
  4. import { useColorScheme } from &quot;react-native&quot;
  5. import { Paragraph, TamaguiProvider, Theme, YStack } from &quot;tamagui&quot;
  6. import config from &quot;./tamagui.config&quot;
  7. export default function App() {
  8. const colorScheme = useColorScheme()
  9. const [loaded] = useFonts({
  10. Urbanist: require(&quot;./assets/fonts/Urbanist-Bold.otf&quot;),
  11. UrbanistSemibold: require(&quot;./assets/fonts/Urbanist-SemiBold.otf&quot;),
  12. UrbanistMedium: require(&quot;./assets/fonts/Urbanist-Medium.otf&quot;),
  13. UrbanistRegular: require(&quot;./assets/fonts/Urbanist-Regular.otf&quot;),
  14. })
  15. if (!loaded) {
  16. return null
  17. }
  18. return (
  19. &lt;TamaguiProvider config={config}&gt;
  20. &lt;Theme name={colorScheme === &quot;dark&quot; ? &quot;dark&quot; : &quot;light&quot;}&gt;
  21. &lt;YStack
  22. f={1}
  23. jc=&quot;center&quot;
  24. ai=&quot;center&quot;
  25. backgroundColor={&quot;$backgroundSoft&quot;}
  26. &gt;
  27. &lt;Paragraph color=&quot;$color&quot; jc=&quot;center&quot;&gt;
  28. {colorScheme}
  29. &lt;/Paragraph&gt;
  30. &lt;StatusBar style=&quot;auto&quot; /&gt;
  31. &lt;/YStack&gt;
  32. &lt;/Theme&gt;
  33. &lt;/TamaguiProvider&gt;
  34. )
  35. }

This is package.json:

  1. &quot;dependencies&quot;: {
  2. &quot;@tamagui/animations-react-native&quot;: &quot;^1.43.13&quot;,
  3. &quot;@tamagui/babel-plugin&quot;: &quot;^1.43.13&quot;,
  4. &quot;@tamagui/config&quot;: &quot;^1.43.13&quot;,
  5. &quot;@tamagui/font-inter&quot;: &quot;^1.43.13&quot;,
  6. &quot;@tamagui/theme-base&quot;: &quot;^1.43.13&quot;,
  7. &quot;babel-plugin-transform-inline-environment-variables&quot;: &quot;^0.4.4&quot;,
  8. &quot;expo&quot;: &quot;~48.0.18&quot;,
  9. &quot;expo-font&quot;: &quot;~11.1.1&quot;,
  10. &quot;expo-status-bar&quot;: &quot;~1.4.4&quot;,
  11. &quot;react&quot;: &quot;18.2.0&quot;,
  12. &quot;react-dom&quot;: &quot;^18.2.0&quot;,
  13. &quot;react-native&quot;: &quot;0.71.8&quot;,
  14. &quot;react-native-reanimated&quot;: &quot;~2.14.4&quot;,
  15. &quot;react-native-web&quot;: &quot;^0.19.6&quot;,
  16. &quot;tamagui&quot;: &quot;^1.43.13&quot;
  17. },
  18. &quot;devDependencies&quot;: {
  19. &quot;@babel/core&quot;: &quot;^7.20.0&quot;,
  20. &quot;@types/react&quot;: &quot;~18.0.14&quot;,
  21. &quot;@typescript-eslint/eslint-plugin&quot;: &quot;^5.62.0&quot;,
  22. &quot;eslint&quot;: &quot;^8.46.0&quot;,
  23. &quot;eslint-config-prettier&quot;: &quot;^9.0.0&quot;,
  24. &quot;eslint-config-standard-with-typescript&quot;: &quot;^37.0.0&quot;,
  25. &quot;eslint-plugin-import&quot;: &quot;^2.28.0&quot;,
  26. &quot;eslint-plugin-n&quot;: &quot;^16.0.1&quot;,
  27. &quot;eslint-plugin-prettier&quot;: &quot;^5.0.0&quot;,
  28. &quot;eslint-plugin-promise&quot;: &quot;^6.1.1&quot;,
  29. &quot;eslint-plugin-react&quot;: &quot;^7.33.1&quot;,
  30. &quot;husky&quot;: &quot;^8.0.3&quot;,
  31. &quot;prettier&quot;: &quot;3.0.1&quot;,
  32. &quot;typescript&quot;: &quot;^4.9.5&quot;
  33. },
  34. &quot;private&quot;: true,
  35. &quot;lint-staged&quot;: {
  36. &quot;*.{ts,js,jsx,tsx}&quot;: [
  37. &quot;eslint --ignore-path .gitignore --fix --max-warnings 0&quot;,
  38. &quot;prettier --ignore-path .gitignore --write&quot;
  39. ]
  40. }
  41. }

I deleted node_modules and reinstalled but it didn't work.
I run npx expo install expo-font but it didn't work
I cleared the cache(npm cache clean --force ) but it didn't work.
I merged main and theme branches.

答案1

得分: 0

如果在 tamagui.config.ts 文件中写入 type TamaguiCustomConfig = AppConfig,则替换为 interface TamaguiCustomConfig extends AppConfig {} 并输入以下eslint注释行:

  1. // eslint-disable-next-line @typescript-eslint/no-empty-interface
英文:

If type TamaguiCustomConfig = AppConfig is written in tamagui.config.ts file, replace it with interface TamaguiCustomConfig extends AppConfig {} and enter

> // eslint-disable-next-line @typescript-eslint/no-empty-interface as
eslint comment line.

huangapple
  • 本文由 发表于 2023年8月10日 14:46:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76873208.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定