compromise
compromise copied to clipboard
TypeScript types for extending compromise-sentences
:wave: Hi all.
I seem to be running into this closed issue using:
{
"compromise": "^13.11.1",
"compromise-sentences": "^0.3.0",
"typescript": "^4.0.0"
}
I extend and use it as so:
import nlp from "compromise"
import sentences from "compromise-sentences"
const sentenceNlp = nlp.extend(sentences)
const test = sentenceNlp("Let's just see what happens.")
console.debug(test.sentences().toPastTense())
But TypeScript is mad at me.
index.ts:7:20 - error TS2339: Property 'toPastTense' does not exist on type 'ExtendedDocument<{ sentences(n?: number): Sentences; }, {}, {}>'.
7 console.debug(test.sentences().toPastTense())
~~~~~~~~~~~
My tsconfig is minimal and uses ES Module interop
{
"compilerOptions": {
"module": "CommonJS",
"target": "es6",
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"strict": false,
"skipLibCheck": true,
"esModuleInterop": true
},
"exclude": ["node_modules"]
}
Is is possible this has resurfaced? Or am I just being dumb?
hi Chris, you're definitely not dumb. This stuff is very hard. I have no idea how @Drache93 figured out how to do this. He's basically the smartest person alive.
😂 Definitely not the reason I noticed this message! If you want smart, check this website 😄 https://spencermounta.in/
So the previous issue was the overloading. However when I try your example, I'm seeing 'sentences' as 'any'
Could be my setup. Otherwise something broken in the typings.
Edit: Ah I see your error complains with correct thing, I'll fix mine and try again!
Working fine on a fresh install:
Same result with your tsconfig.json also.
:thinking: Well that's confusing. I've uninstalled, reinstalled, wiped node_modules, cloned a fresh repo. I have not spun up a new machine and tried it there to be fair.
Maybe different typescripts?
npm exec -- tsc -v
Version 4.2.4
But I also tested on 4.0.6 and still get the error. My VS Code TS server is 4.2.3.
It's not a huge issue as my use case is rather simple and I can just mangle the types but it sure is curious.
Update: okay, well, now I have installed on a fresh Ubuntu machine and it works. So... no idea what in my local setup would be causing this.
Wish me happy hunting! Any ideas? ~Maybe something in my VS Code config?~ Edit: it's not that, I forgot I'd debugged this from the terminal too.