Search code examples
typescriptvisual-studio-codeevernote

vscode typescript intellisense not working for evernote


I've installed https://www.npmjs.com/package/@types/evernote to my project to get evernote types definition.

When I import Evernote as follow

import { Evernote } from 'evernote';
const client = new Evernote.Client({
  consumerKey: '...',
  consumerSecret: '...',
  sandbox: true,
  token: '...'
});

Vscode recognize Evernote and suggests me autocompletion and lists all the available methods and objects. However, When I run my project, it says TypeError: Cannot read property 'Client' of undefined

When I import Evernote as below, I can run my app:

import * as Evernote from 'evernote';

But I don't get the autocompletion working.

How should I import my evernote module to make it works properly?

I've also tried

import Evernote = require('evernote');

but it doesn't work neither


Solution

    • import { Evernote } from 'evernote' is importing the named export Evernote.
    • import * as Evernote from 'evernote' is special TS syntax to import the module.
    • import Evernote from 'evernote' is importing the default export (note, you'll need to enable esModuleInterop or syntheticDefaultImports in your TSConfig.

    You're looking for import { Client } from 'evernote'.