Skip to content

Instantly share code, notes, and snippets.

View alloy's full-sized avatar

Eloy Durán alloy

View GitHub Profile
const fs = require("fs");
const PromisePool = require("@supercharge/promise-pool");
const { git, getOriginalCommit } = require("./scripts/changelog-generator");
const gitDir = "/Users/eloy/Code/ReactNative/react-native/.git"
const seen = new Map()
const SHAs = new Set()
const existingChangelogData = fs.readFileSync("./CHANGELOG.md", "utf8");
@alloy
alloy / Podfile
Last active February 28, 2020 11:40
Example of a Podfile that builds React Native without integrating into an app
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
install! 'cocoapods', :integrate_targets => false
platform :ios, '9.0'
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"

In an effort to try to get TypeScript definitions for React Native consistent with the cononical Flow types, I have been looking into the possibility of automating this process.

My initial approach was to see how far I could get without any help needed from Facebook’s side. This process looks something like this:

  1. Transform Flow codebase to TypeScript by leveraging existing tooling with a few additional changes, which mostly replaces Flow utility types with TypeScript ones. (This tooling is presumably meant for people migrating from Flow to TypeScript and thus it is ok for these tools to not deliver perfect conversions.)
  2. Replace $ObjMap usage with a mapped type, as RN’s usage of $ObjMap is trivial (return types are static).
  3. Replace import type {Foo} from "./some-module" with import {Foo} from "./some-module".
  4. Replace `m
@alloy
alloy / 1-input.ts
Last active March 27, 2024 08:18
Why does TypeScript inline the typeof type?
const x = {
foo: "bar",
answer: 42
}
type X = typeof x
export default {
get X(): X {
return x
import React from "react"
import { NativeModules } from "react-native"
const SurveyManager = NativeModules.SurveyManager
class Survey extends React.Component {
componentDidMount() {
SurveyManager.start({ ... }, prompt => {
this.setState({ prompt })
})
diff --git a/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h b/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h
index 119fb8fb5a..6840cdd57a 100644
--- a/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h
+++ b/Libraries/Image/RCTImageLoaderWithAttributionProtocol.h
@@ -17,6 +17,7 @@ RCT_EXTERN void RCTEnableImageLoadingPerfInstrumentation(BOOL enabled);
@protocol RCTImageLoaderWithAttributionProtocol<RCTImageLoaderProtocol>
+#ifdef __cplusplus
/**

React Native Link

Who am I?

  • Eloy Durán
  • @alloy
  • Author of CocoaPods
  • Engineer at Artsy, where we’ve been using React Native for 3.5 years in our brownfield app

What will you learn from this presentation?

(function anonymous(locals, jade
) {
var jade_debug = [ new jade.DebugItem( 1, "/Users/eloy/Code/Artsy/force/src/desktop/components/main_layout/templates/react_redesign.jade" ) ];
try {
var buf = [];
var jade_mixins = {};
var jade_interp;
;var locals_for_with = (locals || {});(function (JSON, Object, asset, assetPackage, body, bodyClass, css, data, defaultOptions, head, helpers, jsonLD, options, scripts, sd, sharify, stitch, styleTags, styledComponents, user, userAgent) {
jade_debug.unshift(new jade.DebugItem( 0, "/Users/eloy/Code/Artsy/force/src/desktop/components/main_layout/templates/redesign.jade" ));
jade_debug.unshift(new jade.DebugItem( 1, "/Users/eloy/Code/Artsy/force/src/desktop/components/main_layout/templates/redesign.jade" ));
@alloy
alloy / steps.sh
Created September 11, 2019 12:02
Build Swift
git clone https://github.com/llvm/llvm-project.git
ln -s llvm-project/llvm
ln -s llvm-project/clang
git clone https://github.com/apple/swift-cmark cmark
git clone https://github.com/apple/swift
cd swift
./utils/build-script --release-debuginfo
# This is just the base schema shared by the two options below.
type User {
name: String
friendships: FriendshipConnection
}
type Friendship {
establishedAt: String
withUser: User