I'm new to TypeScript.
I was working on migrating my own React.js project which is written in JS into TypeScript.
I fixed all the bugs and also checked it worked well on npm start
.
But when I tried to compile with tsc, it never works and never shows any of logs.
but as you can see, tsc -v
works.
I tried Ctrl+Shift+B in VSCode, but it also showed same result, nothing.
in my tsconfig.json
, I just added outDir
into auto-generated tsconfig.json
.
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"outDir": "./dist"
},
"include": [
"./src/*"
]
}
Is there anyway I can fix it?
Thanks in advance.
If the app was created using CRA script, I would stick to the pre-existing script command
build
(npm run build) defined in package.json.
In this case, tsc is only used for type checking that's why noEmit
is set to true. The build
command executes react-scripts build
script which behind the scenes uses Webpack to load and compile typescript to javascript.