问题
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
回答1:
import { Evernote } from 'evernote'
is importing the named exportEvernote
.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 enableesModuleInterop
orsyntheticDefaultImports
in your TSConfig.
You're looking for import { Client } from 'evernote'
.
来源:https://stackoverflow.com/questions/58566171/vscode-typescript-intellisense-not-working-for-evernote