-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Typescript definition issue #29
Comments
How are you importing the module? The following works for me: import copy = require('clipboard-copy')
copy('test') |
Just like so: import copyToClipboard from 'clipboard-copy'; and the code works fine. Actually, I've never had to use |
The vast majority of the code on Npm uses When I'm using
If I pass You can also see the difference in the output: import copy from 'clipboard-copy'
copy('test') becomes: var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var clipboard_copy_1 = __importDefault(require("clipboard-copy"));
clipboard_copy_1["default"]('test'); whilst, import copy = require('clipboard-copy')
copy('test') becomes var copy = require("clipboard-copy");
copy('test'); In both cases the typings works correctly for me... |
Actually, I wasn't aware of Some CommonJS libraries are imported in the following way though: I'm using {
"module": "es2015",
"compilerOptions": {
"lib": ["dom", "es2015", "es2016", "es2017"],
"baseUrl": "./src/",
"jsx": "react",
"target": "es5",
"strict": true,
"noUnusedLocals": true,
"noImplicitThis": true,
"noImplicitAny": true,
"noUnusedParameters": true,
"strictNullChecks": true,
"strictBindCallApply": true
}
} |
Here are some more info on it: https://github.com/DefinitelyTyped/DefinitelyTyped#a-package-uses-export--but-i-prefer-to-use-default-imports-can-i-change-export--to-export-default I don't believe that there is anything we can do to make this work from our side (apart from making it an ES module which would be a breaking change). Do you have any example of other packages that work? As far as I know, it would actually be a bug if it worked... |
How about migrating the code to TypeScript? |
@gfx that wouldn't make a difference since in that case, we would do Until ES modules become stable and widely used in Node.js I think that we'll stick with CommonJS style |
Sorry for the late reply. I think we can close the issue, it's been a long time and |
I'm getting a TS error about:
Cannot invoke an expression whose type lacks a call signature
.From what I found out, using the following typedef locally works fine:
I'm on Typescript 3.2.
The text was updated successfully, but these errors were encountered: