re: Learn by Contributing VIEW POST

VIEW FULL DISCUSSION
 

I've really been enjoying contributing to open source and I definitely agree with you that even documentation is valuable to OSS.

I'm still feeling really good about my past week, so I'm just gonna drop this here as it relates to the post.

This week, I got a PR merged that I've been working on for quite a while for the Refined GitHub browser extension. Feels pretty good.

Enable strict-mode for TypeScript #1783

Basically going with the non-null assertion operator in almost all places, because as mentioned in github.com/sindresorhus/refined-gi..., the assumption with the extension is that the DOM nodes referenced in most cases are expected to be there. If they aren't, the extension breaks, a bug is filed and it's fixed.

One thing to note @bfred-it, is currently dom-chef types need to handle JSX (Element and IntrinsicElements) or we import @types/react.

In the process of working on that PR, I discovered a bug in the TypeScript types that ship with TypeScript.

Missing string indexer on NamedNodeMap interface in lib.dom.d.ts? #30928

For context, see github.com/sindresorhus/refined-gi..., specifically this commit, github.com/sindresorhus/refined-gi....

Also, just posting my tweet about this so that people can find discussions about the issue. See twitter.com/nickytonline/status/11...

I'll restate what I tweeted as I probably should have posted my question here originally.

The NamedNodeMap interface in lib.dom.ts does not allow for a string indexer, even though vanilla JS supports this in browsers, e.g. someDomElement.attribute['aria-label'].value.

We have code like this in the Refined GitHub extension, so for the time being, I've gone ahead via a declaration merge for NamedNodeMap

interface NamedNodeMap {
      [key: string]: Attr;
}

I can't tell from the MDN docs for NamedNodeMap if it's standard or not. All they seem to mention is "Attr nodes' indexes may differ among browsers" which wouldn't apply to access by the attribute name.

Just wondering if this was omitted by mistake or is it because this is not considered WHATWG DOM standard? I went to dom.spec.whatwg.org/#interface-nam... and unless I'm reading it incorrectly, I believe it states that using a string indexer is valid.

Thoughts? Happy to PR this up if it's valid.

And finally, I've made a few PRs to dev.to to get back in the swing of things of contributing there as well.

Fixed some frontend linting issues #2495

What type of PR is this? (check all applicable)

  • [x] Refactor
  • [ ] Feature
  • [ ] Bug Fix
  • [ ] Documentation Update

Description

Fixed some linting issues being reported in the frontend.

Related Tickets & Documents

#1828

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

Added to documentation?

  • [ ] docs.dev.to
  • [ ] readme
  • [x] no documentation needed

[optional] What gif best describes this PR or how it makes you feel?

Richie Rich robot

Boom!






 

That's awesome!!! May be you can share a few tips about how to do what you have done successfully? E.g. how did you discover the problem and what did you do to isolate, solve and deliver the solution? What did you learn on the way?

 
  • I would say only work on stuff that you find interesting and challenging. Otherwise don't bother. You won't enjoy it.

  • When I first started learning react, I started contributing as a way of learning. I found a react boilerplate project, react-slingshot, and just started offering suggestions that became PRs, and also did bug fixes. Eventually I was asked to become a maintainer to which I said yes.

coryhouse / react-slingshot

React + Redux starter kit / boilerplate with Babel, hot reloading, testing, linting and a working example app built in


Build status: Linux Build status: Windows Dependency Status Coverage Status

A comprehensive starter kit for rapid application development using React.

Why Slingshot?

  1. One command to get started - Type npm start to start development in your default browser.
  2. Rapid feedback - Each time you hit save, changes hot reload and linting and automated tests run.
  3. One command line to check - All feedback is displayed on a single command line.
  4. No more JavaScript fatigue - Slingshot uses the most popular and powerful libraries for working with React.
  5. Working example app - The included example app shows how this all works together.
  6. Automated production build - Type npm run build to do all this:

React Slingshot Production Build

Get Started

  1. Initial Machine Setup

    First time running the starter kit? Then complete the Initial Machine Setup.

  2. Clone the project

    git clone https://github.com/coryhouse/react-slingshot.git.

  3. Run the setup script

    npm run setup

  4. Run the example app

    npm start -s

    This will run the automated build process, start…

Takeaway from this is open source is a great way to learn from others and if you contribute enough to a project, you may be asked to become a maintainer (if that's your jam).

  • In terms of problems/solutions, the more recent one I had while converting the Refined GitHub extension to TypeScript (TS), I had converted everything to TS, but webpack builds were failing. So initially, I tried some configuration changes in regards to webpack and the TS config, but no dice. I compiled each entry point from webpack directly with the TS compiler and they built fine, so clearly something was not right with webpack/TS situation.

At this point I started to debug webpack, specifically the ts-loader plugin. If you've never debugged webpack code, you can run the following command to get started with the debugger. node --inspect-brk ./node_modules/webpack/bin/webpack.js. I found the error that was being thrown from webpack in the code and put a breakpoint there. First I saw that the files weren't being generated. When I reran the debugger, this time I saw that a particular boolean was not set properly which was related to webpack/TS configuration. Once I fixed the configuration, I was good to go. Takeaways, use your tools. Also, I was probably tired at this point and probably missed the obvious misconfiguration. 🙃

Awesome!

  1. I started using refined-github :)
  2. Would you mind if I copy your comment to the article? It's very inspirational and a good showcase of real-world example
code of conduct - report abuse