Closed RIAEvangelist closed 8 months ago
I'm working on creating the ambient type declarations. :wave:
README.md
since I expect if they're public there, they should be available everywhere (I say this because some private fields, and method's haven't been added for things like DominosFormat
where the user isn't expected to use it).Address
, Customer
, Image
, Item
, Menu
, NearbyStores
, Order
, Payment
, Store
, Tracking
.urls
from dominos
, useInternational
, canada
, usa
from dominos/utils/urls.js
, and Base64File
used by Image
.Types that aren't part of a library, are ambient type declarations. Hence the d.ts
extension. There's two options when it comes to using them:
npm i -D @types/node @types/dominos
The Node types are what a TypeScript user would have to install anyhow — and some of them are used in @types/dominos
.
Since the library is using native JavaScript modules — this poses a problem for TypeScript when using things like nodemon
, and ts-node
in tandem. I propose this be included in the readme. The problem stems from when [ts-node fails when ES Modules are in the dependency graph in Node.js](). These are the steps to get it working:
package.json
include "type": "module"
tsconfig.json
should have:
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node"
}
}
nodemon.json
config (this is what resolves the issue):
{
"execMap": {
"ts": "node --loader ts-node/esm"
}
}
I would prefer if someone more experienced using the library could try out the types first (TypeScript knowledge is not required):
npm init -y && npm i dominos && npm i -D @types/node
inside a folder (TypeScript language server is part of VS Code so you don't have to install it here).index.d.ts
file at the root of the project, so it gets picked up.index.ts
file (the name is irrelevant, just make sure it has a .ts
extension).
I would like to support typescript users, but I need a
types.d
file for the module to do so easily for Jr devs. I would appreciate it if someone would contribute this file to the repository.Thank you. 🍕 🥳 🎉