Feature request: support TypeScript 'out of the box'

No problème with ts. Valid unicode js code si valid Unicode ts code.

2 Likes

TS is not only about Typecheck ! You also get full code completion even for imports !
Write a module once and you never have to remember its public property names.

1 Like

+1 for TypeScript as a default language!
The argument that type-checking might not be wanted by some people is not valid since TS does not force you to use type checks. There really are not draw backs!

3 Likes

The meteortypescript:compiler package might already do the trick? I wouldn’t want Meteor to have TypesScript by default. Meteor uses Babel, which aligns to the future of JavaScript.

That said, there’s nothing from preventing us from using tsc compiler manually ourselves, in tandem with Meteor. In the root of our project, we can move our Meteor app into a sub-folder, with TypeScript source code outside of that folder, then we can run tsc using the --out or --outDir options to compile our TS code into the Meteor app folder, and that will work just fine. :wink:

4 Likes

I tried using that package (https://atmospherejs.com/meteortypescript/compiler) but I had some issues running it properly. See https://github.com/meteor-typescript/meteor-typescript-compiler/issues/50. Perhaps I was not using it properly but I could not get it to work.

Manually working the directories sounds like a nice idea. I’ll try that out, thanks for sharing.

1 Like

For anyone interested, my Meteor/React boilerplate now supports Flow out of the box. If you’re using WebStorm, be sure to set your JavaScript language version to “Flow.” Otherwise you can just run npm run flow as usual.

1 Like

Cool! Question though: does your eslint still work when you set Webstorm to use Flow? (Yes, I did ask this before but now that you are actively working with it again you might be able to answer it this time :slight_smile: )

Yep, eslint works great! I’ve got this in my package.json:

"eslint-plugin-flowtype": "^2.2.7",

And then the necessary eslint settings for Flow are in .eslintrc of course.

2 Likes

The by far easiest way to setup TypeScript in meteor is to add the barbatus:typescript atmosphere package.

Just install it besides ecmascript, and you’re up and running.

Here is the tsconfig.json i use for React meteor projects

{ "compilerOptions": { "experimentalDecorators": true, "module": "commonjs", "target": "es5", "isolatedModules": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "removeComments": false, "noImplicitAny": false, "sourceMap": true, "allowJs": true, "jsx": "react" }, "filesGlob": [ "client/**/*.ts", "client/**/*.tsx", "server/**/*.ts", "server/**/*.tsx", "typings/**/*.d.ts" ], "exclude": [ "node_modules", ".meteor" ] }

The allowJs: true flag make incremental adoption of TS a lot easier, because you can convert a single file at a time.

I installed TSLint as an extension in i.e. VSCode, and also as a global package through npm - and then it worked too. The configuration I use (tslint.json) is quite long, so I haven’t embedded it here.

I installed typings as a global package through npm. After you install some types you might need to restart VSCode in order for it to pick it up.

6 Likes

+1 for TypeScript support in Meteor tutorials, tooling, etc (like it is in Apollo).

People from the FHIR project have published a comprehensive type definitions file for resources in healthcare, based on the HL7 standards. Looking at how to support this.

This would be nice as an out-of-the-box option by simply meteor add typescript then just any files that end with .ts or .tsx are handled.

The only real problem is: if there is a .js file that imports a .ts file, how does that get handled?

I’ve dealt with this sort of thing in a project, and it’s a lot of work to meld .js + .ts together, but it can be done.

2 Likes

Works perfect! Thanks for responses! :birthday:

+10,000 that will be amazing :slight_smile:

1 Like