question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[RFC]: rewrite in typescript and restructure to monorepo

See original GitHub issue

Problem:

  • Multi repo make it hard to tracking isue, issue in 1 sub package has less attention… We already know why Google, Facebook use Mono Repo pattern.
  • Type definition is not align with js implementation. Most of case I have to use type any, which removes most of the benefit of using typescript. ( type checking, auto completion …)

Solution:

  • Restructure multi repos to Mono repo.
  • Use tools like typewiz to convert source code to TS with less effort. And @urish is offering help if open source maintainer want to convert their source code to TS. I’m willing to help too and I believe there are many people from community are willing too.

Roadmap:

  • Convert to mono repo and config build system
  • Start rewriting in TS
  • Release in d3 v6

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gustavderdrachecommented, Mar 23, 2018

Speaking as the author of the current D3v3 typings (and occasional helper on v4 when @tomwanzek or @Ledragon don’t beat me to it!), maintaining types for D3 can be trickier than it looks and we welcome any and all improvements. The D3 API surface is incredibly flexible, and it’s taken a lot of collective brainpower to reflect this flexibility in a statically-typed world.

I’ve authored and maintained a number of production codebases using both the v3 and v4 @types packages and can’t remember a case where I’ve needed to revert to an any type. I suggest opening issues in the DefinitelyTyped repo with demonstration code to see if we can’t put our heads together to solve the problems you’re seeing.

1reaction
tomwanzekcommented, Mar 23, 2018

With respect to maintaining TS definitions within the actual D3 modules, I have always deferred to @mbostock as the principal owner. Always open to considering a migration and discussion, how we could most efficiently maintain them here without unduly impacting his release cycles.

Here is some background:

When we checked last month, the installations that use D3 + TS Definitions are about >15% inferred from npm download stats (give or take differences in popularity for individual modules that are downloaded individually).

As @Ledragon already mentioned, the D3-related TS definitions are current for the 30+ D3 modules he, @gustavderdrache and myself have supported since the refactoring @mbostock has done with D3 v4. In our experience, generally these TS definitions reflect the latest published version of a D3 module within less than a week after new version release. (Some of the cycle time is due to DefinitelyTyped merge/pub process but again generally the Microsoft folks have been very responsive to get approved PRs published to npm quickly). Since the initial release stabilization of D3 v4 and the first cut of definitions, we have seen about 10 fix requests across all the modules we support (over about 1 1/2 years). About half of them were related to relaxing argument types, which were too strict, some others were about arguments/properties which were optional, rather than mandatory.

While we are working through the definitions to fully validate them for strictNullChecks and strictFunctionTypes, they are feature complete including the extensive use of generic parameters to control type-safety on the extensive D3 API Mike has developed over the years. strictNullChecks validations are a bit more involved, as we have to go deeper into the source code in some case to establish D3 behavior. Most PR activity is related to enhancing the definitions (see tracking issue DefinitelyTyped/DefinitelyTyped#23611) or matching D3 module minor/major releases.

@sandangel Should you have identified a particular issue where you believe the TS definitions do not reflect the D3 API, please feel free to open an issue on DefinitelyTyped for the affected definition(s) making sure to @-mention the involved definitions owners. When doing so, please ensure to provide a concise issue description, as it is not clear to me why you always would have to “use any”. As mentioned, we make extensive use of generics with constraints to allow use-case specific type-safety, which includes the ability to strongly type the this context of D3 methods/functions operating on bound DOM elements. So, should you have questions on how to use the generics effectively, feel free to use StackOverflow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrating to a Monorepo Using NPM 7 Workspaces - Medium
A practical guide for developers to refactor and configure an existing repo to a Monorepo using of npm 7 workspaces, webpack, babel, ...
Read more >
RFC - Universal monorepo for Rescript Bindings?
What if we made a monorepo where each binding is its own module similar to how Typescript handles their @types repo?
Read more >
Moving TypeScript code into a Bazel monorepo - Aspect Blog
You'll want developers to stay comfortable with their existing configurations, which are likely in package. json files. Dependencies should ...
Read more >
This Week In React #120: use RFC, Sandpack, Progressive ...
Hi everyone!
Read more >
Ember Data Packages
This move to packages will help us restructure the project and ... continue to live in a monorepo that (until further RFC) would...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found