Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

288
Vistas
TypeScript Dynamic Classes (to be used at the end as Repository Pattern with Axios)

I've got suggested to use that way to define types (in Nuxt.js for all components manually and at the end, the data will be loaded with Axios using the "Repository Pattern"). For a small projects it's fine, but what about big projects with multiple data, types etc. Is there any way to automate it? Can i have some kind of "dynamic" Typescript classes?

Some data:

export const samplePage = [
    {
        buttons: [
            {
                size: 1,
                text: "Some text"
            }
        ]
    }
]

samplePage.model.ts

export class Button {
    size: number;
    text: string;

    constructor(button: Partial<Button> = {}) {
        this.size = 1;
       this.text = "";
    }
}

test.vue

<template>
  <div>
  </div>
</template>
<script lang="ts">
import { SamplePage } from "@/classes/models/samplePage.model"

import Vue from 'vue'
export default Vue.extend({
  data() {
    return {
        samplePage: samplePage
    }
  },
  mounted() {
    console.log("debug: samplePage", new SamplePage(this.samplePage[0]))
  },
  methods: {

  }
})
</script>
<style lang="scss" scoped>

</style>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda