I was eagerly anticipating the release of TypeScript 2.1.4, as one of the major reasons my team decided to use TS was the convenience of importing installed modules without needing to search for or create type definitions, thanks to implicit any imports. However, despite this feature being promoted, I am still encountering errors stating that a module cannot be found. Interestingly, once I install types for the module (React in this case), everything works smoothly.
Below is my package.json:
{
"name": "my_app_name",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --colors --port 8282"
},
"dependencies": {
"react": "^15.4.1",
"react-dom": "^15.4.1"
},
"devDependencies": {
"awesome-typescript-loader": "^3.0.0-beta.9",
"source-map-loader": "^0.1.5",
"typescript": "^2.1.4",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2"
}
}
This is my tsconfig.json:
{
"compilerOptions": {
"outDir": "./dist/",
"module": "commonjs",
"target": "esnext",
"jsx": "react"
},
"include": [
"./**/*"
]
}
Here's a snippet from a .tsx file containing a React component that showcases the issue:
import * as React from "react";
export interface HelloProps { compiler: string; framework: string; }
export const Hello = (props: HelloProps) => {
return <h1>Hello from {props.compiler} and {this.props.framework}!</h1>
};
Additionally, I have created a separate project replicating this problem and shared it on BitBucket. Any assistance would be highly appreciated. Should this be an issue with TypeScript itself, I will not hesitate to raise the concern on the Github repository.