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

Typescript example without Faker #17

Open
emersonbottero opened this issue Dec 22, 2023 · 1 comment
Open

Typescript example without Faker #17

emersonbottero opened this issue Dec 22, 2023 · 1 comment

Comments

@emersonbottero
Copy link

How can we have typescript support in the basic example show in the docs?

import { createServer, Model } from "miragejs"

export function makeServer({ environment = "development" } = {}) {
  let server = createServer({
    environment,

    models: {
      user: Model,
    },

    seeds(server) {
      server.create("user", { name: "Bob" })
      server.create("user", { name: "Alice" })
    },

    routes() {
      this.namespace = "api"

      this.get("/users", (schema) => {
        return schema.users.all()
      })
    },
  })

  return server
}
´´´

when I tried to set the Model it doesn.t seems to be working.. 

![image](https://github.com/miragejs/examples/assets/12377432/a34b4166-a3dc-44d5-909a-8f8497569c9c)


@emersonbottero
Copy link
Author

emersonbottero commented Dec 22, 2023

using

    models: {
      user: Model.extend<Partial<User>>({}),
    },

image

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

1 participant