Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[vscode error] Request textDocument/hover failed #207

@replygirl

Description

@replygirl

The error

This happens very time I hover over a specific symbol:

Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: (tag.text || "").split is not a function
  Code: -32603 

Sample code

Affected component:

The affected new CoordinateSpan(...) symbol is labeled near the bottom of the <script> tag

<!-- @/components/Map.vue -->

<template lang="pug">
div(ref="mapContainer")
</template>

<script setup lang="ts">
import { inject, onMounted, ref } from 'vue'

const maps = inject<typeof mapkit>('mapkit')
const mapContainer = ref<HTMLDivElement | null>(null)
const map = ref<mapkit.Map | null>(null)

onMounted(() => {
  if (import.meta.env.SSR) return
  if (maps == null) throw new Error('MapKit is not available')
  if (mapContainer.value == null)
    throw new Error('Map container has not mounted')

  console.info(mapContainer.value)

  const { Coordinate, CoordinateRegion, CoordinateSpan, Map, MapRect } = maps!

  map.value = new Map(mapContainer.value!, {
    visibleMapRect: new MapRect(-73.979187, 40.705628, 1, 1),
    region: new CoordinateRegion(
      new Coordinate(-73.979187, 40.705628),
      new CoordinateSpan(0.692826, 0.210573) // this is the affected symbol
    ),
    center: new Coordinate(-73.979187, 40.705628),
  })
})
</script>

MapKit provider

// @/modules/mapkit.ts

import type { UserModule } from '@/types'

// Events: https://developer.apple.com/documentation/mapkitjs/mapkit/map/handling_map_events

// Types: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/apple-mapkit-js-browser/index.d.ts

export const install: UserModule = ({ app, isClient }) => {
  app.provide<typeof mapkit | null>('mapkit', isClient ? mapkit : null)

  if (isClient)
    mapkit.init({
      authorizationCallback: done =>
        done(import.meta.env.VITE_APP_APPLE_MAPKIT_TOKEN as string),
    })
}

Context:

  • The project is loosely based on frandiox/vitesse-ssr-template
  • In tsconfig.json, register mapkit by adding apple-mapkit-js-browser to compilerOptions.types
  • The offending type is fully documented and can be jumped to with alt+click just like the other types from mapkit
  • The component compiles without type errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions