-
Notifications
You must be signed in to change notification settings - Fork 1k
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 #234
Comments
Is there a Branch? |
Are you planning to move the core itself to TS? The router needs to have types to work well in TS projects. |
Currently in process by Peter:
Yes indeed. I believe @jeremyscatigna might have a start on this already. True, Jeremy? |
In this adding of "first class typescript support", is there a line item for generating types for gql queries? Something like apollo-codgen? This is currently one of the pain points when integrating with any API (whether REST or graphql) and if that would be included in the Redwood framework that would be amazing and make for an awesome and very type-safe coding experience. |
+1 on generating types for gql queries. The graphql-code-generator project might also worth considering as it generates typesafe React Hooks, HOCs, etc for pre-defined query fragments. |
Is there a rough timeline for TypeScript support? E.g months, 1/2 year, 1 year? |
Hi @marceloverdijk it’s a top 3 priority (on the list with Auth and Jest tests, for example), but the progress has admittedly been slow. I know we want it to be “months”. But that’s all the certainty I can commit to regarding a rough timeline. What I could commit to, personally, is helping organize a collaborative effort around this. I know:
…but we haven’t really rounded up critical mass. So taking this as a nudge in that direction, and as a next-step I just this created a Forum topic (below). Chime in you’re available + interested: |
Thx @thedavidprice for the honest answer. Much appreciated! |
Our development configurations are now "TypeScript aware" via #438, this means that if you rename the The next steps are to figure out if building a project is working, and to add types to the redwood router. We'll add support for starting a redwood project in typescript, and making sure the generators generate TypeScript. |
EDIT: added an example that showcases some of the techniques discussed here Those are the tools at our disposal. But what are the challenges? ChallengesUsing path aliases (src/*) instead of relative imports
Directory Name conventionRedwood uses the DirectoryName convention extensively. For the following import: import MyComponent from "src/MyComponent" Normal Lookup (simplification)
With DirectoryName convention:
Can it be mapped to TypeScript?
Auto Imports on Routes.js
Possible Solution: Language Service Plugin
Possible Solution: Code GenerationIf we're already generating code, we could "declare global var"iables for each of these pages. Possible Solution: Routes.js must always be JS (not TS)
Named Routes
importAll.macro
Cells
Solution?
(*) Providing a Custom TypeScript CompilerIf everything else fails, we can change the way TypeScript works :). This might sound crazy, but I'll bring it up to be exhaustive.
How can this be distributed? Publish a separate NPM module
Challenges:
Monkey Patch
Challenges:
|
Maybe I could take a hit at writing type definitions for |
@koolamusic that would be fantastic! Looping in @peterp here. Maybe open a separate Issue (linking back to this one) to get started? And definitely don't hesitate to let us know what questions + clarification + help you need along the way. 🚀 |
@thedavidprice do you have any developer guidelines for adding types? Do you want to store them in one big file, or separate definitions into linked files? Do you want to keep definitions in Redwood repo, or shall it be tracked in the @types repo? |
Hi @tomitrescak! Thanks for checking in here. @peterp is the one to provide an update as this issue is (in a good way) out of date. And your question is a bit of "it depends" 😆. For the Framework (this repo redwoodjs/redwood) we have a mix of approaches. For the application development template (redwoodjs/create-redwood-app) there's a lot more customization involved and (I believe) includes storing in a big file. |
@tomitrescak I think it's okay to start out with one file for some packages, while others could use a type-per-module approach to separate the definitions. With regards to the developer guidelines, have you seen https://github.com/sindresorhus/typescript-definition-style-guide ? would love to know what your thoughts are |
I've added the type defs for the router over here: #1110 |
@jvanbaarsen I don't think we'll ever compile with |
But once we're full-type compliant, nothing will stop you from using tsc. It's just that we're not setting up our own tooling to use it. We rather strip out the types and transpile to JS via babel, and via experimental esbuild support. |
I'm happy to report that we'll be full type compliant in https://mobile.twitter.com/appfactory/status/1384203938958770177 |
Here are the last few issues that we're working on to close this issue:
Developer experience
|
Please note: outstanding typescript issues can be tracked on the project board https://github.com/redwoodjs/redwood/projects/2! 🚀 |
You should switch the color. |
I'm currently onboarding and working through the Tutorial using a TypeScript project. I happen to run into a couple of TypeScript warnings during that. Is there already an initiative to polish the Tutorial for TypeScript? |
@Philzen No, nothing specific for the tutorial. But please report what you find so we can take a look. I think it would be best if you could report each individual thing as its own issue. Then we can group them if needed. |
@Tobbe Thanks for the reply – will do and refer to them here. |
This tracking issue is no longer maintained, please reference the project board for the latest updates instead:
https://github.com/redwoodjs/redwood/projects/2
We're going to add first-class support for TypeScript and be an even better experience for JavaScript as a result.
Make the project that's created by
yarn create redwood-app
support TypeScript:*.js
files increate-redwood-app
repo to TypeScript.create-redwood-app
package.tsconfig.json
file in a projectMake the generators TS/ JS aware:
👉See sub-Tracking Issue #523
The api side:
.ts
files via theimportAll.macro
(tests!)context
, is that a problem in the ts world?.ts
files.The bridge between api and web:
currentUser
returned fromapi/src/lib/user.ts
withgetCurrentUser
inuseAuth
The web side:
.ts/ .tsx
files?Framework/Packages
packages/api/makeMergedSchema/*
to TypeScript #563Tooling
The text was updated successfully, but these errors were encountered: