Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Typescript for Vue references #135

Open
Joebayld opened this issue Jan 5, 2021 · 4 comments
Open

Add Typescript for Vue references #135

Joebayld opened this issue Jan 5, 2021 · 4 comments

Comments

@Joebayld
Copy link

Joebayld commented Jan 5, 2021

Opening this issue so we can add typescript support for the reference object methods such as this.$refs.myObject.getNode() and it would ideally return a Node type from the Konva library. Here's my current workaround for how I'm achieving this:

import { Stage } from 'konva/types/Stage'
import { Layer } from 'konva/types/Layer'
import { Node } from 'konva/types/Node'

interface KonvaLayer extends Vue {
  getNode (): Layer
}

interface KonvaStage extends Vue {
  getStage (): Stage
}

interface KonvaTransformer extends Vue {
  getNode (): Transformer
}

$refs!: {
  stage: KonvaStage
  transformer: KonvaTransformer
  markLayer: KonvaLayer
}

Maybe it can be a generic so we'd define the type as: VueKonvaType<Layer>, VueKonvaType<Stage>, etc?

I'm new to defining type declarations but can help make this happen.

Thanks,
Joe

@cristianvasquez
Copy link

Thanks for this workaround!

@jez9999
Copy link

jez9999 commented Oct 13, 2022

I would love to see this added too, it's a major omission in vue-konva. Right now we can't really use TypeScript when our code gets a ref to the v-stage, for instance:

const playfieldRef = ref<???>(null);
[...]
const stage = playfieldRef.value.getStage();

[...]

<template><v-stage ref="playfieldRef" :config="playfieldInitialConfig"></v-stage></template>

@NellLee
Copy link

NellLee commented Jul 25, 2023

Is there any Update on this? It would be awesome to have typed versions the refs.

@lavrton
Copy link
Member

lavrton commented Jul 26, 2023

I am happy to apply a Pull Request if someone can do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants