-
-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Description
NOTE After completely rebuilding the project because of facebook/react-native#4968 I am now unable to reproduce this error.
Working on a simple test app, I found that I was getting errors and was unable to import anything from the following file/module when it was named async.ts
, but that everything worked fine when it was named async.tsx
.
I prefer to distinguish between files with or without JSX by using the appropriate file extension. It's not a big deal to have all files be .tsx
, but if that is required it should be noted in the README. Otherwise this project has worked great so far - thank you for putting it together.
// async.tsx
// if something imported, fails if file is named async.ts
// simple async functions
export function getJSONResource(host: string, resourceName: string) {
return getResource(host, resourceName)
.then(response => response.json());
}
export function getResource(host: string, resourceName: string) {
return fetch(`${host}/${resourceName}`)
.then(handleErrors);
}
export function handleErrors(response: Response) {
if(!response.ok) {
throw Error(response.statusText);
}
return response;
}
1-2 sentences describing the problem you're having or the feature you'd like to request
Expected Behavior
I would have expected to be able to successfully import code from a file with a .ts
extension, as long as no JSX syntax was used.
Observed Behavior
I was unable to import anything and received an error to that effect.
Environment
-
npm ls react-native-scripts-ts
: v1.11.4 -
npm ls react-native
: v0.52.0 -
npm ls expo
: v25.0.0 -
node -v
: 6.9.1 -
npm -v
: 5.7.1 -
yarn --version
: 0.27.5 -
watchman version
: 4.9.0 -
Operating system: OS X Sierra 10.12.6
-
Phone/emulator/simulator & version: Both with Expo and iOS Simulator v10.0