Note I'm not pro or anti myself, I've only just begun playing with it, but would like to hear from all kinds of people.
Note I'm not pro or anti myself, I've only just begun playing with it, but would like to hear from all kinds of people.
I'm a huge fan of strongly-typed code, but I like to add the types much later, once all of the pieces are in place and are not in constant change, and mostly as a way to not have to write unit tests. If I type from the start I find I lock in to sub-optimal data structures and get "attached" to them. I already typed them, I don't want to break things!
Also, I live by the "What Would Rich Hickey Do?" school of thought... so when he mandates types in Clojure, I'll switch to TypeScript by default ;)
You could use the allowJs typescript flag and mostly use JS files at first; perhaps only typing a few models.
But TS is at this moment really eating JS jobs, and that kinda hurts. I just don't understand the proponents, besides the job opportunity, give me one single reason to write in TS? If you want to go for a strictly typed language TS is definitely the worse choice. TS simply doesn't fit in the JS ecosystem. Look at (a part of) the dependency part of this package.json, from the beginning of a large project. Don't you agree something is going very wrong in the JS world?
"ts-jest": "^23.1.3",
"ts-loader": "^4.5.0",
"ts-node": "^7.0.1",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.14.0",
"tslint-react": "^3.6.0",
"typescript": "^3.0.1",
"typings-for-css-modules-loader": "^1.7.0",
"@sentry/browser": "^4.0.0-beta.12",
"@sentry/node": "4.0.0-beta.12",
"@sentry/types": "^4.0.0-beta.12",
"@types/autoprefixer": "^6.7.3",
"@types/classnames": "^2.2.6",
"@types/clean-webpack-plugin": "^0.1.2",
"@types/compression": "0.0.36",
"@types/cookie-parser": "^1.4.1",
"@types/cors": "^2.8.4",
"@types/cucumber": "^4.0.4",
"@types/enzyme": "^3.1.13",
"@types/enzyme-adapter-react-16": "^1.0.3",
"@types/enzyme-to-json": "^1.5.2",
"@types/express": "^4.16.0",
"@types/helmet": "0.0.38",
"@types/html-webpack-plugin": "^3.2.0",
"@types/jest": "^23.3.1",
"@types/js-cookie": "^2.1.0",
"@types/memwatch-next": "^0.3.1",
"@types/node": "^10.5.7",
"@types/node-sass": "^3.10.32",
"@types/optimize-css-assets-webpack-plugin": "^1.3.3",
"@types/react": "^16.4.11",
"@types/react-dom": "^16.0.7",
"@types/react-helmet": "^5.0.7",
"@types/react-intl": "^2.3.10",
"@types/react-loadable": "^5.4.1",
"@types/react-redux": "^6.0.6",
"@types/react-router-dom": "^4.3.0",
"@types/redux-mock-store": "^1.0.0",
"@types/serve-favicon": "^2.2.30",
"@types/webdriverio": "^4.10.3",
"@types/webpack-merge": "^4.1.3",
"@types/webpack-node-externals": "^1.6.3",
"webpack": "4.19.0",
"webpack-assets-manifest": "^3.0.2",
"webpack-cli": "3.1.0",
"webpack-dev-middleware": "^3.1.3",
"webpack-dev-server": "^3.1.5",
"webpack-hot-middleware": "^2.22.3",
"webpack-merge": "^4.1.4",
"webpack-node-externals": "^1.7.2",
"stylelint": "^9.5.0",
"stylelint-config-prettier": "^4.0.0",
"stylelint-config-recess-order": "^2.0.0",
"stylelint-config-recommended-scss": "^3.2.0",
"stylelint-scss": "^3.3.0",The absolute worst case with TS is that I'm as bad off as I would be in JS (use "any", or "as", or provide a dummy anything-goes d.ts for a lib, or whatever). I haven't found that I actually need to do those things very often, even being fairly lazy and having a very low tolerance for time lost to managing my tools.
You and the author are both overly concerned about writing code and completely ignoring maintainability. If you write your code once and never touch it again, sure, use plain JS. If you're going to come back in six months month and refactor it or hand it off to a co-worker and expect him to write some code TypeScript is a godsend.
JS developers moving to TS should at least do a few weeks of Assembly and C programming to first understand the origin of types. I've spoken too many front-end devs who don't have a clue what a type actually is and at the same time promote TS. It's a godsend we don't need them in scripting languages. Use tooling to catch issues, that's the future, TS is just a whim.