vinejs / vine

VineJS is a form data validation library for Node.js

Home Page:https://vinejs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot find module '@vinejs/vine/types' or its corresponding type declarations.

aryanjaya opened this issue · comments

Package version

1.6.0

Describe the bug

I encountered an issue while trying to use the @vinejs/vine library for type inference according to the documentation at https://vinejs.dev/docs/getting_started#inferring-types-from-schema.

Code Snippet:

import vine from '@vinejs/vine'
import { Infer } from '@vinejs/vine/types'

const schema = vine.object({
  username: vine.string(),
  email: vine.string().email(),
  password: vine
    .string()
    .minLength(8)
    .maxLength(32)
    .confirmed()
})

type UserRegistration = Infer<typeof schema>

Expected Result:

type UserRegistration = {
   username: string
   email: string
   password: string
}

Error Message:

Cannot find module '@vinejs/vine/types' or its corresponding type declarations.

I followed the provided documentation carefully, and the code is correct. However, I'm still facing an issue locating the @vinejs/vine/types module.

Thank you for your time and support!

Reproduction repo

No response

can you please share your tsconfig?
you'll need moduleResolution set to at least Node16

This is my tsconfig.json file:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2021",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": true,
    "strict": true,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true
  }
}

FYI, I tried vine.js in my Nest.js project.

Vine is ESM-only so it's incompatible with NestJS, which still uses CommonJS

So, do you mean I can't use Vine in NestJS project?

yeah as long as NestJS doesn't migrate to ESM, it won't be possible

give a try to Adonis.js, a backend framework that will support ESM for version 6 🙂

I thought "Vine" could be used in NestJS :(

Yeah, I also planned to try Adonis.js after the release of version 6.

I thought "Vine" could be used in NestJS :(

You will be able to use vine when NestJS supports ESM. It seems that it is not planned at the moment.

Ohh ok. Thanks for the clarification. 👍