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

create public API in typescript #187

Open
pahjbo opened this issue Aug 21, 2024 · 3 comments
Open

create public API in typescript #187

pahjbo opened this issue Aug 21, 2024 · 3 comments

Comments

@pahjbo
Copy link

pahjbo commented Aug 21, 2024

It might make it clearer what the intended public API was if it were created in typescript - it would at least allow for a distinction to be made between what is considered stable vs. what people might consider using by looking at the source code.

@bmatthieu3
Copy link
Collaborator

@pahjbo - the documentation is here to provide the public API. It still needs to be completed of course (see #186) but it is intended to provide public user API.

@pahjbo
Copy link
Author

pahjbo commented Aug 22, 2024

I was also thinking that if using in a TypeScript context, then having the type definitions makes everything better!

@tylertucker202
Copy link

tylertucker202 commented Nov 5, 2024

I'm looking forward to using this in my Typescript project as well. I looks like I'm able to generate ts files in the following way:

npm install typescript --save-dev
add a tsconfig.json

{
  // Change this to match your project
  "include": ["src/js/*"],
  "compilerOptions": {
    // Tells TypeScript to read JS files, as
    // normally they are ignored as source files
    "allowJs": true,
    // Generate d.ts files
    "declaration": true,
    // This compiler run should
    // only output d.ts files
    "emitDeclarationOnly": true,
    // Types should go into this directory.
    // Removing this would place the .d.ts files
    // next to the .js files
    "outDir": "typescript",
    // go to js file when using IDE functions like
    // "Go to Definition" in VSCode
    "declarationMap": true
  }
}

Add "types": "typescript/**/*d.ts", to package.json
and run the compiler with
npx tsc

Looks promising. Another idea is that we can add the *.d.ts files to the DefinitelyTyped, and have ts users install that separately. @bmatthieu3, let me know what you prefer.

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

No branches or pull requests

3 participants