@@ -381,6 +381,16 @@ export class MigrateController
381
381
this . spinner . text = "Project dependencies have been updated" ;
382
382
this . spinner . succeed ( ) ;
383
383
384
+ // update tsconfig
385
+ const tsConfigPath = path . resolve ( projectDir , "tsconfig.json" ) ;
386
+ if ( this . $fs . exists ( tsConfigPath ) ) {
387
+ this . spinner . start ( "Updating tsconfig.json" ) ;
388
+
389
+ await this . migrateTSConfig ( tsConfigPath ) ;
390
+
391
+ this . spinner . succeed ( "Updated tsconfig.json" ) ;
392
+ }
393
+
384
394
// add latest runtimes (if they were specified in the nativescript key)
385
395
// this.spinner.start("Updating runtimes");
386
396
//
@@ -780,8 +790,24 @@ export class MigrateController
780
790
constants . NODE_MODULES_FOLDER_NAME ,
781
791
constants . WEBPACK_CONFIG_NAME ,
782
792
constants . PACKAGE_LOCK_JSON_FILE_NAME ,
783
- constants . TSCCONFIG_TNS_JSON_NAME ,
784
793
] ) ;
794
+
795
+ const {
796
+ dependencies,
797
+ devDependencies,
798
+ } = await this . $pluginsService . getDependenciesFromPackageJson (
799
+ projectData . projectDir
800
+ ) ;
801
+ const hasSchematics = [ ...dependencies , ...devDependencies ] . find (
802
+ ( p ) => p . name === "@nativescript/schematics"
803
+ ) ;
804
+
805
+ if ( ! hasSchematics ) {
806
+ // clean tsconfig.tns.json if not in a shared project
807
+ await this . $projectCleanupService . clean ( [
808
+ constants . TSCCONFIG_TNS_JSON_NAME ,
809
+ ] ) ;
810
+ }
785
811
}
786
812
787
813
private async handleAutoGeneratedFiles (
@@ -1182,6 +1208,31 @@ export class MigrateController
1182
1208
return dependencies ;
1183
1209
}
1184
1210
1211
+ private async migrateTSConfig ( tsConfigPath : string ) : Promise < boolean > {
1212
+ try {
1213
+ const configContents = this . $fs . readJson ( tsConfigPath ) ;
1214
+
1215
+ // update
1216
+ configContents . compilerOptions = configContents . compilerOptions || { } ;
1217
+ configContents . compilerOptions . target = "es2017" ;
1218
+ configContents . compilerOptions . module = "esnext" ;
1219
+ configContents . compilerOptions . moduleResolution = "node" ;
1220
+ configContents . compilerOptions . experimentalDecorators = true ;
1221
+ configContents . compilerOptions . removeComments = false ;
1222
+
1223
+ configContents . compilerOptions . lib = [
1224
+ ...new Set ( [ ...( configContents . compilerOptions . lib || [ ] ) , "es2017" ] ) ,
1225
+ ] ;
1226
+
1227
+ this . $fs . writeJson ( tsConfigPath , configContents ) ;
1228
+
1229
+ return true ;
1230
+ } catch ( error ) {
1231
+ this . $logger . trace ( "Failed to migrate tsconfig.json. Error is: " , error ) ;
1232
+ return false ;
1233
+ }
1234
+ }
1235
+
1185
1236
private async migrateNativeScriptAngular ( ) : Promise < IMigrationDependency [ ] > {
1186
1237
const dependencies = [
1187
1238
{
0 commit comments