.extend() not working with ES6's import statement
See original GitHub issueSorry if this has already been asked, but I couldn’t find the answer anywhere.
Basically, doing this works:
import nlp from 'compromise'
This too:
const nlp = require('compromise')
nlp.extend(require('compromise-ngrams'))
But this:
import nlp from 'compromise
nlp.extend(require('compromise-ngrams'))
Makes TSLint throw this error:
Property ‘ngrams’ does not exist on type ‘DefaultDocument’.
What’s the proper way of extending Compromise in an ES6 way?
Note: This is my tsconfig
:
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "out",
"sourceMap": true,
"rootDir": "src",
"strict": true,
"esModuleInterop": true // this makes my first example work
},
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
ES6 importing extended classes - javascript - Stack Overflow
I think the problem is that the Posts class is not being moved with the MyClass class; but without casting I have no...
Read more >Solved: How to import a javascript class and extend it in
Solved: Hi I am trying to use two Javascript projects - and export a class defined in one to be extended (inherited) in...
Read more >Extending a list in Python (5 different ways) - GeeksforGeeks
Let's see all of them one by one. 1. Using append() function: We can append at the end of the list by using...
Read more >can not use import statement outside a module - YouTube
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
Read more >Python List extend() Method - W3Schools
The extend() method adds the specified list elements (or any iterable) to the end of the current list. Syntax. list.extend(iterable). Parameter Values ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, for the feedback - will make a PR with updated Readme. So far the readme doesn’t include typescript specific stuff.
That did it. Thanks! Your suggestion worked even without the
compromise-numbers
package.Seems like if you want to use
import
, you have to doconst nlpEx = nlp.extend(extension_name)
.I’m glad you’re replying to these questions. The information you provide isn’t on the net, I think.
(And thanks, I didn’t know you could drop images here!)