Skip to content
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

[TS] Refactor TS module #759

Merged
merged 5 commits into from
May 13, 2020
Merged

[TS] Refactor TS module #759

merged 5 commits into from
May 13, 2020

Conversation

nlordell
Copy link
Contributor

@nlordell nlordell commented May 13, 2020

This refactors the main module so it is now a TS module. This means that TS projects (like dex-price-estimator) should integrate better with the contracts as it is now a TS module.

Test Plan

Use yarn link with a TS project and ensure that this new module system works as intended. I will add detailed instructions soon.

@nlordell nlordell requested a review from a team May 13, 2020 07:35
Copy link
Contributor

@bh2smith bh2smith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good, but the changes seem like the content of two PRs.

@nlordell
Copy link
Contributor Author

nlordell commented May 13, 2020

This is good, but the changes seem like the content of two PRs.

Do you mean the @src path that was added should be a separate PR? I can do that.

edit: @bh2smith I reduced it as much as possible while keeping it buildable with the new structure. Let me know if its easier to review :).

Copy link
Contributor

@fleupold fleupold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine. Let's coordinate on how to merge this with the other outstanding ts paths

package.json Outdated
@@ -2,10 +2,10 @@
"name": "@gnosis.pm/dex-contracts",
"version": "0.2.15",
"description": "Contracts for dFusion multi-token batch auction exchange",
"main": "src/index.js",
"main": "build/commonjs/index.ts",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the path just common and doesn't the file still end in js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path was wrong, I noticed it when I used yarn link with dex-price-estimator.

@@ -0,0 +1,20 @@
import BN from "bn.js";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this conflict with #753 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to just remove the encoding.d.ts file once encoding.js becomes encoding.ts.

@nlordell nlordell force-pushed the ts-module-refactor branch from 4751213 to 3eb5972 Compare May 13, 2020 08:28
@nlordell
Copy link
Contributor Author

Seems fine. Let's coordinate on how to merge this with the other outstanding ts paths

Looks like tsc doesn't copy .js files to the build output, so the import paths on the compiled JS files for encoding.js and onchain_reading.js are currently wrong. This means for this to work correctly, we need to merge #753 and #754 first anyway.

@nlordell nlordell force-pushed the ts-module-refactor branch from 96b9c11 to c9066d0 Compare May 13, 2020 10:06
@nlordell nlordell merged commit f09cdee into master May 13, 2020
@nlordell nlordell deleted the ts-module-refactor branch May 13, 2020 10:16
@@ -8,7 +8,7 @@
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these .d.ts files anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type definitions. They allow other TypeScript projects to use type information from the original TS code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants