简体   繁体   中英

VS Code and Typescript watch: Files are being recompiled without being saved

I'm developing a Typescript project and I run "tsc -w" to keep it compiling while I edit.

The problem is, sometimes my files will be recompiled even when I don't save them. Sometimes it recompiles files randomly that I haven't touched (Like if I open an existing file in typescript to begin editing)

Is this vs code? or Typescript? does anyone know a solution to stop this happening?

My .tsconfig is below

{
  "compilerOptions": {
    "target": "es2015",
    "module": "es2015",
    "allowJs": false,
    "jsx": "react",
    "sourceMap": true,
    "outDir": "build",

    "baseUrl": ".",
    "paths": {
      "@shared/*": [ "src/shared/*" ],
      "@app/*": ["src/*"]
    },
    "strict": true,
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true,
    "skipLibCheck": true,
  },
  "filesGlob": [
    "src/**/*.ts",
    "src/**/*.tsx",
  ],
  "types": [
    "react",
    "react-dom",
    "react-native"
  ],
  "exclude": [
    "build",
    "**/node_modules/*",
    "jest.config.js",
    "App.js"
  ],
  "include": [
    "./src",
  ],
  "compileOnSave": false
}

Turns out I didn't have to run a separate Typescript Watch process - Expo Typescript support has improved since I started my project.

See https://docs.expo.io/versions/latest/guides/typescript/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM