英文:
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.
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<...>'.
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:
import { useFonts } from "expo-font";
import React from "react";
import { StatusBar } from "expo-status-bar";
import { useColorScheme } from "react-native";
import { Paragraph, TamaguiProvider, Theme, YStack } from "tamagui";
import config from "./tamagui.config";
export default function App() {
const colorScheme = useColorScheme();
const [loaded] = useFonts({
Urbanist: require("./assets/fonts/Urbanist-Bold.otf"),
UrbanistSemibold: require("./assets/fonts/Urbanist-SemiBold.otf"),
UrbanistMedium: require("./assets/fonts/Urbanist-Medium.otf"),
UrbanistRegular: require("./assets/fonts/Urbanist-Regular.otf"),
});
if (!loaded) {
return null;
}
return (
<TamaguiProvider config={config}>
<Theme name={colorScheme === "dark" ? "dark" : "light"}>
<YStack
f={1}
jc="center"
ai="center"
backgroundColor="$backgroundSoft"
>
<Paragraph color="$color" jc="center">
{colorScheme}
</Paragraph>
<StatusBar style="auto" />
</YStack>
</Theme>
</TamaguiProvider>
);
}
This is package.json:
"dependencies": {
"@tamagui/animations-react-native": "^1.43.13",
"@tamagui/babel-plugin": "^1.43.13",
"@tamagui/config": "^1.43.13",
"@tamagui/font-inter": "^1.43.13",
"@tamagui/theme-base": "^1.43.13",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"expo": "~48.0.18",
"expo-font": "~11.1.1",
"expo-status-bar": "~1.4.4",
"react": "18.2.0",
"react-dom": "^18.2.0",
"react-native": "0.71.8",
"react-native-reanimated": "~2.14.4",
"react-native-web": "^0.19.6",
"tamagui": "^1.43.13"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/react": "~18.0.14",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard-with-typescript": "^37.0.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.1",
"husky": "^8.0.3",
"prettier": "3.0.1",
"typescript": "^4.9.5"
},
"private": true,
"lint-staged": {
"*.{ts,js,jsx,tsx}": [
"eslint --ignore-path .gitignore --fix --max-warnings 0",
"prettier --ignore-path .gitignore --write"
]
}
}
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 'export'
issue and f in YStack and jc in Paragraph give error.
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<...>'.**
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:
import { useFonts } from "expo-font"
import React from "react"
import { StatusBar } from "expo-status-bar"
import { useColorScheme } from "react-native"
import { Paragraph, TamaguiProvider, Theme, YStack } from "tamagui"
import config from "./tamagui.config"
export default function App() {
const colorScheme = useColorScheme()
const [loaded] = useFonts({
Urbanist: require("./assets/fonts/Urbanist-Bold.otf"),
UrbanistSemibold: require("./assets/fonts/Urbanist-SemiBold.otf"),
UrbanistMedium: require("./assets/fonts/Urbanist-Medium.otf"),
UrbanistRegular: require("./assets/fonts/Urbanist-Regular.otf"),
})
if (!loaded) {
return null
}
return (
<TamaguiProvider config={config}>
<Theme name={colorScheme === "dark" ? "dark" : "light"}>
<YStack
f={1}
jc="center"
ai="center"
backgroundColor={"$backgroundSoft"}
>
<Paragraph color="$color" jc="center">
{colorScheme}
</Paragraph>
<StatusBar style="auto" />
</YStack>
</Theme>
</TamaguiProvider>
)
}
This is package.json:
"dependencies": {
"@tamagui/animations-react-native": "^1.43.13",
"@tamagui/babel-plugin": "^1.43.13",
"@tamagui/config": "^1.43.13",
"@tamagui/font-inter": "^1.43.13",
"@tamagui/theme-base": "^1.43.13",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"expo": "~48.0.18",
"expo-font": "~11.1.1",
"expo-status-bar": "~1.4.4",
"react": "18.2.0",
"react-dom": "^18.2.0",
"react-native": "0.71.8",
"react-native-reanimated": "~2.14.4",
"react-native-web": "^0.19.6",
"tamagui": "^1.43.13"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/react": "~18.0.14",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard-with-typescript": "^37.0.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.1",
"husky": "^8.0.3",
"prettier": "3.0.1",
"typescript": "^4.9.5"
},
"private": true,
"lint-staged": {
"*.{ts,js,jsx,tsx}": [
"eslint --ignore-path .gitignore --fix --max-warnings 0",
"prettier --ignore-path .gitignore --write"
]
}
}
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注释行:
// 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论