Giter Club home page Giter Club logo

Comments (9)

zernonia avatar zernonia commented on May 25, 2024 1

Thanks for the issue. Seems like the issue lies with typescript not resolving correctly from the npm package.
The import should work nicely, just the typing are missing. Pushing a fix!

from radix-vue.

ChrisGV04 avatar ChrisGV04 commented on May 25, 2024

That's weird. I have been using the namespaced components without issues even today.

Make sure you have installed version 1.2.0 or greater, since that's when namespaced components where added.

from radix-vue.

aleksey-hoffman avatar aleksey-hoffman commented on May 25, 2024

@ChrisGV04 yep, I have "radix-vue": "^1.4.6". I restarted VScode to make sure it's not caused by TS watcher. Still gettting the error

from radix-vue.

aleksey-hoffman avatar aleksey-hoffman commented on May 25, 2024

@ChrisGV04 the type error dissapears when I import it from dist:

import {Dialog} from 'radix-vue/dist/namespaced';

Instead of what's specified in the docs:

import {Dialog} from 'radix-vue/namespaced';

But then I get Vite error:

[plugin:vite:import-analysis] Missing "./dist/namespaced" specifier in "radix-vue" package

Not sure if it's meant to be exported from dist or if it's just a typo in the docs

from radix-vue.

ChrisGV04 avatar ChrisGV04 commented on May 25, 2024

I'm not sure why you can't use radix-vue/namespaced. I have been using it exactly as the docs say since I started using Radix Vue.

Here are some suggestions that I can think of:

  1. I use pnpm instead of npm or yarn. I don't know if this makes a difference.
  2. Try to add a .npmrc file to your project directory with this line: shamefully-hoist=true then delete the node_modules and package-lock file and try to run install again.
  3. Try adding "type": "module" to your package.json and reloading VS Code.

I have those on my own project using Radix Vue and it works perfectly

from radix-vue.

aleksey-hoffman avatar aleksey-hoffman commented on May 25, 2024

@ChrisGV04 it seems the type declaration for radix-vue/namespaced is not exported from index.d.ts file of the package.

I have "type": "module" specified. Probably shouldn't create .npmrc just for one package.
Perhaps pnpm resolves missing types automatically somehow

image

from radix-vue.

ChrisGV04 avatar ChrisGV04 commented on May 25, 2024

Just checked the source code and it does export the namespaced types correctly.

If they weren't exported, it wouldn't work for anyone at all. But it works fine in my case.

I use Nuxt 3, so the .npmrc is actually part of the starter template. I also had it on Vite projects, but I'm not sure if it could affect your app. I suggest you give it a try and revert the changes if it breaks something else

from radix-vue.

ChrisGV04 avatar ChrisGV04 commented on May 25, 2024

The namespaced types are exported in the node_modules/radix-vue/package.json and can be found at node_modules/radix-vue/dist/namespaced/index.d.ts.

from radix-vue.

aleksey-hoffman avatar aleksey-hoffman commented on May 25, 2024

@ChrisGV04 could you please take a look at my tsconfig? Is there anything wrong with it?

from radix-vue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.