import * as $ from "jQuery"; - typescript-typings

I try to define jquery selector inside ts file but I have an error with message;
[ts] Cannot find name '$'
here is the ss below;
I've searched on net somes taking about typings that I dont have in my project solution, if I need it to solve this can you also explain me how can I get in clear?

The response is now rather
npm install jquery #types/jquery

After
npm install jquery --save
and
typings install dt~jquery --save
you can use
import * as $ from 'jquery';
Then you should be able to work with
$(...)
In Aurelia you need to register the dependency "jquery", I don't know if something similar has to be done in Angular.

Related

hapi.js Version 18.x Typings

I recently upgraded my project to use the #hapi/hapi node modules vs. the old hapi module. I'm using version 18.3.1 ("#hapi/hapi": "^18.3.1").
My Typescript definitions no longer work as the Import reads: import * as Hapi from 'hapi';
When running the node process I get the module not found error. Is there a way to point the #types/hapi typings to the new #hapi/hapi module?
Uninstall the #types/hapi dependency. This didn't work for me moving to 18.3.1. Instead install #types/hapi__hapi. I searched for a while and ran across that package, which seems to do the trick.
npm un #types/hapi -D
npm i #types/hapi__hapi -D
Then instead of importing from 'hapi', import from '#hapi/hapi'.
import * as Hapi from '#hapi/hapi';

Can not use dependency module right away after installing with --save-dev

I don't know if this is common. But why I can not use (import or require) dependency modules right away after I installed it with npm install --save-dev module?
Yet I have to reinstall it again using npm install --only=dev and only after that, I'd be able to require the module.
Is this the normal and the most practical way?
You did it the wrong way around. It's: npm install <package name> --save-dev
it can be that if you try to require() it through JS, that it says that the require() method is undefined. But it'll still work if you test your package out.
Hope this helps
Here is an example on how I require my packages:
#!/usr/bin/env node
var awesomevarname = require('packagename');

react-router 3.10.10 IndexRoute

I'm trying to figure out how to build apps with react and feathers. I found Ben Awad's YouTube tutorial series (https://www.youtube.com/watch?v=etq_vv_RVcU&index=2&list=PLN3n1USn4xlnulnnBGD2RMid_p7xVj9xU) and was following along with the code. However I somehow got an issue he didn't cover. When I go to run the code produced at the end of this video I get the following error:
./src/index.js
36:23-33 'react-router' does not contain an export named 'IndexRoute'.
Most of the stuff I've found seems to suggest that IndexRoute was phased out in v4, however running npm -v react-route returns 3.10.10 so I don't think it should be affected (could be wrong). Does anyone have any thoughts about what might be causing this issue? Thank you.
I think IndexRoute was removed since version 2 from react-route so you must use version 2 of react-route, in order to do so you can install it using npm:
npm install --save react-router#2
IndexRoute was removed in version 4 meaning that version 3.x still has it. Install with npm:
npm install --save react-router#3.x
or
yarn add react-router#3.x

TypeScript definition for builtin 'net' NodeJS types?

I am trying to write a TCP client application, and for that the builtin 'net' package seems to do the job. However, I am not able to find the TypeScript definitions for the package.
https://nodejs.org/api/net.html
Since it is built into NodeJs, I am almost sure it exists, but it cannot find any information about it anywhere.
Thanks!
They are available in the official typings for node. Install it with npm install #types/node --save-dev and you can import it in your TypeScript code using: import * as net from "net";

how to use #types/node in node application

I am working in VSCode on Ubuntu 16.04. I've created node project using below commads:
npm init
tsc --init
I've created a new file called index.ts. I'm trying to use fs and readling to read file contents. but when I am writing below lines of code at the top of index.d.ts:
import fs = require('fs');
import readline = require('readline');
I'm getting below error:
can not find module 'fs' and can not find module 'readline'
even process is not found.
I've installed typings of node from here using below command:
sudo npm install #types/node -global --save
Can anyone please help me how to resolve this error?
Since TypeScript 2.x, all typings are installed using npm like this: npm install #types/node.
For TypeScript 1.8, it might be better to typings to install the node types. For detail see the quickstart at: https://basarat.gitbooks.io/typescript/content/docs/quick/nodejs.html.
For what i know you have two options here:
(Recommended) Install devDepencencie npm install #types/node --save-dev, which will add the type module for http.
Create a index.d.ts file declaring a definition for http module, like:
declare module 'http. This method will not enable auto-complete for http methods

Resources