-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Added TypeScript definitions, updated babel to copy .d.ts files #76
Conversation
…o copy type definition files to lib/ in build script
Hey, thanks a lot for working on this @tcarrio. This is looking really great! 🎉 How are you test these changes? Also, tell when you think this is ready for a review. |
Most of the typing is based on the API so with unit testing it would be mocking successful/failed requests but it would still make the assumption of what those types are. I'm going to do some more work with the types as they are here to see that everything works as expected with the client itself, outside of the request/response types. The TypeScript definitions are exported from the specific modules they were defined in with JavaScript. Certain methods don't exist in this client that I have found on the docs so they're stubbed with incomplete types. More would come with work on the client, which I may also take a further look at after this. Would there be interest in converting the project to TypeScript entirely? It does alleviate concern for mismatching types. Figured I'd ask for a follow-up commit. |
I'd be happy to convert this codebase to TypeScript; it'll still be usable from JavaScript code, and we're generally aiming to move all of our JavaScript codebases to TypeScript. And this is nicely small/encapsulated enough that we can reasonably switch it over and then verify that it works well. @tommyip @andersk @showell FYI as they may have some thoughts on the details. |
That's awesome news. I can take this change beyond TypeScript definitions to completely TypeScript while adhering to the existing tests to maintain the same functionality then. |
This has a couple changes I would want to make first, but I am also working on a full TypeScript conversion that uses Babel still. |
The existing code uses diff --git a/.eslintrc b/.eslintrc
index 545ff1b..98cf819 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,5 +1,5 @@
{
- "extends": "airbnb",
+ "extends": "airbnb-typescript",
"globals": {
"fetch": false,
"FormData": false
diff --git a/package.json b/package.json
index e02062a..b0186d2 100644
--- a/package.json
+++ b/package.json
@@ -22,21 +22,23 @@
"@babel/plugin-transform-destructuring": "^7.6.0",
"@babel/plugin-transform-instanceof": "^7.5.5",
"@babel/preset-env": "^7.6.3",
+ "@typescript-eslint/eslint-plugin": "^2.15.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"eslint": "^6.5.1",
- "eslint-config-airbnb": "^18.0.1",
+ "eslint-config-airbnb-typescript": "^6.3.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.16.0",
"mocha": "^6.2.1",
- "sinon": "^7.5.0"
+ "sinon": "^7.5.0",
+ "typescript": "^3.7.4"
},
"scripts": {
"build": "babel -D -d lib/ src/",
"prepare": "npm run build",
"prepublish": "npm run build",
- "lint": "eslint src test examples",
+ "lint": "eslint src test examples --ext js,ts",
"test": "npm run lint && npm run build && mocha test/*",
"call": "node examples/interactive_call_endpoint.js"
}, |
Also, this needs a diff --git a/package.json b/package.json
index b0186d2..6ff461b 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,9 @@
"fs-readfile-promise": false
},
"dependencies": {
+ "@types/isomorphic-fetch": "^0.0.35",
+ "@types/isomorphic-form-data": "^2.0.0",
+ "@types/node": "^13.1.4",
"fs-readfile-promise": "^3.0.1",
"ini": "^1.3.5",
"isomorphic-fetch": "^2.2.1",
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..e08f8b9
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "target": "ES2019",
+ "noEmit": true,
+ "isolatedModules": true,
+ "strict": true,
+ "moduleResolution": "node",
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true
+ },
+ "include": [
+ "src/**/*",
+ "test/**/*",
+ "examples/**/*"
+ ]
+} |
I'll make sure to format all the updates accordingly. Currently this only copies over the TypeScript definitions so the TypeScript package isn't really necessary. But the switch to TS entirely will incorporate all of these |
The |
I'll have time to look at this in the next few days. Thanks for the heads up on those @andersk |
hi. is there any progress with TS support for |
Not yet @psychowico. I don't have as much time to work on this these days, if you wanted to pick it up. Otherwise, it may be some time. |
Hey. Can I pick this up? |
Feel free! I haven't had time to pick this up at all yet. |
*.d.ts
) files fromsrc/
inlib/
This PR is the current work-in-progress for Issue #74