简体   繁体   中英

Typescript Intellisense not working in even VS code even after adding type definition files

I started a project to understand how externally loaded types work with Typescript programming. So I started with a ts file which imports JsSHA and following is the code that I use to test the working of this library.

import * as jsSHA from "jssha";

class sha{
    shaObj: any;
    hash : string;

    constructor(){
        this.shaObj = new jsSHA("SHA-512","TEXT");
        this.shaObj.update("This is a test object");
        this.hash = this.shaObj.getHash("HEX");
    }
}

var s:sha = new sha();
console.log(s.hash);

In addition to adding JsSha.js via npm I also added the type definitions (.d.ts) of this library based on what is said here . Despite doing all this I still don't get any intellisense related to JsSha object or the constructor method of this library. Am I missing something here that I should do in order to get things work.

PS: I restarted VS Code, Just in case to avoid any issues due to caching. Also updated all the existing packages that have any updates.

I'm using TS at 2.1.6, here are my dependencies and devdependencies from my package.json file:

"dependencies": {
  "jssha": "^2.2.0",
  "retyped-jssha-tsd-ambient": "0.0.0-0",
  "typescript": "^2.1.6",
  "typings": "^2.1.0"
},
"devDependencies": {
  "retyped-jssha-tsd-ambient": "0.0.0-0"
}

The following set up provides intellisense on my machine. It fetches the declaration files from NPM, which is the future of declaration files .

{
  "name": "temp",
  "version": "0.0.0",
  "dependencies": {
    "jssha": "^2.2.0",
    "typescript": "^2.1.6"
  },
  "devDependencies": {
    "@types/jssha": "0.0.29"
  }
}

jsSHA 智能感知工作的演示。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM