This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as fs from 'fs' | |
import * as path from 'path' | |
import * as globby from 'globby' | |
import { parseComponent } from 'vue-template-compiler' | |
import { format } from 'prettier' | |
import { parse } from '@babel/parser' | |
import traverse from '@babel/traverse' | |
import generate from '@babel/generator' | |
const graphqlCodeGenFile = '../src/generated/graphql.ts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
const fs = require('fs') | |
const stylus = require('stylus') | |
const compiler = require('vue-template-compiler') | |
const globby = require('globby') | |
const targets = globby.sync(path.resolve(__dirname, '../src/**/*.vue')) | |
targets.forEach(file => { | |
console.log('***** processing: ' + file + ' *****') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div v-if="posts.loading">Loading...</div> | |
<ul v-else> | |
<li v-for="p in posts.data" :key="p.id">{{ p.title }}</li> | |
</ul> | |
</template> | |
<script lang="ts"> | |
import Vue from 'vue' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
chainWebpack: webpackConfig => { | |
// prettier-ignore | |
webpackConfig.module | |
.rule('css') | |
.oneOfs.values().forEach(rule => { | |
rule | |
.use('vue-media') | |
.loader('vue-media-loader') | |
.after('postcss-loader') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Store<S> { | |
private vm: Vue | |
constructor(initialState: S) { | |
this.vm = new Vue({ | |
data: initialState | |
}) | |
} | |
get state(): S { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue, { VueConstructor } from "vue"; | |
declare function extractInstance<T extends Vue>(Ctor: VueConstructor<T>): T; | |
const Test = Vue.extend({ | |
data() { | |
return { | |
test: 123 | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Mapping<K, V> { | |
_k: K; | |
_v: V; | |
} | |
type P<K, M extends Mapping<K, any>> = M extends Mapping<K, infer V> | |
? V | |
: never; | |
interface XMap<T extends Mapping<any, any> = Mapping<never, undefined>> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Emit<Payloads> { | |
<Name extends keyof Payloads>(name: Name, payload: Payloads[Name]): void | |
} | |
interface Observe<Payloads> { | |
<Name extends keyof Payloads>( | |
name: Name, | |
cb: (payload: Payloads[Name]) => void | |
): void | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Store, ActionContext } from 'vuex' | |
type Actions<S, P> = { | |
[K in keyof P]: (ctx: ActionContext<S, any>, payload: P[K]) => void | Promise<any> | |
} | |
type Mutations<S, P> = { | |
[K in keyof P]: (state: S, payload: P[K]) => void | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { inject, create } from '../../../src/interface' | |
import Counter from './counter' | |
const { Getters, Mutations, Actions } = inject('counter', Counter) | |
interface Todo { | |
id: number | |
isCompleted: boolean | |
title: string | |
} |
NewerOlder