Typescript definition issue
See original GitHub issueI’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:
declare module 'clipboard-copy' {
function clipboardCopy (text: string): Promise<void>
export default clipboardCopy
}
I’m on Typescript 3.2.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9
Top Results From Across the Web
Documentation - Type Declarations - TypeScript
TypeScript includes declaration files for all of the standardized built-in APIs available in JavaScript runtimes. This includes things like methods and ...
Read more >Typescript Definition · Issue #126 · React95/React95 - GitHub
I plan to use this package in an upcoming Reason project, so I'd rather not reimplement the type definitions by writing bindings, if...
Read more >Issues for TypeScript definitions | Drupal.org
Title Status Priority Category Component Re...
Usage example Active Normal Feature request Documentation 3
Definitions for core modules ‑ views_ui Active Normal Feature request Code...
Read more >Typescript definition issue for npm package for node and ...
The problem is I am running under typescript environment. So in the node client, I can consume the library just fine. This is...
Read more >TypeScript Programming with Visual Studio Code
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. It offers classes, modules, and interfaces to help you build robust...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gfx that wouldn’t make a difference since in that case, we would do
export = function clipboardCopy (text) { ... }
to maintain compatibility with the current ecosystem.Until ES modules become stable and widely used in Node.js I think that we’ll stick with CommonJS style ☺️
The vast majority of the code on Npm uses
module.exports = ...
and the correct way to import them areimport ... = require('...')
. Depending on how you have configured TypeScript or your bundler it might work withimport ... from '...'
also…When I’m using
import copyToClipboard from 'clipboard-copy'
I’m getting:If I pass
--esModuleInterop
totsc
it works. Do you haveesModuleInterop
in yourtsconfig
?You can also see the difference in the output:
becomes:
whilst,
becomes
In both cases the typings works correctly for me…