【发布时间】:2023-02-09 09:34:16
【问题描述】:
我在 package.json 中有以下内容
"@types/google.maps": "~3.48.3",
// in my tsx file the first line at the top is
/// <reference types='google.maps' />
但是在访问 google.maps.MapMouseEvent 时 - 我收到错误“google”未定义。 第 980:43 行:'google' 未定义 no-undef
980行是
onMarkerDragEnd = async (mapMouseEvent: google.maps.MapMouseEvent) => {
// I also tried
/// <reference path='../../../../node_modules/@types/google.maps' />
// I also tried in tsconfig.json
"compilerOptions": {
"types": [
"google.maps"
]
}
但错误仍然存在。我正在使用编译打字稿
react-app-rewired build
寻找有关如何在打字稿中使用 @types/google.maps 的任何提示。
【问题讨论】:
标签: typescript google-maps build react-app-rewired