TypeScript文件中的Vscode断点未在React Native中命中

Can*_*ğlu 5 debugging typescript babeljs react-native visual-studio-code

我有一个React Native 0.61项目,TypeScript 3.6.2和Vscode 1.38.1。

这是我的启动配置:

{
    "name": "Debug iOS",
    "cwd": "${workspaceFolder}",
    "type": "reactnative",
    "request": "launch",
    "platform": "ios"  
},
Run Code Online (Sandbox Code Playgroud)

tsconfig.json

  {
    "compilerOptions": {
      // Target latest version of ECMAScript.
      "target": "esnext",
      // Search under node_modules for non-relative imports.
      "moduleResolution": "node",
      // Process & infer types from .js files.
      "allowJs": true,
      // Don't emit; allow Babel to transform files.
      "noEmit": true,
      // Enable strictest settings like strictNullChecks & noImplicitAny.
      "strict": true,
      // Disallow features that require cross-file information for emit.
      "isolatedModules": true,
      // Import non-ES modules as default imports.
      "esModuleInterop": true,
      "baseUrl": "./src",
      "jsx": "react-native",
    }
  }
Run Code Online (Sandbox Code Playgroud)

babel.config.js

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
};
Run Code Online (Sandbox Code Playgroud)

我开始在Vscode中调试,我看到以下输出:

Starting debugger app worker.
Established a connection with the Proxy (Packager) to the React Native application
Debugger worker loaded runtime on port 4021
Run Code Online (Sandbox Code Playgroud)

但是,我的断点不会受到影响。当我开始调试时,它们在Vscode中保留为空白,灰色,“未验证的断点”。如果我debugger在代码本身中放入任何语句,则会在生成/编译的.bundle文件中被击中:

在此处输入图片说明

在此处输入图片说明

这是我尝试过的一些方法(它们都不起作用):

  • 添加"sourceMaps": true,到我的启动配置
  • 添加"outDir": "${workspaceRoot}/.vscode/.react"到我的启动配置中(即使它说“ Property outDir不允许”,我也尝试过
  • 添加"sourceMap": true到我的tsconfig
  • 添加"outDir": "build"到我的tsconfig
  • 添加"module": "commonjs"到我的tsconfig
  • 添加"inlineSourceMap": true到我的tsconfig

显然,我一次又一次地尝试了它们,一次又一次添加了一次,而不是一次添加。我还关闭了Vscode,删除了所有Metro缓存文件(快速模块映射等),并在每个步骤中重新打开了Vscode。

我在以下位置阅读了可能相关的问题和答案:

另外,这是my的输出react-native info,如果有帮助的话:

System:
    OS: macOS 10.15
    CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
    Memory: 3.69 GB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.10.0 - /usr/local/bin/node
    Yarn: 1.19.0 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      Android NDK: 17.2.4988734
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5522156
    Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: ^0.61.1 => 0.61.1 
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-gesture-handler: 1.0.16
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?