Skip to content

Instantly share code, notes, and snippets.

View mitchell-garcia's full-sized avatar

Mitchell Garcia mitchell-garcia

View GitHub Profile
import React from 'react'
import { Dimensions, Animated, View, Easing, Platform } from 'react-native'
import PropTypes from 'prop-types'
/**
* DismissableScrollview
* Will dismiss element when the user scrolls from the top and there is no more vertical
* scrolling available.
*/
export default class DismissableScrollview extends React.Component {
@mitchell-garcia
mitchell-garcia / ExampleFile.vue
Created March 7, 2018 01:30
Example of how to type an Object with a Typescript interface in VueJS
<script lang="ts">
import Vue from "vue"
type ComplexObjectInterface = {
testProp: string
modelName: number
}
export default Vue.extend({
props: {
const modules = {};
let tmpModule;
function requireAll(r) {
r.keys().forEach(function (moduleName) {
tmpModule = r(moduleName);
if (!tmpModule.default) {
throw new Error(`Module not correctly exported. Excepted Vuex Module definition but got: ${tmpModule.default} for module: ${moduleName}`);
}
<script lang="ts">
import Vue, { PropTypes } from "vue"
type ComplexObjectInterface = {
testProp: string
modelName: number
}
export default Vue.extend({
props: {
@mitchell-garcia
mitchell-garcia / ComponentName.vue
Last active January 16, 2018 01:43
Single File Component Example
<script lang="ts">
import Component from "vue-class-component"
import { Prop } from "vue-property-decorator"
type ComplexObjectInterface = {
testProp: string
modelName: number
}
@Component
Feature vue-class-component Vue.extend
Autocomplete For Component Props In Templates x
Type-safety for Props x
Type-safety for Data Properties
Type-safety for Computed Properties
Type-safety for Methods
@mitchell-garcia
mitchell-garcia / TestComponent.vue
Last active January 15, 2018 15:11
Typing Props
<script lang="ts">
import Vue from "vue"
interface TestComponentData {
testingProp: string
theme: "white" | "red"
}
export default Vue.extend({
data() {
@mitchell-garcia
mitchell-garcia / index.ts
Last active December 18, 2017 04:35
Store Module Example with vuex-typex
import Vue from 'vue'
import { getStoreBuilder } from 'vuex-typex';
import Vuex, { Store } from 'vuex'
import { UserModule } from "./userModule";
export interface RootState {
user: UserModule;
}
Vue.use(Vuex);
[Thu Nov 09 2017 15:23:28 GMT-0500 (EST)] DEBUG Mounting folder `/Users/e006707/Projects/test-project/dist` at `/`
[Thu Nov 09 2017 15:23:28 GMT-0500 (EST)] INFO Static server running at http://localhost:8081
Debugger listening on [::]:5859
[15:23:32] COMMAND POST "/wd/hub/session"
[15:23:32] DATA {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"browser":"chrome","browserstack.debug":"true","browserstack.local":"true","browserName":"firefox","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"4.9.5","name":"webdriverio"}}}
[15:23:37] INFO SET SESSION ID 580859e74c3200e092d47c6173618125eabd9b32
[15:23:37] RESULT {"applicationCacheEnabled":false,"rotatable":false,"mobileEmulationEnabled":false,"networkConnectionEnabled":false,"chrome":{"chromedriverVersion":"2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f)","userDataDir":"C:\\Windows\\pro
@mitchell-garcia
mitchell-garcia / vuex.d.ts
Created October 25, 2017 13:35
Manually Typed Vuex Typescript Definition
/**
* Static vuex typings copied from ones included in node_modules.
*
* We need to do this in order to get typings for this.$store in components.
* Once this Feature is added, we can remove this + the custom mapping in tsconfig.json
* https://github.com/vuejs/vuex/issues/994
*/
import Vue, { WatchOptions } from 'vue';
type Dictionary<T> = { [key: string]: T };