joi-extract-type icon indicating copy to clipboard operation
joi-extract-type copied to clipboard

What's a consistent and working set of dependencies for Typescript 4?

Open helgridly opened this issue 3 years ago • 5 comments

I've been struggling to find a set of dependencies that work smoothly together. Here's what I've tried so far:

@hapi/joi@17 & [email protected]

Suggestion from this page. Gives me:

error TS2315: Type 'extractType' is not generic.

@hapi/joi@17 & [email protected] & @types/hapi__joi

error TS2694: Namespace 'Joi' has no exported member 'extractType'.

@hapi/[email protected] & [email protected]

Based on comments that joi-extract-type doesn't support 16+ yet.

error TS2315: Type 'extractType' is not generic.

@hapi/[email protected] & [email protected] & @types/hapi__joi

error TS2694: Namespace 'Joi' has no exported member 'extractType'.

I've also tried [email protected] & [email protected] per this comment but my TS novice-ness couldn't figure out where to put the provided joi.d.ts and how to set up typeRoots for it to be visible.

If someone can post a set of dependencies which work together I'd be super grateful.

helgridly avatar Dec 03 '20 20:12 helgridly

{
  "dependencies": {
    "@hapi/joi": "15.1.1",
    "joi-extract-type": "15.0.2",
    "@types/hapi__joi": "15.0.4"
  }
}

lonewarrior556 avatar Dec 03 '20 22:12 lonewarrior556

Thank you! Unfortunately, that still gives me:

error TS2694: Namespace '"/path/to/node_modules/@types/hapi__joi/index"' has no exported member 'extractType'.

helgridly avatar Dec 03 '20 22:12 helgridly

also I have

  "typescript": "3.8.3"

If that's not it, The way you are implementing it must be the issue. Make sure you have

import joi from '@hapi/joi';
import 'joi-extract-type';

whereever you use joi

lonewarrior556 avatar Dec 04 '20 14:12 lonewarrior556

You're right - I'd been flipping back and forth between using joi-extract-type and not, and in the last case hadn't imported it at all 🤦 Thank you!

This works for me:

    "typescript": "3.8.3",
    "@hapi/joi": "15.1.1",
    "joi-extract-type": "15.0.2",
    "@types/hapi__joi": "15.0.4"

The typescript 3.8 dependency is indeed important - running via ts-node works for me on TS 4 but gave me the known circular dependency error when I ran tsc.

@TCMiranda I'm happy to make a PR to the readme to document this, if you'd like.

helgridly avatar Dec 04 '20 15:12 helgridly

This set seems to work for me:

    "@hapi/joi": "17.1.1",
    "@types/hapi__joi": "15.0.4",
    "typescript": "4.1.3",
    "joi-extract-type": "15.0.8",

domdomegg avatar Oct 01 '21 12:10 domdomegg