octet-stream / dinky

JavaScript bindings for Philomena JSON API. Supports sites such as Derpibooru and Furbooru.
https://www.npmjs.com/package/dinky.js
MIT License
7 stars 3 forks source link

Fix type declarations that prevent TypeScript builds from succeeding #12

Closed jozsefsallai closed 4 years ago

jozsefsallai commented 4 years ago

TypeScript builds fail with the following error:

node_modules/dinky.js/lib/Dinky.d.ts:47:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

47 class Dinky {
   ~~~~~

Found 1 error.

when using the following tsconfig:

{
  "compilerOptions": {
    "declaration": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "importHelpers": true,
    "module": "commonjs",
    "outDir": "./dist",
    "rootDirs": [
      "./src"
    ],
    "strict": true,
    "target": "es2017",
    "typeRoots": [
      "./node_modules/@types"
    ]
  },
  "exclude": [
    "node_modules",
    "./config.json"
  ],
  "include": [
    "./src/**/*.ts"
  ]
}

I haven't tested with other configurations, but I feel like the reason it fails is that I have strict and/or declaration set to true.

As noted in https://github.com/octet-stream/dinky/issues/11#issuecomment-701648613, the declare modifier is missing from the following types:

With these changes in place, the builds are successful and the type annotations/completions also work correctly (so the in-editor behavior hasn't changed).