Adding watermark.js to angular 4 - javascript

Hi I am trying to add watermark to the image and i am trying to include watermark.js to the angular 4. Could someone please tell me how to include watermark.js in angular. I tried installing using
npm install watermark -save
and then using the
import * as watermark from 'watermark';
but the above line throws me an error stating cannot find module 'watermark'
can someone please tell how i can import the watermark.js and use it to watermark my image?

You're missing type definitions for watermark.js. However, judging by this github issue, the authors of this lib currently don't offer them.
You have a couple of possibilities to fix this:
Declare type definition manually. This is the quickest way, but you'll also lose all type safety when it comes to using this lib
Help with creating proper type definitions (as shown in this tutorial). This way you'll be type safe, learn a lot about the TS type system, and, as a bonus, contribute back to the OSS community.
Good luck!

Related

How to Clear this "Type annotations can only be used in TypeScript files.ts(8010)" error in VSCODE

I am using nest js as my backend and i get this type annotation error often. I am unable to solve this error. The file extension by default is .ts file. I even get this error when i use React with typecript. Is there any other options to solve this problem without disabling the validation.
I have tried disabling the typescript validation as some of the articles and Q&A suggest. But whats the use of disabling it when we use the typescript. I tried reinstalling the typecript and ESLInt too.
Make sure your language in the bottom right window angle is set to TS
What exactly you did to lose it? you haven't provided links to what you did

WebStorm autocomplete for npm modues

I recently started following a course about Node.js. I have an issue in WebStorm. I am trying to explore the validator module. The autocomplete in WebStorm doesn't give me choices for methods unless I select the default in the drop-down list which is unusual across all programming languages including JS !!! is it an issue and if yes what is the solution?
The problems occur because of the weird way properties are defined.
Normally installing Typescript stubs can be used as a workaround. But this doesn't work for validator due to WEB-43528. Please follow this ticket for updates
Using import validator from "./validator"; instead of require() can be used as a workaround

Localization using react typescript

I am new to React, and I want to localize every component in my project, the component extension is tsx.
I want the text to change from English to French.
I have tried using react-intl and react-i18n. My problem is that to install these libraries they find on #types but my project use typings.
Can someone show how to do it manually? Such as a drop down which shows you languages and when selecting the language the text changes?
Please help me.
Thanks in advance.
You can always just copy the *.d.ts files from whatever project has them and use those directly. You can also make a pull request directly if typings are missing for a project that you need them for.

Typescript extract knowledge from js object

I'm creating a ionic (cordova) product and I'd like to utilize typescript and its benefits for autocompletion optimally. But since many of the plugin objects don't stem from concrete classes I don't know how/if there is a way to utilize the knowledge from the plugin files (which are .js). If there is a way to do this I'd of course like to know this.
As mentioned in my comment you can use Typescript definition files to provide type information.
There are definition files for common Cordova plugins on Definitly Typed.
If you can't find type information for the plugin you're looking for, you can write your own definition file.
If there is a way to do this I'd of course like to know this.
Yes. Just add allowJS to true in the tsconfig.json compilerOptions. Your IDE should magically start working with .js files ;)
More
Give http://alm.tools/ a go. I wrote it with such workflows in mind 🌹

Visual Studio Code Suggestions Don't Pop Up but Parameter Hints Do

I'm new to VS Code and am trying to get IntelliSense code completion working for both dojo and arcgis api for javascript. I've installed both type definitions globally using typings. I get parameter hints on methods only after they've been completely typed out but no suggestions while typing. (I should clarify that I do get suggestions but just not for the methods/parameters I'm looking for.) I've tried both jsconfig and tsconfig (with allowJs set to true) with the same result.
Example for dojo string substitute() method:
No suggestions :
Parameter hints :
As you can see from the images , it appears to be referencing the type definitions but for some reason its not providing the suggestions for autocomplete. I'm obviously missing something or just don't understand how its supposed to work.
Any help would be greatly appreciated. Thanks
Autocomplete currently can't be accomplished with JavaScript because of the way dojo asynchronously loads modules. However, it can be accomplished with TypeScript by tricking ts that your dojo classes are ts classes. https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/dojo

Categories

Resources