dijs / wiki

Wikipedia Interface for Node.js
MIT License
315 stars 61 forks source link

error TS2339: Property 'rawContent' does not exist on type 'Page'. #153

Closed Infinitay closed 3 years ago

Infinitay commented 3 years ago

Code Snippet

import wiki from 'wikijs';

(async () => {
    const kpopwiki = wiki({ apiUrl: 'https://kpop.fandom.com/api.php' });
    const gidle = await kpopwiki.page("(G)I-DLE");
    console.log(await gidle.rawContent()); # Property 'rawContent' does not exist on type 'Page'
})();

Output

PS E:\Documents\Code\NodeJS\k-pop\kpop-wiki-scraper> npm start

> kpop-wiki-scraper@1.0.0 start
> ts-node ./src/main.ts        

E:\Documents\Code\NodeJS\k-pop\kpop-wiki-scraper\node_modules\ts-node\src\index.ts:513
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
src/main.ts:6:26 - error TS2339: Property 'rawContent' does not exist on type 'Page'. 

6  console.log(await gidle.rawContent());
                           ~~~~~~~~~~

    at createTSError (E:\Documents\Code\NodeJS\k-pop\kpop-wiki-scraper\node_modules\ts-node\src\index.ts:513:12)
    at reportTSError (E:\Documents\Code\NodeJS\k-pop\kpop-wiki-scraper\node_modules\ts-node\src\index.ts:517:19)
    at getOutput (E:\Documents\Code\NodeJS\k-pop\kpop-wiki-scraper\node_modules\ts-node\src\index.ts:752:36)
    at Object.compile (E:\Documents\Code\NodeJS\k-pop\kpop-wiki-scraper\node_modules\ts-node\src\index.ts:968:32)
    at Module.m._compile (E:\Documents\Code\NodeJS\k-pop\kpop-wiki-scraper\node_modules\ts-node\src\index.ts:1056:42)
    at Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Object.require.extensions.<computed> [as .ts] (E:\Documents\Code\NodeJS\k-pop\kpop-wiki-scraper\node_modules\ts-node\src\index.ts:1059:12)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
PS E:\Documents\Code\NodeJS\k-pop\kpop-wiki-scraper> 

Additional Information

Is there any reason as to why I am unable to call Page#rawContent? The object is a Page and it seems as if we should be allowed to call the function..

Infinitay commented 3 years ago

Pardon my issue, I'm in the process of learning TypeScript and forgot about the declaration file. rawContent is missing from the Page interface within the declaration file. Not sure if this was intentional or not since the method is used privately within other methods such as Page#content.

dijs commented 3 years ago

This has been fixed and published in v6.2.1