The possibility of TypeScript in Meteor become a reality and official supported. It was discussed here Official TypeScript compiler coming to Meteor
We’re starting to convert some .js files to .ts https://github.com/meteor/meteor/labels/Project%3ATypeScript-conversion
But I think we need to accept some code style for TS at first.
@benjamn Do you have idea about it? may be some template?
UPDATED 17 Jul
Q https://github.com/meteor/meteor/pull/10614#issue-296046123 @menewman
- Is the correct way to check for TS errors in this project just to open the project in VSCode and see if it gets angry? (That’s what I did and it seemed to work… okay.)
- For whatever reason, TypeScript lets me get away with code like
const pipe = require("multipipe"); but not import pipe from "multipipe"; , because for the latter version it wants me to install the type defs for that package via NPM. I have no idea how to add new NPM dependencies to meteor/tools and I’m not sure whether it’s advised/allowed even for TS types. What do you recommend we do in cases like that?
- I submitted this into the
release-1.8.2 branch because that’s where your “convert files.ts” PR was targeted, but I’m not sure if this was the right thing to do, since the Contributing guides seem to encourage submitting into devel . However, devel doesn’t seem to have all of your TS-related changes from release-1.8.2 .
A https://github.com/meteor/meteor/pull/10614#pullrequestreview-260210683 @benjamn
- Yes, I think we should use external tools (especially VSCode) for TypeScript type checking, and let
meteor-babel simply do the compilation. That said, you can also run meteor npx tsc from within the meteor/tools directory, which is something we should do as part of our Circle CI tests (edit: implemented by 06b5f32).
- Totally fine to keep it like this (using
require ) for now. At some point we’ll do a pass to convert everything to import s and make sure the appropriate @types/… packages are installed. That’s the kind of thing that should be easy to automate, so I don’t want to waste human time.
Technically, we will need to add @types/split2 to dev-bundle-tool-package.js and rebuild the dev bundle. You can simulate that (without rebuilding the dev bundle) by running meteor npm install -g @types/split2 .
- Yep, the
release-1.8.2 branch is the only place (besides release-1.9 , which is still experimental) where TypeScript is supported.
Q @types https://github.com/meteor/meteor/pull/10633 @nicusor
Add @types/semver@5.4.0 to both dev-bundle-tools-package.js and dev-bundle-server-package.js
@types/semver is important because multiple files that should be transformed to TypeScript require it (e.g. utils/utils.js ).
Regarding the versioning mismatch. There shouldn’t be any problems since the only difference between 5.4.0 and 5.4.1 is the addition of a try...catch statement in commit semver/7be83d15dcff73f6, so the interface wasn’t changed.
A https://github.com/meteor/meteor/pull/10633#pullrequestreview-262486357 @benjamn
… This will require rebuilding the dev bundle after I merge it into release-1.8.2, though you can do that locally by running
scripts/generate-dev-bundle.sh
rm -rf dev_bundle
meteor --help # downloads the new dev bundle
Summary
- Use
release-1.8.2 branch to merge your pull request
- Run
cd path/to/meteor/tools && ../meteor npx tsc to compile TS code in tools
- Install global
npm i -g @types/XXX if you need it.
Also it can be a part of dev-bundle in scripts/dev-bundle-server-package.js, scripts/dev-bundle-tool-package.js