Skip to content

Commit 20e2364

Browse files
committed
feat(compiler-sfc): useAttrs support generic type
1 parent a643c41 commit 20e2364

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,39 @@ return { get aa() { return aa }, set aa(v) { aa = v }, bb, cc, dd, get a() { ret
12371237
}"
12381238
`;
12391239
1240+
exports[`SFC compile <script setup> > useAttrs w/ generic type 1`] = `
1241+
"import { defineComponent as _defineComponent } from 'vue'
1242+
import { useAttrs, ref} from 'vue'
1243+
1244+
export default /*#__PURE__*/_defineComponent({
1245+
setup(__props, { expose }) {
1246+
expose();
1247+
1248+
const attrs = useAttrs<{ foo: number }>()
1249+
1250+
return { attrs, useAttrs, ref }
1251+
}
1252+
1253+
}, { attrs: {} as { foo: number }})"
1254+
`;
1255+
1256+
exports[`SFC compile <script setup> > useAttrs w/ type reference 1`] = `
1257+
"import { defineComponent as _defineComponent } from 'vue'
1258+
import { useAttrs, ref} from 'vue'
1259+
type CompAttrs = { foo: number }
1260+
1261+
export default /*#__PURE__*/_defineComponent({
1262+
setup(__props, { expose }) {
1263+
expose();
1264+
1265+
const attrs = useAttrs<CompAttrs>()
1266+
1267+
return { attrs, useAttrs, ref }
1268+
}
1269+
1270+
}, { attrs: {} as { foo: number }})"
1271+
`;
1272+
12401273
exports[`SFC compile <script setup> > with TypeScript > const Enum 1`] = `
12411274
"import { defineComponent as _defineComponent } from 'vue'
12421275
const enum Foo { A = 123 }

0 commit comments

Comments
 (0)