-
Notifications
You must be signed in to change notification settings - Fork 3
Meteor typescript support #285
Comments
|
Having 1st class TypeScript support for Meteor would be huge! There's also a problem with absolute imports that needs to be fixed as well with typescript. microsoft/TypeScript#13730 |
I've been writing more and more TypeScript lately, and I approve of this direction. I'm going to need some help validating the functionality of this |
I am happy to help you out here!
👍 since babel can handle typescript, that's the best way to go! |
I'm happy to test any beta release of the typescript > babel package 👍 |
It would be great to have this. |
@benjamn it would be great to see that support added, as we at Rocket.Chat are looking to move towards TypeScript (some of the packages we write extenerally and import are TypeScript) for our code internally. However, as mentioned the |
...it gets more and more annoying to be struck with meteor |
@scharf We hear you! |
@scharf FYI babartus updated TS to 2.8 |
I made some experiments using It turns out, that on my project Scenario
|
Forgot to mention how long it really takes until the app updates: with I have a 2017 MacBookPro (2,9 GHz Intel Core i7), some of my co-workers have slower computers and it takes up to a minute to update with |
Wouldn't it be possible to let It doesn't sound efficient, as your then building two times. Kind of a 2 stage build. But if I understand @scharf correctly, he's already doing something like that and it seems to be a lot faster. |
The only reason I still use |
I thought about this... Hmmm with the |
We're still going to want to wrap |
@benjamn awesome! Any ideas when this will be started or any eta? I would love to get started using TypeScript within Rocket.Chat, since we will soon be having a definitions it only makes sense to move towards TypeScript..especially as a large open source project. ❤️ |
...but if it reduces the update time on each meteor watch cycle form 30 sec to 4 seconds it makes a difference -- and debugging the generated code without .map is better than wasting hours waiting for meteor to update.... |
That 30 second baseline is based on |
yes ... and I am sure a real integration of TypeScript into meteor could do much better 😉 I have days where meteor rebuilds 300 times and my hack saves me 2h of waiting time.... |
One more spec to add to this story could be the source map for Android/iOS. |
Would it be possible to use TypeScript only for the tooling. With a (glad to see that TS support is coming tho) |
I have been working with TypeScript for more than 2 years and love it. I see that many projects either switch to TypeScript or are developed with TypeScript right from the start. I am not a meteor user yet, but would like to try it. Therefore a big +1 for TypeScript only! |
UP, any news? Is there official docs how to use TypeScript with Meteor? |
Did someone try this already with meteor? https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/ |
@yorrd as soon as the next repo for barbatus/ardonis:typescript is settled, I'll start contributing. Likely to first simplify dependencies ( @MastroLindus I was referring to DefinitelyTyped (where barbatus is listed among the maintainers) which could do with some/much improvements. |
@yorrd One thing I noticed recently is that I don't see anymore errors in the command line , I am using visual code as a IDE with the typescript version set to my workspace one, and if I open the file with it I do see the errors correctly, but not when meteor/adornis compile those files... I didn't notice this previously.. |
@PopGoesTheWza finishing the move to a new repo and some minor cleanup today @MastroLindus yeah. We had loads of warnings and I didn't have the nerve to only show fatal errors. You're right, that's high up on the todo list. Feel free to contribute once we got the repo. Sorry for not communicating this |
@MastroLindus fixed in the last version, syntax errors are shown now. For the rest, use your IDE :P (logging is kind of a mess right now, whatever, later) @everyone new github repos @ https://github.com/Adornis/typescript and https://github.com/Adornis/typescript-compiler, please use the former for issues. Pull requests absolutely encouraged. Let's move the discussion there. |
Hi @benjamn ! |
My workaround for using typescript in meteor has been to use the tsc --watch command, and then output all of my typescript target es6, which meteor then sees and does it's normal build process. It's not perfect, but it's actually pretty fast and lets me use typescript without having to wade into meteor's build system. You will need to declare some modules in order to import Meteor packages into typescript files for everything to play nicely together. |
we managed to make the typescript version variable in adornis:typescript. You can now "link" your project's typescript version into the package WITHOUT cloning it locally. Especially important because TypeScript 3.4 has a 20x performance regression in our projects... |
@yorrd In the adornis typescript readme it states that
Here though you mention that it works without cloning it locally. |
@MastroLindus sorry, I thought we could do it. It seems Meteor doesn't forward env vars to the compiler by default. Maybe someone else knows more about this? In our team, we currently just downgrade the |
@yorrd that's too bad, thank you anyway for trying and sorry I cannot help too much, my knowledge of meteor internals is also very limited. If you have access at least to the meteor root folder of the project, would it be possible, even without the need for an env var, to check if there's a typescript version installed in METEOR_ROOT/node_modules/typescript and use it if found? |
Of topic: In my pursue to move away from some meteor core stuff an be more compatible with standard components, I switched from |
@MastroLindus I agree. Played around with using the typescript version from the hosting project folder but didn't succeed so far. To be honest, I forgot what I have tried, it's been a few months. Honestly, at the moment I'm happy with just pushing the version manually, don't think it's worth the hassle. If someone wants to submit a pull request, I'll gladly accept. @arichter83 we did try doing webpack in meteor, it just doesn't feel like meteor anymore tbh. The no config build system is one of the biggest reasons we use meteor. |
@arichter83 we switched our main project from the standard build to webpack last year, and were happy with it in the beginning. Then we noticed recurring build time issues, extra machine load due to changes detection, then the package went unsupported, and fast-forward a few months, we're back on the standard Meteor build and getting all the improvements brought with the new versions. At this point, webpack no longer seems an worthy option for Meteor projects. |
@yorrd thank you so much for your efforts anyway. Hoping that sooner or later we will get a more official typescript compiler from MDG, going forward in this way for a few months is not that bad, and your plugin has come a long way too! @arichter83 I join the others in saying that for me too weback is not the answer. We already don't use blaze anymore, we already use many NPM packages instead of atmosphere, we already opt-out reactivity when we don't need it, if we stop using the meteor build tools tools in favor of webpack at that point the whole point of using meteor in my opinion would become questionable. |
Hopefully some official input is still inbound. In the meantime, we've been experimenting with using JSDoc typing. Perhaps not as clean, but seems to work well enough. There's some documentation scattered around the place on how to get started, e.g. on the TS Github wiki. Biggest problem: there's nothing that warns you about type errors when running your application, so it can be tempting to ignore how correct your typings are. When types hard to express in JSDoc format, you can drop down to .d.ts files like so: // moduleUno/index.types.d.ts
export type MyFunc = <T>(param: T) => T // moduleUno/index.js
// @ts-check
/** @typedef {import('./index.types.d.ts').MyFunc} MyFunc */
import { Meteor } from 'meteor/meteor'
/** @type {MyFunc} */
export let myFunc = param => {
return param
}
/**
* @template T
* @param {T} param
*/
export let myOtherFunc = param => {
return param
} // moduleDos/index.js
import { myOtherFunc } from './moduleUno'
// ^^^^^^^^^^^ -- should grab the type info from the other module
// (and it should be `<T>(param: T) => T`) So if you need typechecking, don't want to commit to writing actual TypeScript in Meteor yet, and don't mind the Ecmascript package's performance, this seems like an OK alternative solution. |
@ceigey We've been doing exactly that for almost half a year now and I would recommend it to anyone that is unable to commit completely to TS. |
Given that @benjamn talk at the next Meteor night is: Reimplementing Meteor in TypeScript, Module by Module |
So how are you guys handling this now? babel-typescript? ardonis:typescript? Make tsc compile to a single file, and feed that to meteor? It would be interesting to know how you've handled this. And if there is a migration path, that allows for a |
@smeijer for my team, we're transitioning from using tsc manually and pointing Meteor to the build artefacts, to using ES6+ with JSDoc comments and .d.ts files (as hinted at in my above comment). Both approaches require running tsc in --watch mode in the background, but the latter solution is far less intrusive (as there's no awkward situation where Meteor is requiring tsc to build the files first to run). |
@smeijer well I'm biased (disclaimer, That being said, one of Meteor's strengths is its easy to use compiler which doesn't need hours of configuration work. So the only real solution is to have a compiler plugin. Working on incremental at the moment, could use help... Every other solution involves having a separate process we have to manage or essentially not writing |
@smeijer I'm still compiling my .ts and .tsx files into their .js and .jsx counterparts, which meteor then sees. It's not perfect but I think it's the best way to write typescript in an incremental fashion and doesn't involve getting into the meteor compilers core guts. @yorrd I agree that one of the main reasons why I use meteor is that I don't want to get sucked into webpack configs and compiler settings, which is why it would be really nice to have first class support for typescript. Hopefully in a future release! |
Cross-posting this comment: If you update to the latest beta by running meteor update --release 1.8.2-beta.16 you can then run meteor add typescript to try the new Thanks to @scharf for starting this discussion, and to everyone else for investigating different strategies here. I know I didn’t comment much, but I was paying attention. |
@benjamn Thank you. As I understand, the Meteor Typescript compiler has certain limitations. Can you clarify what advantages it brings compared to using the official Typescript compiler directly and having it generate js(x) files in a directory seen by Meteor build, so Meteor builds them into the final product (processing them through Babel)? |
@alesn I believe the PR convo here meteor/meteor#10610 will answer your questions. |
@filipenevola This has been resolved, right? See previous comment. |
@benjamn Thank you for your effort! Since I opened it, I will also close it! |
AFAIK, the barbatus:typescript is the "official" typescript support.
However, it seems that the project is not updated anymore.
I think meteor should support typescript natively like meteor supports coffeescript.
Coffeescript is much less popular than typescript:
The text was updated successfully, but these errors were encountered: