Tag Archives: typescript

Bot for Slack built with TypeScript and node – @genos

You can find the bot project on my Github – slack-genos.

genos-bot-slack

There is a node package called slack that extracts all the Slack API and create functions for each.

npm i -S slack

They don’t provide TypeScript definition files, but we can create on own file under /typings folder.

With that I created a structure to run the bot.
Continue reading

Using TypeScript to map database schema and models

Imagine a large scale application, with a big database full of tables and columns. Now imagine that you will have to remove a column from one of the tables, how would you guarantee that removing that column will not cause issues on your application?

In C# using Code First or Entity models that would be easy, your application would break when trying to reference something that no longer exist. In JavaScript you don’t get to know where things are being referenced, but if you use TypeScript there is a way to keep track of it.

Normally in JavaScript you would see code like this:

await knex('student').where('deleted', false);

Continue reading

TypeScript vs JavaScript

TypeScript is JavaScript with types, to put it simple.

  • How do I install?
    • npm i -D typescript
  • Does it work on Linux/Mac?
    • Yes
  • Does my editor support it?
  • Do I have to learn a whole new language? Like CoffeeScript, Dart…?
    • No! Absolutely no! If you know JavaScript you know 95%. The remaining 5% or less is basically configuration.
  • Any big companies using it?
  • Does it support React?
    • Yes. `.tsx` files.
  • Have you ever coded a real project with it?
    • Yes and I actually kept it compatible with the architecture of other (js) projects in my company. One of the projects is scaling.
  • How many bugs did you prevent?
    • Over 9000… A lot and very recently I found a bug in production in a very big project that would never happen if it was coded in TypeScript.
  • Do you still use babel?
    • Not if I get to choose which version of node I will be using. For some old versions some polyfills are really good… TypeScript does not add polyfills, it does not change your code more than enough to support a few ES features. You can check it out for yourself on TypeScript playground, the playground targets ES3, so if you use arrow functions or async/await TypeScript will “alter” your code.

Continue reading

Simple lightweight TypeScript 2.0 React Redux Babel Webpack project

I’m never satisfied with bootstraps out there, so I’m always creating some simple ones. Well this one is a bit more complex than the other ones I’ve built because of the complexity of React and Redux.

Check it out at brunolm/ts-react-redux-startup

I recently started using Workflowy (it is free), which is a website where you can create lists and it allows you to use as a brain dump. If you want to check it out you can use this link to get extra items https://workflowy.com/invite/35df8d82.lnx

On my Knowledge List I added things about Redux, Babel, Webpack and everything else…

Continue reading

Simple lightweight TypeScript 2.0 Babel Webpack project

I wanted to create a project using TypeScript + Babel. I knew I would have to setup a few things.

I choose to use Webpack because it has some dev tools, auto-reload. And it is nice to use loaders. But I couldn’t find any minimal simple examples, so I decided to create one.

brunolm/typescript-babel-webpack is a project with just the essential, nothing else. Simple and clean.

You can see that in this project there is a README.md where I tried to write all the steps I went through to create that setup and the issues I faced.

Continue reading