-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add typescript support for aepp-sdk #1113
Add typescript support for aepp-sdk #1113
Conversation
…e json to enable type detection.
Hi @davidyuk , |
@davidyuk I made a final change and customized the Happy to receive your feedback! |
@davidyuk Any update regarding the review? |
Hi @davidyuk please check this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these notices are resolved in #1131. @the-icarus please take a look at that PR.
@@ -21,3 +21,4 @@ coverage.* | |||
/examples/**/dist | |||
.history | |||
.site | |||
*.tgz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm pack
is an edge case, I don't think that ignore files shouldn't be aware of it
@@ -0,0 +1,2 @@ | |||
es_src |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.npmignore
overrides .gitignore
, currently it brings extra files to the packed package, for example, I got a local package about 40mb because of node_modules
of examples. So, if .npmignore
is used, it should contain all records from .gitignore
. Alternatively, I'm proposing to use a files
property of package.json
to add only necessary folders (dist
and es
).
@@ -56,7 +56,7 @@ export const DENOMINATION_MAGNITUDE = { | |||
* @param {String} [options.denomination='aettos'] denomination of amount, can be ['ae', 'aettos'] | |||
* @return {String} | |||
*/ | |||
export const toAe = (value, { denomination = AE_AMOUNT_FORMATS.AETTOS } = {}) => formatAmount(value, { denomination, targetDenomination: AE_AMOUNT_FORMATS.AE }) | |||
export const toAe = (value: string | number | BigNumber, { denomination = AE_AMOUNT_FORMATS.AETTOS } = {}) => formatAmount(value, { denomination, targetDenomination: AE_AMOUNT_FORMATS.AE }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line is too long, I'm planning to limit it by linter in future
@@ -3,42 +3,32 @@ | |||
* @module @aeternity/aepp-sdk/es/utils/bignumber | |||
* @example import { parseBigNumber, asBigNumber, isBigNumber, ceil } from '@aeternity/aepp-sdk/es/utils/bignumber' | |||
*/ | |||
import BigNumber from 'bignumber.js' | |||
import BigNumber from 'bignumber.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;
is not allowed by our linter rules, need to switch from standard
to ts-standard
for linting
"prepare": "npm run build", | ||
"genChangelog": "conventional-changelog -p angular -i CHANGELOG.md -s", | ||
"prepublishOnly": "npm run docs:docco && npm run docs:api" | ||
"prepublishOnly": "npm run docs:docco && npm run docs:api", | ||
"prepack": "tsc && node tooling/prepack.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proposing to move tsc
to build
script
@@ -2,7 +2,8 @@ | |||
"name": "@aeternity/aepp-sdk", | |||
"version": "7.7.0", | |||
"description": "SDK for the æternity blockchain", | |||
"main": "dist/aepp-sdk.js", | |||
"main": "dist/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file is es/index.js
, as I understand this change needs to be reverted
"@babel/register": "7.10.1", | ||
"@babel/runtime": "^7.10.2", | ||
"@types/bignumber.js": "^5.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proposing to remove this package because of warning:
npm WARN deprecated @types/bignumber.js@5.0.0: This is a stub types definition for bignumber.js (https://github.com/MikeMcl/bignumber.js/). bignumber.js provides its own type definitions, so you don't need @types/bignumber.js installed!
"outDir": "./dist/es", | ||
"noImplicitAny": true, | ||
"module": "es6", | ||
"target": "es2017", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switching it to es5
should solve #196
@@ -0,0 +1,5 @@ | |||
const fs = require('fs-extra') | |||
|
|||
fs.move('es', 'es_src') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposing a more radical change: to rename current es
to src
(as it should be) and to build typescript straight to /es
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
refactored version merged in #1131 |
I added basic typescript support for the aepp-sdk so we are able to code in typescript and also users of the sdk get type completion in typescript.
This is an initial pull request which already contains transformation where I already converted
utils/account-formatter.js
andutils/bignumber.js
to typescript.There are still open discussions how we want to build the SDK. With the current setup javascript users might only able to use the build assets from
dist
so I guess we still need to adjust the build process but this is something I want to discuss with the current developers/maintainers of the SDK.Happy to receive your feedback.