I'm not sure what changed, maybe it is even related to babel, but I started getting errors like UserControler_1
is undefined when I use things like this
UserControler.ts
export function signOut() { console.log("Sign Out") }
Page.tsx
import * as React from "react;
import { signOut } from "./UserControler";
import { TouchableWithoutFeedback, Text } from "react-native";
class Page extends React.Component {
_signOut = () => signOut()
render() {
return (
<TouchableWithoutFeedback onPress={this._signOut}>
<Text>Sign Out</Text>
</TouchableWithoutFeedback>
)
}
}
Above results in error like this
UserControler_1 is undefined
Sometimes it errors more specifically i.e.
Can't find variable: signOut
Weirdest thing is that if I change code to something like this, it works fine
import * as React from "react;
import { signOut } from "./UserControler";
class Page extends React.Component {
render() {
return (
<TouchableWithoutFeedback onPress={() => signOut}>
<Text>Sign Out</Text>
</TouchableWithoutFeedback>
)
}
}
Very confused here
My tsconfig
{
"compilerOptions": {
"moduleResolution": "node",
"module": "es6",
"target": "es6",
"lib": ["es7"],
"allowJs": true,
"checkJs": true,
"jsx": "react-native",
"removeComments": true,
"outDir": "./dist",
"typeRoots": ["node_modules/@types", "./typings"],
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"allowSyntheticDefaultImports": true,
"strict": true
},
"exclude": ["./node_modules", "./android", "./ios", "./__tests__", "./dist", "./__mocks__"],
"include": ["./src"]
}
This builds into dist folder from where babel draws its files and hence makes application work, my babelrc
{
"presets": ["react-native"]
}