Gathering detailed insights and metrics for vue-cli-plugin-tsx
Gathering detailed insights and metrics for vue-cli-plugin-tsx
Gathering detailed insights and metrics for vue-cli-plugin-tsx
Gathering detailed insights and metrics for vue-cli-plugin-tsx
npm install vue-cli-plugin-tsx
Typescript
Module System
Node Version
NPM Version
JavaScript (74.89%)
Vue (12.97%)
TypeScript (12.14%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
2 Stars
49 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Jan 23, 2021
Latest Version
0.1.16
Package Id
vue-cli-plugin-tsx@0.1.16
Unpacked Size
60.84 kB
Size
20.95 kB
File Count
11
NPM Version
6.4.1
Node Version
10.15.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Write vue in TSX, powered by babel-plugin-macros, vue-tsx.macro and babel-plugin-transform-vue-jsx-spread-attributes. And no runtime helpers are injected, except for merging attributes in JSX.
NOTICE: This package only works for vue 2
and projects created by vue-cli
.
NOTICE: This package isn't campatible with @vue/cli-plugin-typescript
.
NOTICE: <template />
isn't available, please use scopedSlots
attribute.
NOTICE: DON'T use variable h
in context where JSX used, because Vue use it to be as $createElement
alias.
NOTICE: The followed names / prefixes are reserved, if you use them, something will go wrong.
However, you can use them as attributes in JSX to pass related data.
1npm install -D vue-cli-plugin-tsx
or
1yarn add -D vue-cli-plugin-tsx
1import LogoAsset from '@/assets/logo.png' 2import { component, functional, type as t, EVENTS, SCOPED_SLOTS } from 'vue-tsx.macro' 3import HelloWorld from '@/components/HelloWorld.vue' 4import { VNode } from 'vue' 5 6// It will transform to Vue object with no runtime helper: 7// const Component = { props: {...}, render: function () { ... } } 8const Component = component({ 9 props: { 10 // optional prop with type string | undefined. 11 propWithVuePropType: String, 12 // required prop with type number 13 propWithVuePropDef: { 14 type: Number, 15 // If prop contains required filed, no matter of its value (true of false), 16 // this prop will be required. 17 // Because in most cases, we only set required when it's true. 18 required: true, 19 }, 20 // optional prop with type { a: number; b?: string } | undefined 21 propWithTSType: t<{ a: number; b?: string }>(), 22 // required prop 23 propWithRequiredTSType: { 24 type: t<number[]>(), 25 required: true, 26 }, 27 }, 28 29 // Declare component's events with their payload types. 30 // This field will be removed by macro. 31 [EVENTS]: { 32 eventWithStringPayload: String, 33 eventWithTSPayload: t<{ count: number }>(), 34 }, 35 36 // Declare component's scoped slots' scope (param) types. 37 [SCOPED_SLOTS]: { 38 default: { 39 scope: Number, 40 required: true, 41 } 42 }, 43 44 render() { 45 return ( 46 <div> 47 {this.propWithTSType ? this.propWithTSType.a : undefined} 48 <HelloWorld /> 49 {this.$scopedSlots.default(this.propWithVuePropDef)} 50 </div> 51 ) 52 }, 53}) 54 55// We needn't to declare the first createElement argument, 56// macro and jsx will do this for you. 57const Home = functional(context_ => { 58 const attrs = { 59 // names that not Vue's VNode options key name will 60 // move to attrs property. And Vue will pick them to 61 // props if defined in Component's props field. 62 propWithRequiredTSType: [1, 2], 63 propWithVuePropDef: 123, 64 65 // We can pass scoped slots to children to generate VNodes. 66 scopedSlots: { 67 default: props => [<hr />] 68 }, 69 70 // Due to TS' restriction, we cannot derive key named 'onEventWithStringPayload', 71 // so we cannot pass event listener as attribute for custom component, and we should 72 // pass them in `on` attribute. 73 on: { 74 eventWithStringPayload: payload => console.log(payload) 75 } 76 } 77 78 // Because Vue supports function child only if it's the only child. 79 // It means if we only declare scoped slots with only one default one, 80 // the component can accept a function. 81 82 // However, because Intrinsic Elements' listener names are known, 83 // you can use such as `onMouseUp={...}` on Intrinsic Elements, e.g., 84 // div, span, and so on. 85 return ( 86 <div 87 class='home' 88 onMouseDown={event => console.log(event.pageX)} 89 on={{ 90 click: event => { 91 console.log(event.target) 92 }, 93 }}> 94 <img alt='123' src={LogoAsset} /> 95 <Component propWithRequiredTSType={[1, 2]} propWithVuePropDef={123}> 96 {() => <hr />} 97 </Component> 98 99 <Component {...attrs} /> 100 </div> 101 ) 102}) 103 104export default Home
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
143 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More