Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module '"@webarkit/jsartoolkit-nft"' has no exported member 'ARToolkitNFT' #292

Open
timohausmann opened this issue Mar 16, 2023 · 4 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@timohausmann
Copy link

Hey, trying first steps with this module but get this error in my Vite react-ts project:

What I did:

$ npm create vite@latest (etc.)
$ npm i @webarkit/jsartoolkit-nft
import { ARToolkitNFT, ARControllerNFT } from '@webarkit/jsartoolkit-nft'

VS Code says:

Module '"@webarkit/jsartoolkit-nft"' has no exported member 'ARToolkitNFT'
Module '"@webarkit/jsartoolkit-nft"' has no exported member 'ARControllerNFT'

But it works when I add // @ts-ignore above.

Any ideas what' the issue?

@kalwalt
Copy link
Member

kalwalt commented Mar 16, 2023

Hi @timohausmann i have never had this issue, i can import it into ARnft without any problems. Probably a Vite issue? I have no experience with It so i can not say so much. Just a question are you trying to import in a JavaScript file or Typescript?

@kalwalt kalwalt self-assigned this Mar 18, 2023
@kalwalt kalwalt added the help wanted Extra attention is needed label Mar 18, 2023
@kalwalt
Copy link
Member

kalwalt commented Mar 20, 2023

@timohausmann you should add more infos about the issue and if possible a link to a repository with a minimal example to test. Thank you! 🙂

@timohausmann
Copy link
Author

timohausmann commented Mar 20, 2023

Hey, it's a TS file. The issue seems to be that both index.d.ts and index.ts have a default export of an object literal. I'm not sure if deconstructing default exports is valid synxtax. Named exports would be better here, like:

export ARToolkitNFT from "./ARToolkitNFT";
export ARControllerNFT from "./ARControllerNFT";

So currently this works with the default export:

import artools from '@webarkit/jsartoolkit-nft';
const {ARToolkitNFT, ARControllerNFT } = artools;

Codesandbox Demo of the issue: https://codesandbox.io/s/confident-engelbart-o1idk3?file=/src/index.ts

@kalwalt
Copy link
Member

kalwalt commented Mar 29, 2023

Hey, it's a TS file. The issue seems to be that both index.d.ts and index.ts have a default export of an object literal. I'm not sure if deconstructing default exports is valid synxtax. Named exports would be better here, like:

export ARToolkitNFT from "./ARToolkitNFT";
export ARControllerNFT from "./ARControllerNFT";

So currently this works with the default export:

import artools from '@webarkit/jsartoolkit-nft';
const {ARToolkitNFT, ARControllerNFT } = artools;

Codesandbox Demo of the issue: https://codesandbox.io/s/confident-engelbart-o1idk3?file=/src/index.ts

Yes you are right youn need to import in this way:

import artools from '@webarkit/jsartoolkit-nft';
const {ARToolkitNFT, ARControllerNFT } = artools;

I should update the Readme, but i'm going to make some changes and improvements to the C++ and Typescript code.
In regards of the question if deconstructing default exports is valid synxtax. probably is not strictly valid, so maybe better to use the named export. If you are interested i'm working on this feature in this PR #301

kalwalt added a commit that referenced this issue Mar 29, 2023
kalwalt added a commit that referenced this issue Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants