Cannot resolve typescript imports
See original GitHub issueCurrent Behavior
When attempting to use ts-loader to resolve typescript files, haul says it is unable to resolve the module.
When trying to import a ts component with the line
import { SomeComponent } from './some-component';
You get the following error from haul ERROR in
./src/index.android.tsx Module not found: Error: Can't resolve './some-component' in 'C:\Users\gusta\Documents\rn-typescript-example\src'@ ./src/index.android.tsx 15:23-50 @ multi ./~/haul-cli/src/utils/polyfillEnvironment.js ./src/index.android.tsx
(TSC gives no errors when compiling this)
if you try with the file extension, as:
import { SomeComponent } from './some-component.tsx';
Haul works fine, but react native crashes runtime with undefined is not an object
I have created a reproduction repo: https://github.com/GeeWee/rn-typescript-example
Expected Behavior
I expect it to resolve and transform the typescript file properly.
Haul Configuration (webpack.haul.js)
module.exports = ({ platform }, { module }) => ({
entry: `./src/index.${platform}.tsx`,
module: {
...module,
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader'
},
...module.rules
]
}
});
Your Environment
| software | version |
|---|---|
| Haul | 0.5.0 |
| react-native | 0.42.3 |
| node | 7.7.4 |
| npm or yarn | yarn 0.21.3 |
| typescript | 2.2.2 |
| ts-loader | 2.0.3 |
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
I had the exact same problem yesterday, and you need to set
extensionsunderresolve. I’ve got a working example here: https://github.com/cbrevik/rn-typescript-example/blob/master/webpack.haul.jsE.g.
Edit: Opened a PR to flesh out example project a bit more (https://github.com/nixterrimus/rn-typescript-example/pull/3)
Check this doc https://webpack.js.org/guides/typescript/