Compromise: Incorrect TypeScript Definition for sentences()

Created on 28 May 2020  路  5Comments  路  Source: spencermountain/compromise

I believe there is a TypeScript definition issue with sentences():

Error:

Property 'subjects' does not exist on type 'ExtendedDocument<{ sentences(n?: number | undefined): Sentences; }, World, Phrase>'.

TS Code:

import nlp from 'compromise';
import compromiseSentences from 'compromise-sentences';
const nlpEx = nlp.extend(compromiseSentences);

nlpEx('Hi bob').sentences().subjects();

Working on observablehq:
image

bug quick fix

All 5 comments

ah, thank you. good find.
will add to next release.

yeah, it looks like typescript doesn't see the new methods from the plugin, can reproduce.
@Drache93 any advice?
cheers

Ah yeh. @spencermountain Odd one, for some reason sentence() shows an overload, so it returns an ExtendedDocument if no parameters, otherwise returns Sentence correctly...I'll poke around!

Oh right :D sentences(): ExtendedDocument<Ext, W, Ph> is a built in function (looks like it should actually take a parameter also...).

/** overload original sentences() method and return Sentence class**/

you're right - i added the missing param and I think it's properly overloaded now.
Thanks!
fixed in 13.3.2

Was this page helpful?
0 / 5 - 0 ratings

Related issues

douglance picture douglance  路  4Comments

fhoffa picture fhoffa  路  4Comments

bikibird picture bikibird  路  3Comments

drhayes picture drhayes  路  4Comments

DominoTree picture DominoTree  路  5Comments