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 Issues · meteor/meteor · GitHub
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 Convert eachline.js to eachline.ts by menewman · Pull Request #10614 · meteor/meteor · GitHub @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 notimport 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 tometeor/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 intodevel
. However,devel
doesn’t seem to have all of your TS-related changes fromrelease-1.8.2
.
A Convert eachline.js to eachline.ts by menewman · Pull Request #10614 · meteor/meteor · GitHub @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 runmeteor npx tsc
from within themeteor/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 toimport
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
todev-bundle-tool-package.js
and rebuild the dev bundle. You can simulate that (without rebuilding the dev bundle) by runningmeteor npm install -g @types/split2
.- Yep, the
release-1.8.2
branch is the only place (besidesrelease-1.9
, which is still experimental) where TypeScript is supported.
Q @types Add @types/semver@5.4.0 to both dev-bundle-tools-package.js and dev-bundle-server-package.js by nicu-chiciuc · Pull Request #10633 · meteor/meteor · GitHub @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 atry...catch
statement in commit semver/7be83d15dcff73f6, so the interface wasn’t changed.
A Add @types/semver@5.4.0 to both dev-bundle-tools-package.js and dev-bundle-server-package.js by nicu-chiciuc · Pull Request #10633 · meteor/meteor · GitHub @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 inscripts/dev-bundle-server-package.js
,scripts/dev-bundle-tool-package.js