Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript typings are incomplete / not a module #14

Closed
phiresky opened this issue May 15, 2021 · 3 comments
Closed

Typescript typings are incomplete / not a module #14

phiresky opened this issue May 15, 2021 · 3 comments
Labels
bug

Comments

@phiresky
Copy link

@phiresky phiresky commented May 15, 2021

You can't import the main api via

import * as SQLite from "wa-sqlite";

because it throws this error:

File '.../node_modules/wa-sqlite/src/types/sqlite-api.d.ts' is not a module.

The dist file etc are also not typed, import SQLiteAsyncESMFactory from "wa-sqlite/dist/wa-sqlite-async.mjs"; throws a type error, as does import * as VFS from "wa-sqlite/src/VFS";

@rhashimoto rhashimoto added the bug label May 15, 2021
@rhashimoto
Copy link
Owner

@rhashimoto rhashimoto commented May 15, 2021

Hmm. I don't write in Typescript. I added the declaration file because it was the easiest way to generate documentation and provide VSCode Intellisense hints (for Javascript).

It looks like you can at least compile by using a local Javascript file to import from the package and then import that Javascript into Typescript. But that's horrible because all the API signatures are lost.

I haven't found great Typescript documentation for what I'm trying to do so I haven't figured out how to fix this, but I'll keep poking at it.

rhashimoto pushed a commit that referenced this issue May 15, 2021
@rhashimoto
Copy link
Owner

@rhashimoto rhashimoto commented May 15, 2021

@phiresky I checked in an attempt at a fix. Can you please give it a try? It appears to work on the attached micro-project.

wa-sqlite-ts-bug.zip

@rhashimoto rhashimoto closed this May 16, 2021
@rhashimoto
Copy link
Owner

@rhashimoto rhashimoto commented May 16, 2021

Reopening because it's fixed for the dist/ and API files but not other files like src/VFS.js. Need to check examples/ as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug
Projects
None yet
Development

No branches or pull requests

2 participants