Try npm install -g typescript@latest. You can also use npm update instead of install, without the latest modifier.
Try npm install -g typescript@latest. You can also use npm update instead of install, without the latest modifier.
Open command prompt (cmd.exe/git bash)
Recommended:
npm install -g typescript@latest
or
yarn global add typescript@latest // if you use yarn package manager
This will install the latest typescript version if not already installed, otherwise it will update the current installation to the latest version.
And then verify which version is installed:
tsc -v
If you have typescript already installed you could also use the following command to update to latest version, but as commentators have reported and I confirm it that the following command does not update to latest (as of now [ Feb 10 '17])!
npm update -g typescript@latest
» npm install typescript
Videos
So I want to update my (very large*) project from TypeScript 2.3.3 to the latest version, and I know that a breaking changes doc exists.
What's your approach to go from TS 2.3 to 4.2? The way I see it is...
Switch to latest version, run a TS build and address errors as needed. I figure this is the best approach, but maybe I'm wrong.
Use the breaking change doc and look at major version only. So look at 2.x -> 3.x breaking changes. Fix each manually, then upgrade to 3.x (which version?). Fix those errors an move on. This sounds pretty time consuming.
Go through the doc and address all issues. This sounds insane.
I figure #1 is probably the quickest approach (and I guess I could've been well on my way in the time that it took to write this damn post). But I wanted to see others opinions.
*this project is 180,000 lines of typescript code. I consider it a humongous projects, but I have no idea what other people work on, so who knows.
I found answer in here
First use npm install your expect typescript version in your project
Then, open gulpfile.js :
const build = require('@microsoft/sp-build-web')
// Add the following code:
const typescriptBuild = require('@microsoft/gulp-core-build-typescript')
typescriptBuild.TypeScriptConfiguration.setTypescriptCompiler(require('typescript'))
// Finish
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`)
build.initialize(require('gulp'))
Finally run gulp serve, you will see the new version with typescript:
Starting subtask 'tslint'...
Starting subtask 'typescript'...
[typescript] TypeScript version: 4.4.3
Finished subtask 'copy-static-assets' after 867 ms
Maybe you will have a typescirpt error with 'dateVersion'
you can fixed like this
// @ts-ignore
protected get dataVersion(): Version {
return Version.parse('1.0');
}
But even so, gulp compiles with Fluent8 and react@17, but it doesn't actually run on workbench projects
As for react@17, spfx workbench looks for react from node_modules/react/dist, but react@17 does not have this directory, so a 404 error will be reported
You can use below command to install the specific/latest version of typescript.
you can optionally use -g parameter to globall install the Typescript.
npm install typescript@latest
npm install [email protected] (specify version number you want to install here)