New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

volar-component-types

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

volar-component-types

A module that provides Volar types for auto-discovered components in Nuxt 2

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
19
375%
Maintainers
0
Weekly downloads
 
Created
Source

volar-component-types

A module that provides Volar types for auto-discovered components in Nuxt 2.

Introduction

Nuxt 2, like Nuxt 3, auto-discovers components but unlike Nuxt 3, it doesn't automatically generate types for those components so Vue Language Tools (formerly Volar) is not able to type-check those unless they are explicitly imported (which defeats the purpose of auto-discovering). This module takes care of registering types for all auto-discovered components so that Volar is aware of those and can type-check them. Does that by generating a plain type definition file with extended types for GlobalComponents interface.

Setup

  • Install volar-component-types package:
    # Npm
    npm i -D volar-component-types
    # Yarn
    yarn add -D volar-component-types
    
  • Add the module to buildModules in nuxt.config.js.
    export default {
        buildModules: [
           'volar-component-types/nuxt',
        ],
    }
    
  • Set following options in tsconfig.json:
    {
       // other options...
       "include": [
          "./nuxt/types/components.d.ts",
          "./nuxt.config.ts",
          // Also make sure that all pages and components are included, for example:
          "./pages/**/*",
          "./components/**/*",
          // etc...
       ],
       "vueCompilerOptions": {
         "target": 2.7,
         "strictTemplates": true,
       }
    }
    
  • Extend types array in tsconfing.json to augment Nuxt Config with module configuration types.
    {
       "compilerOptions": {
          "types": [
             "volar-component-types",
          ]
       }
    }
    
  • Run nuxt dev.

FAQs

Package last updated on 20 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts