typescript-cheatsheets / vue Goto Github PK
View Code? Open in Web Editor NEWCheatsheets for experienced Vue developers getting started with TypeScript
License: MIT License
Cheatsheets for experienced Vue developers getting started with TypeScript
License: MIT License
i don't do much Vue so this is really wide open - please let me know if you're keen on maintaining this!
Use class-based components, not Vue's proprietary data shape that gets passed to Vue.extend. (at least for Vue 2)
For Vuex support (types on your action / mutation payloads), use https://github.com/championswimmer/vuex-module-decorators.
Put "vetur.experimental.templateInterpolationService": true
in your VS Code settings to get TypeScript analysis on your <template>
in .vue files. This only works inside VS Code with Vetur installed - vue-cli-service build
won't show you type errors in your <template>
.
Don't forget that @someEvent='someEventHandler'
isn't type safe. This is the only major area where Vue and TypeScript don't play nice and you end up with a black hole of untyped data coming into your application.
Unrelated to Vue - verify the data coming into your app using IO-TS: https://github.com/gcanti/io-ts
For linting, use ESLint + Prettier. Rather than wrestling with the setup, just use the Vue CLI (or run vue ui) and then choose to add TypeScript support to your project when initially creating it and choose ESLint + Prettier. @ts-ignore
is banned by default. To change that, modify your eslintConfig.rules in your package.json
file. Here's mine:
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended",
"@vue/typescript/recommended",
"@vue/prettier",
"@vue/prettier/@typescript-eslint"
],
"parserOptions": {
"parser": "@typescript-eslint/parser",
"ecmaVersion": 2020
},
"rules": {
"no-debugger": 1,
"@typescript-eslint/ban-ts-ignore": 0,
"no-var": 1,
"@typescript-eslint/no-array-constructor": 1,
"@typescript-eslint/camelcase": 1,
"@typescript-eslint/no-use-before-define": 0,
"prefer-const": 1,
"@typescript-eslint/no-inferrable-types": 1,
"@typescript-eslint/no-this-alias": 1,
"@typescript-eslint/no-unused-vars": 1,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-empty-function": 0,
"no-console": 0,
"@typescript-eslint/no-non-null-assertion": 0
}
}
I've been thinking about how to best organise the docs. Currently there is clear divide between Vue 3 & Vue 2 I think it may be better to split the docs by Vue APIs for the following benefits.
However
So I'd like to propose the following structure for this repo to look something like this, with some ideas of sections within each page:
README.md
composition-api.md
props
,ref
,reactive
, computed
and other hooks.options-api.md
data
, methods
, computed
and other properties.class-components.md
data
, methods
, computed
and other properties.Later down the line we can also start to have separate pages for Vuex and Vue Router potentially?
Perhaps something in the same vein as the React+TS logo? - https://github.com/typescript-cheatsheets/react.
Please get in touch.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.