xlsx-populate icon indicating copy to clipboard operation
xlsx-populate copied to clipboard

would there be typescript definitions?

Open cfcodefans opened this issue 7 years ago • 8 comments

hi, is there any plan to provide typescript definitions? thanks

cfcodefans avatar Oct 02 '17 11:10 cfcodefans

They don't exist now and there isn't a plan for it at this point. Pull requests are welcome.

dtjohnson avatar Oct 06 '17 01:10 dtjohnson

would love to see this myself, maybe I'll take a crack at it if I can ever carve out some time. The very thorough use of JSDoc comments sure makes it easier. In fact... now that I look it up there's at least one project out there that does so automatically: https://github.com/teppeis/closure-ts

jbrecht avatar Oct 09 '17 21:10 jbrecht

Building from the JSDoc would be ideal so that there is no duplication of effort.

dtjohnson avatar Oct 09 '17 21:10 dtjohnson

+1

m-farahmand avatar Jun 05 '18 15:06 m-farahmand

+1

Spiderpig86 avatar Jul 13 '18 13:07 Spiderpig86

I decided this was the lib to use, but decided not for this very reason.

atljoseph avatar Mar 26 '19 00:03 atljoseph

I've started a project to create/test/improve a typescript definition file for xlsx-populate. Feel free to give it a try: https://github.com/JanLoebel/types-xlsx-populate

Any help is appreciated!

JanLoebel avatar Jun 05 '19 17:06 JanLoebel

Adding type definitions to this project is quite simple:

  1. Run npm install --save-dev typescript.
  2. Create a tsconfig.json file like:
    {
        "compilerOptions": {
            "target": "ES5",
            "outDir": "types",
            "newLine": "LF",
            "allowJs": true,
            "declaration": true,
            "emitDeclarationOnly": true
        },
        "include": [
            "lib"
        ],
        "compileOnSave": false
    }
    
  3. Add "types": "types/XlsxPopulate.d.ts" to package.json.
  4. Run npx tsc to generate the declaration files.

image

Unfortunately, the JSDoc comments have various issues. Adding "checkJs": true in tsconfig.json results in 653 errors being found. Some of those could probably be fixed by using import types where necessary, but in other cases the types are very weak (there are a lot of ... does not exist on type '{}' errors, for example).

😞

Edit: Other issues:

  • TypeScript doesn't support function overloads in JSDoc (issue).
  • JSDoc will likely choke on TS-specific syntax like @typedef {import("./Range")} Range (issue).

glen-84 avatar May 26 '20 20:05 glen-84