Is there any reason there's a random typscript fil...
# prisma-whats-new
r
Is there any reason there's a random typscript file in https://github.com/graphcool/framework/tree/master/examples/permissions?
a
Where?
r
On the README as well as actually in the tree.
I'll get the line..,
a
You can choose πŸ™‚
r
I don't know much about typescript, but you can use ts files in an otherwise js project?
It's literally the only ts file in there
a
You can specify the .ts file instead of the .js file in your
graphcool.yml
and it 'will just work ℒ️'
r
What are the pros and cons?
a
Personal preference.
r
huh, okay
a
Some people like to use Typescript, and Graphcool supports it.
r
Yeah, I get that, but using a single typescript file in an otherwise javascript project?
Copy code
.
β”œβ”€β”€ README.md
β”œβ”€β”€ graphcool.yml
β”œβ”€β”€ node_modules
β”œβ”€β”€ package.json
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ email-password
β”‚   β”‚   β”œβ”€β”€ authenticate.graphql
β”‚   β”‚   β”œβ”€β”€ authenticate.js
β”‚   β”‚   β”œβ”€β”€ loggedInUser.graphql
β”‚   β”‚   β”œβ”€β”€ loggedInUser.js
β”‚   β”‚   β”œβ”€β”€ signup.graphql
β”‚   β”‚   β”œβ”€β”€ signup.js
β”‚   β”‚   └── signup.ts
β”‚   └── permissions
β”‚       β”œβ”€β”€ Post.graphql
β”‚       └── User.graphql
β”œβ”€β”€ types.graphql
└── yarn.lock
a
It's just an example. I agree it doesn't make much sense in this case, but most of the examples (and templates) use Typescript. https://github.com/graphcool/templates/tree/master/auth/email-password
So the example you linked actually uses an outdated email-password template, because the current one uses only Typescript.
r
"Outdated", or just "not preferred by typescripters"?
πŸ™‚
Β―\_(ツ)_/Β―
Thanks
a
Outdated, because if you were to recreate this example manually, you'd get a different file structure.
r
Right. I was a bit disappointed to see that the
templates
folder didn't retain the javascript
email-password
option. It used to be js but was converted over to typescript. Thankfully I found the example folder in question here and that it was still using js. Also, this react-apollo example (https://github.com/graphcool-examples/react-graphql/tree/master/authentication-with-email-and-apollo) uses the js version, which is nice
a
You don't like TS?
r
I haven't had time to learn it. I'm pretty new and just keeping up with JS is enough for me to handle
At some point I would like to know both
a
It would be nice if the examples could be extended to more languages: Javascript, Typescript, Coffeescript, or anything else for that matter. But I think that's really a community effort at this point.
r
So are you saying GC is a platform for TS devs, and only supports JS through community initiated contributions?
That would be big news to me
a
No that's not what I meant.
I meant that currently, some examples are in JS, and some are in TS. And that it would be helpful for other devs if all examples came in multiple languages.
r
I don't think anyone is asking for coffeescript support, but it doesn't seem to crazy to expect JS support
a
On the other hand, we're not talking about functions with hundreds of lines of code, so the difference is minimal anyway.
r
I"m getting the feeling that GC is trying to nudge JS devs into TS.
If that's the case, I'd just like to know explicitly so I can plan accordingly
a
I can't speak for GC, but I think that is definitely not the case. All of the tools, both legacy console projects and Framework, fully support JS.
We're still talking about examples here, not about anything close to a core feature that you are 'forced' to use.
r
Except, for example, an
email-password
JS template. I'm not trying to be difficult. I'm just getting mixed messages.
a
You can write anything you want in JS, and it will be 100% supported.
r
Yeah, i get that, but I can't import a JS email-password template using the CLI. Only TS. I hope I'm not sounding like I'm complaining. You guys have delivered an awesome product, and I'm super grateful. I just want to know what direction GC is going. Will the JS email-password template be brought back at some point, for example? Why was it removed in the first place? It was written already, and then removed in favor or the current TS template.
a
Like I said, I can't speak for GC, so I'll copy @nilan in here. I think you have a valid point that it would be helpful for non-TS devs if there were more JS-based examples, on the other hand I am glad these templates exist to begin with, otherwise I'd have to write everything myself...
Maybe you can create a post on the forum, so others can chime in as well?
r
I already asked nilan about it. He said "it was removed to have unified TS examples". I understand why the TS template was created, but not why the JS template was removed. It was literally already there, why not keep it? At any rate, I left it there with him and didn't press it, because I knew he had better things to do than squabble about this issue. He's building things. That said, I would just like clarity on whether or not GC is going to support JS devs. The
auth
folder is one of the "officially supported" template folders, so when I see a JS template removed from that folder it raises a bit of a concern for me. Actually, it wasn't really a big concern then, but through this discussion it seems the 'TS over JS' narrative is getting louder. I assumed you were part of GC by how much help I see you giving people, but if you can't speak for GC then maybe not? Either way, I'm hoping the JS template comes back. At that point I won't need it, but it will be a good sign that JS is in fact going to supported moving forward.
a
No, I'm not part of GC, just a community member. But I support your view of keeping the JS examples if they are already there.
πŸ‘ 1
r
Thanks for being a rock star community helper!
πŸ™πŸ» 1
n
just chiming in, I was encouraging you to provide a JS version of the email pw template before and I'm still open to collaborate with you on that one @rion. I upgraded the templates to TypeScript for a unified experience and because I actually find it easier to code with, but I agree that we should have more JS examples out there. you should know that whenever there are TS support, there is automatically JS support, because TS gets compiled to JS anyway. so a debate whether or not JS will continued to be supported is obsolete ;)
a
I proposed on Github to add language branches to the repos so we can easily share other language versions without disrupting the repo structure.
πŸ‘ 1
r
Right, what I meant by "support" was helping out JS devs by providing ready-made templates and examples in JS. I know JS is always supported technically through transpiling. Also, I'm not asking anyone to do anything for me, I was just asking about it to know if I have to learn TS in order to use templates from the CLI. The question I've asked a few times which I'm still unclear on is why the JS template was removed. It was already there, why remove it? It kind of made me think that JS is a second class citizen here. Lastly, for folks like me, changing a working JS template to TS is not an "upgrade" - it's removing support for something. All that said, please know that I love GC and have been spreading the news about it to my limited sphere of influence.
πŸ‘πŸ» 2
i
@rion - Good points. I’m not on the GC team so opinions are my own. That being said, you can globally install TypeScript (which comes with it’s compiler) and you can compile any TS into JS. I think the compiler defaults to ES5 if you don’t use a
tsconfig.json
and only use the compiler. You can add a
tsconfig.json
and get more control the compilation process. (For example, ES6 instead of ES5.) Past that, I’d encourage you to check out TS. I had the same concerns you have about just trying to stay afloat with JS but after I actually started messing around with TS, I fell in love with it and found that it’s actually not that much to learn, especially if you come from a low-level background. (C#/Java/Go/C/C++/etc devs should feel more comfortable with TS over JS).
πŸ‘ 1
r
Thanks for that input @iamclaytonray. I think you're probably right about TS being a more comfortable and powerful language once you get the hang of it, and it's probably not too much more to learn. I am reluctant to learn yet another technology if I don't need to, so this whole conversation has been mostly about just wanting to know straight from GC which language they will be supporting (in the way I am using the term "support"). If they want to target TS devs over JS devs, just say so, so we can plan accordingly (by learning TS for example).