-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Cannot import certain npm packages when using TypeScript #2062
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
Comments
Some other imports require different syntax now. For instance, in a traditional JS project, this is fine: import validator from 'validator'; In a TS project, it's not:
This fix works for validator, but does not work for moment: import * as validator from 'validator'; |
This seems to be a bug in TypeScript, because per its documentation, In this case, it only works properly when Note: Vue CLI simply scaffolds a standard usage for upstream deps like webpack and typescript, it doesn't do any magic beyond the |
Closed via 350f77b |
Ah, gotcha. Still, glad to see a simple tsconfig.json change in the Vue TS template fixes it! |
Just came across this comment:
So it's a bug in their documentation. 🙁 |
Should be fixed by microsoft/TypeScript-Handbook@8e974c8, and we'll update the website documentation soon. Sorry about all this. |
@DanielRosenwasser Ahh, yes. My |
Version
3.0.0-rc.10
Node and OS info
Node 8.10, yarn 1.9.2, macOS 10.13.6
Steps to reproduce
https://github.com/ffxsam/repro-import-bug
yarn && yarn serve
What is expected?
I expect the app to run with no issues.
What is actually happening?
Error is given: Cannot invoke an expression whose type lacks a call signature. Type 'typeof moment' has no compatible call signatures.
Using
import moment from 'moment'
also does not work.The text was updated successfully, but these errors were encountered: