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

npm install doesn't seem to work when using import #318

Open
nathan-i-martin opened this issue Jun 12, 2022 · 6 comments
Open

npm install doesn't seem to work when using import #318

nathan-i-martin opened this issue Jun 12, 2022 · 6 comments

Comments

@nathan-i-martin
Copy link

nathan-i-martin commented Jun 12, 2022

Could not find a declaration file for module 'parallax-js'. 'C:/dev/premier-properties-management/node_modules/parallax-js/dist/parallax.js' implicitly has an 'any' type. Try 'npm i --save-dev @types/parallax-js' if it exists or add a new declaration (.d.ts) file containing 'declare module 'parallax-js';

This was the issue I received from Visual Studio Code while attempting to import a fresh npm install of Parallax. import Parallax from 'parallax-js';
I've since changed it to const Parallax = require('parallax-js'); which seems to work just fine.

I did also attempt to run the npm i --save-dev @types/parallax-js command however that didn't work out.
I'm working in the Angular CLI environment (which includes babel), using typescript.

@nathan-i-martin
Copy link
Author

I might be wrong, but I believe this might be an issue with parallax not being written in Typescript. I might fork and work on implementing that

@reneroth
Copy link
Collaborator

We'd appreciate that! I've meant to get more familiar with typescript for some time now, and this might be a good opportunity :)

@nathan-i-martin
Copy link
Author

Absolutely! Let me give it a shot, I've forked and have a repo open over here:
https://github.com/nmartin42/parallax-ts

@nathan-i-martin
Copy link
Author

@reneroth I haven't tested, a bit busy and I also figured you probably have a better system for testing than I do. However, it seems as tho I've converted everything successfully!
Please give it a shot and if you think it's good I can issue a merge request.
Please also review my commits as I've made some changes here and there, which, if you don't like you may want to remove. For the most part everything is the same however.

@reneroth
Copy link
Collaborator

reneroth commented Apr 6, 2024

@nathan-i-martin thanks for the effort! I'd love to just keep this as a separate repository for now, since I (as you might've noticed sorry) barely have any time for stuff besides work and other grown up people things, so maintenance would be hard.

Would it be possible to only add the types definitions without changing the original JS file?

I am a bit confused though why it does not work by default, since I always assumed typescript was compatible with vanilla javascript?

@nathan-i-martin
Copy link
Author

Hey! I wrote this a while ago and it also was incomplete so forgive me if my memory isn't totally accurate on the issue.

I also assumed the same thing. Maybe newer versions of TS work with it.
Typescript is one of those things where it works when it works but if it doesn't, you're basically screwed haha

Theoretically tho someone should be able to import it as an "any" object and it would work. Like I said, it's been a minute since I've used parallax in a project so I'd have to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants