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 support #56

Open
Avataw opened this issue May 15, 2022 · 12 comments · May be fixed by #71
Open

Typescript support #56

Avataw opened this issue May 15, 2022 · 12 comments · May be fixed by #71
Labels
help wanted Extra attention is needed

Comments

@Avataw
Copy link

Avataw commented May 15, 2022

Quick discussion:
I followed the first half of the redwood tutorial purely using typescript.
Now in the intermission it is heavily suggested to use this repo instead.

I was quite surprised to see that no typescript version of this repo exists - I think it'd be neat to have in the future!

I am also volunteering to implement it - I'm just wondering where to put it :x

Options:
A) different branch
B) different repo
C) same branch, relevant files exist in .js/x and .ts/x

@adriatic
Copy link

adriatic commented May 17, 2022

@Avataw your ideas on expanding the Redwood tutorial is very appealing to me. Please check the section Current list of authors, articles, and tools which indicates the need for your Typescript Redwood Blog app creation.

@thedavidprice
Copy link
Contributor

I am also volunteering to implement it - I'm just wondering where to put it :x

Thank you for offering @Avataw That would be helpful, indeed 🚀 (And no small task.)

Because we want this repo to be maintainable, using automation as much as possible, we need to keep things in one repo using one main branch. For this initiative, what I suggest is:

  • Work against this Repo via PR(s), which could be separated into a PR per directory
  • replace the current main branch codebase with TS equivalent
  • when devs clone this repo, they can:
    1. keep it as TS
    2. convert to JS using the yarn rw ts-to-js command

Additionally, this repo README and the Tutorial will need to be updated with instructions to clone and either keep as TS or convert to JS.

What do you think?

@Tobbe
Copy link
Member

Tobbe commented May 25, 2022

@Avataw Sorry I didn't see this one earlier. You did a great job on the PRs and discussions on the tutorial docs. I'd love to work with you on converting this repo to TS. Just let me know if there's anything I can do for you.

@adriatic
Copy link

adriatic commented May 26, 2022

@awataw - I found your message first, because it hits a sweet spot for me (looking for RW customers that would be willing to add articles to the Redwood Application Development Cookbook - an important piece of documentation, a project that might function on it's own, without adding to the workload for core team members).

On the first glance, I thought that you are a perfect match for the RADC project, but realized later that a company founder (@thedavidprice) and a core team member (@Tobbe) responded to your initial post so enthusiastically, please consider their responses first 😄,

@Avataw
Copy link
Author

Avataw commented May 29, 2022

@thedavidprice sounds great! I'd love to do that and help :) I won't be able to do that before the mid of june though :/
@Tobbe thanks for offering - I'll let you know if something comes up :)

@adriatic thanks! I do like the idea of the RADC project :) For example an in-depth example of debugging redwood applications would be incredibly helpful - I'm just not sure if it should be outsourced into a different repo, instead of putting it into the main documentation somewhere :)

@adriatic
Copy link

@Avataw - the Typescript version of Redwood Blog application (called here Redwood Tutorial) is missing a lot and would be very important to Redwood users.

By the time you plan to create the Typescript version (my advice would be to do it in your own repository, worrying about its final destination later), I will likely finish the set of articles on in-depth debugging practices. Then we can both focus on adding Typescript to that set. Stay in touch 😄

@cubu
Copy link

cubu commented Jul 3, 2022

This is the typescript version I work from scratch (not following the suggestion in intermission): https://github.com/cubu/redwood-tutorial-ts/

Basically if user follow the current tutorial, they will have no trouble completed most of the work. Only the services function in comments.ts file need to be updated.
As in the tutorial, it use Prisma and CreateCommentArgs interface. However the new generated code use QueryResolvers. To make it work, we added the function createComment & deleteComment as below:

export const createComment: QueryResolvers['comment'] = ({ input }) => {
  return db.comment.create({
    data: input,
  })
}

export const deleteComment: QueryResolvers['comment'] = ({ id }) => {
  requireAuth({ roles: 'moderator' })
  return db.comment.delete({
    where: { id },
  })
}

We also need to update this function to make it display properly at the end of Chapter 6 (this is a nightmare to troubleshoot with beginners):

export const comments: QueryResolvers['comments'] = ({ postId }) => {
  return db.comment.findMany({ where: { postId } })
}

Another trouble is testing, tests still failed due to discrepancy in tutorial code and create-redwood-app generated code. But I haven't touched it yet.

Hope that's help someone who have trouble follow the tutorials.

@Tobbe Tobbe added the help wanted Extra attention is needed label Jul 4, 2022
@rushabhhere
Copy link

@thedavidprice @Tobbe here's my attempt at an example intermission repo in TypeScript: https://github.com/rushabhhere/redwood-tutorial-ts/

I have tried my best to cover all additional tests and styles. I am willing to make necessary changes per your suggestions and help roll this out as soon as possible. I hope this is helpful!

@Tobbe
Copy link
Member

Tobbe commented Jul 30, 2022

@rushabhhere Thank you!

Did you also try ts-to-js as David suggested? I mean, it shouldn't cause any problems, but just wanted to make sure your repo still works fine as a JS project 🙂

@rushabhhere
Copy link

@Tobbe yes, I did try it out. It worked fine for me.

@Tobbe
Copy link
Member

Tobbe commented Jul 30, 2022

@rushabhhere If you could make a PR against this repo with your changes, that would be fantastic! And also update the Readme with instructions for both TS and JS.

Thanks!

@rushabhhere
Copy link

@Tobbe Done #71!

jgal1 added a commit to jgal1/redwood that referenced this issue Jul 11, 2023
…ow not to look for a Typescript version.

I'm a first-time Redwood user. While working through the tutorial, once I hit the intermission and started working through the examples, I realized cloning the tutorial repo with the default instructions contained js-only code. Since the tutorial provided example snippets in Typescript, I figured there must be a separate branch or way to download a typescript version. After poking around, I found this open issue redwoodjs/redwood-tutorial#56 and realized this was in progress, so this just edits the documentation to save other readers time while working through the tutorial. I'm no copywriter, and the tutorial seems to take a specific tone, so please feel free to edit the copy or make suggestions (i.e. link to the github issue in the comment so people can track it) I didn't include the issue since there doesn't seem to be a precedent for doing so in the rest of the documentation. Using Redwood for the first time has been a great experience by the way!
jtoar added a commit to redwoodjs/redwood that referenced this issue Jul 13, 2023
…ow not to look for a Typescript version (#8885)

I'm a first-time Redwood user. While working through the tutorial, once
I hit the intermission and started working through the examples, I
realized cloning the tutorial repo with the default instructions
contained js-only code. Since the tutorial provided example snippets in
Typescript, I figured there must be a separate branch or way to download
a typescript version. After poking around, I found this open issue
redwoodjs/redwood-tutorial#56 and realized
this was in progress, so this just edits the documentation to save other
readers time while working through the tutorial. I'm no copywriter, and
the tutorial seems to take a specific tone, so please feel free to edit
the copy or make suggestions (i.e. link to the github issue in the
comment so people can track it) I didn't include the issue since there
doesn't seem to be a precedent for doing so in the rest of the
documentation. Using Redwood for the first time has been a great
experience by the way!

---------

Co-authored-by: Dominic Saadi <dominiceliassaadi@gmail.com>
jtoar added a commit to redwoodjs/redwood that referenced this issue Jul 17, 2023
…ow not to look for a Typescript version (#8885)

I'm a first-time Redwood user. While working through the tutorial, once
I hit the intermission and started working through the examples, I
realized cloning the tutorial repo with the default instructions
contained js-only code. Since the tutorial provided example snippets in
Typescript, I figured there must be a separate branch or way to download
a typescript version. After poking around, I found this open issue
redwoodjs/redwood-tutorial#56 and realized
this was in progress, so this just edits the documentation to save other
readers time while working through the tutorial. I'm no copywriter, and
the tutorial seems to take a specific tone, so please feel free to edit
the copy or make suggestions (i.e. link to the github issue in the
comment so people can track it) I didn't include the issue since there
doesn't seem to be a precedent for doing so in the rest of the
documentation. Using Redwood for the first time has been a great
experience by the way!

---------

Co-authored-by: Dominic Saadi <dominiceliassaadi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants