NuxtN
Nuxt2y ago
Phillip

How to use DefinitelyTyped types in a Nuxt 3 project?

I've been trying to use DefinitelyTyped types in my project multiple times but just cannot get it working. Is there an additional step that I need to do?

  1. installed types for Google Maps with npm i @types/google.maps (https://www.npmjs.com/package/@types/google.maps)
  2. in my script setup I try to import an interface like this:
    <script setup lang="ts">
    import { GeocoderResult } from '@types/google.maps'

    A index.d.ts is present in @types/google.maps but I'm getting
    'GeocoderResult' is declared but its value is never read.ts(6133)
    Cannot import type declaration files. Consider importing 'google.maps' instead of '@types/google.maps'.ts(6137)
Do I need to add something else to my tsconfig?

Edit: Okay I just read it's not possible to import index.d.ts file as it seems... but how am I supposed to use the interface in @types/google.maps?
npm
TypeScript definitions for google.maps. Latest version: 3.55.11, last published: 12 days ago. Start using @types/google.maps in your project by running npm i @types/google.maps. There are 148 other projects in the npm registry using @types/google.maps.
Was this page helpful?