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

feat: migrate-lookups-file-flow-to-ts #82

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

Akirtovskis
Copy link
Contributor

@Akirtovskis Akirtovskis commented Mar 15, 2022

Description

Migrated lookups.ts file from Flow to TypeScript as part of a bigger task to migrate the whole project types from Flow to TS.

  1. Following this PR the next task was to start migrating from Flow to Ts:
    feat: update eslint config #80

  2. This change is part of M1 of this grant:
    Subdomain registrar improvement stacksgov/grants-program#282

  3. After the whole repo is migrated to the TS it should
    improve dev experience and productivity as TypeScript is used
    across all the other Stacks repos.

Does this introduce a breaking change?

This does not include a breaking change.

Are documentation updates required?

Yes, once this will get a green light, I will add documentation for TS setup either on this branch or the one right after this one.

Testing information

  1. Review the config
  2. Review lookups.ts
  3. Run npm run tsc and see no errors

@codecov
Copy link

codecov bot commented Mar 15, 2022

Codecov Report

Merging #82 (e61d6be) into master (da2d144) will not change coverage.
The diff coverage is n/a.

❗ Current head e61d6be differs from pull request most recent head 784dc8a. Consider uploading reports for the commit 784dc8a to get more accurate results

@@           Coverage Diff           @@
##           master      #82   +/-   ##
=======================================
  Coverage   58.19%   58.19%           
=======================================
  Files           8        8           
  Lines         665      665           
=======================================
  Hits          387      387           
  Misses        278      278           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da2d144...784dc8a. Read the comment docs.

Copy link
Contributor

@pradel pradel left a comment

Choose a reason for hiding this comment

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

Regarding the approach of this pr, I think that until everything is migrated, you have to add the babel typescript config so files can be compiled with flow at the same time.

src/lookups.ts Show resolved Hide resolved
src/lookups.ts Outdated
} from "blockstack";
import { validateStacksAddress } from "@stacks/transactions";
import fetch from "node-fetch";
//@ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

what was the issue with winston?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pradel apparently the lib is not typed and running the suggested "install typed version" command does not fix it, hence the ts-ignore.

Copy link
Contributor

Choose a reason for hiding this comment

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

better to declare the module without types in such case, ts-ignore should ideally never be used :)

src/lookups.ts Outdated Show resolved Hide resolved
.babelrc Outdated Show resolved Hide resolved
.babelrc Outdated Show resolved Hide resolved
src/lookups.ts Outdated Show resolved Hide resolved
src/lookups.ts Outdated Show resolved Hide resolved
src/lookups.ts Outdated Show resolved Hide resolved
.babelrc Outdated Show resolved Hide resolved
tsconfig.json Outdated
"allowJs": true
},
"include": [
"src/lookups.ts"
Copy link
Contributor

Choose a reason for hiding this comment

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

should we include all the src folder here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It think no, because in that case all of the files will require being properly typed!

src/lookups.ts Outdated
} from "blockstack";
import { validateStacksAddress } from "@stacks/transactions";
import fetch from "node-fetch";
//@ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

better to declare the module without types in such case, ts-ignore should ideally never be used :)

package.json Outdated
@@ -48,9 +54,10 @@
"start:regtest": "BSK_SUBDOMAIN_CONFIG=config-develop.json BSK_SUBDOMAIN_REGTEST=true npm run start",
"build": "babel src -d lib",
"flow": "flow",
"tsc": "tsc",
Copy link
Contributor

Choose a reason for hiding this comment

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

as this is part of the build process, maybe it makes sense to rather edit the build command to be tsc && babel src -d lib?

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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