0

I made a project in Typescript and was afraid to update typescript when a new version came out in case it broke my app. Now I've read on Twitter that it's possible to lock a version of Typescript (presumably in a repo). How can this be done?

Do people actually not lock in their current version of TypeScript and then complain when their build breaks?

Twitter thread where it says it's possible to lock Typescript version

Leahcim
  • 40,649
  • 59
  • 195
  • 334
  • It looks like you can just add it to the config as such 1.8. https://stackoverflow.com/questions/23245395/use-specific-typescript-compiler-version-in-visual-studio. Also, it's generally better to use the latest version of a PL/Framework whenever possible. That way you don't miss out on bug fixes/security patches, etc. Make sure to thoroughly test it though, as you're right that it can sometimes break your code. – nmg49 Sep 18 '17 at 13:43
  • Updated: the language suggested by @nmg49 only seems to be for visual studio. I have a tsconfig.json . What to do there? oh, are you locking it in package.json? so a global install's not a good idea. – Leahcim Sep 18 '17 at 13:46

2 Answers2

2

Don't use latest as the dependency version and simply put a version number in your package.json

For example

"devDependencies": {
    "typescript": "2.3.2"
}

instead of "typescript: "latest"

This will "lock" the current project typescript version to "x.x.x". If you are using VSCode for instance it will provide you with the option to use the project typescript version instead of the latest VSCode typescript version.

Murat Karagöz
  • 35,401
  • 16
  • 78
  • 107
0

you can get to know the latest version of typescript

tsc --version

Hemanth Kumar
  • 809
  • 1
  • 7
  • 7