Reputation: 5187
I am developing an application using ASP.NET Webforms and I am having difficulty in using clipboardjs with TypeScript.
What I have tried:
a. Downloaded clipboardjs (https://clipboardjs.com/) and added its reference under script folder.
b. Installed clipboardjs typings using nuget.
c. Installed jquery and its typings and added jquery reference to project.
See the file details below,
Now, when I tried to follow their documentation and put some code, I am getting "Cannot find the name Clipboard" error in typescript.
What am I missing? Any suggestion / help will be greatly appreciated.
Upvotes: 1
Views: 1558
Reputation: 23443
If you're on TypeScript 2.0 or later, you can get declaration files for clipboard by running
npm install @types/clipboard
At that point, if you're not able to just write new Clipboard
in your file without getting an error, you need to add "clipboard"
to the "types"
field in your tsconfig.json
:
{
"compilerOptions": {
"types": ["clipboard"]
}
}
This will tell TypeScript to walk up the directory chain and try to find types for the clipboard
package in each node_modules
folder.
Upvotes: 2