alephjs / aleph.js

The Full-stack Framework in Deno.

Home Page:https://alephjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build error in module: this is defined/typed as an arg is not skipped

elverskog opened this issue · comments

I get a browser error (pasted at bottom) when running aleph as deno task dev, when using pouchdb_deno.

running deno task build, with that module in place, is a whole different topic (panic about threadpooling).

Anyways...In pouch (a few modules really) there's a callback that is supposed to be passed down a chain.
It becomes undefined early in the chain, eventually causing an error.
The callback gets lost because the function idb below is run via call and in Aleph this becomes the first argument, causing opts to equal the callback.

  function idb(
    this: any,
    opts: PouchDB.IdbAdapter.IdbAdapterConfiguration,
    callback: any,
  ) {

If I make a local copy of the module and remove this: any in that file, the error(s) go away.

However, my understanding, from speaking to the author of pouchdb_deno ( @aaronhuggins ) is that the TypeScript compiler and the Deno bundler both strip this keyword out (if it is in the first position) but that the Aleph bundler does not.

Is this something that should be adjusted?

The error(s):
Uncaught TypeError: fun is not a function
tryCode pouchdb-adapter-idb.js:786
runCallback pouchdb-adapter-idb.js:801
completeSetup pouchdb-adapter-idb.js:1511
oncomplete pouchdb-adapter-idb.js:1543
onsuccess pouchdb-adapter-idb.js:1541
init pouchdb-adapter-idb.js:1476
IdbPouch pouchdb-adapter-idb.js:969
runAction pouchdb-adapter-idb.js:800
applyNext pouchdb-adapter-idb.js:796
enqueueTask pouchdb-adapter-idb.js:808
IdbPouch pouchdb-adapter-idb.js:968
idb mod.ts:41
PouchDB pouchdb-core.js:1401

Relevant TypeScript compiler doc for using this parameter definition.

https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function