cds-astro / aladin-lite

An astronomical HiPS visualizer in the browser
https://aladin.cds.unistra.fr/AladinLite/
GNU General Public License v3.0
103 stars 42 forks source link

create public API in typescript #187

Open pahjbo opened 3 months ago

pahjbo commented 3 months ago

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 commented 3 months ago

@pahjbo - the documentation is here to provide the public API. It still needs to be completed of course (see https://github.com/cds-astro/aladin-lite/issues/186) but it is intended to provide public user API.

pahjbo commented 3 months ago

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

tylertucker202 commented 3 weeks ago

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.