Skip to content

Commit 259ca2f

Browse files
authored
feat: 9.1 migrate (#6138)
1 parent 137f31f commit 259ca2f

1 file changed

Lines changed: 48 additions & 9 deletions

File tree

lib/controllers/migrate-controller.ts

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class MigrateController
122122
{
123123
packageName: "@nativescript/core",
124124
minVersion: "6.5.0",
125-
desiredVersion: "~9.0.0",
125+
desiredVersion: "~9.1.0",
126126
shouldAddIfMissing: true,
127127
},
128128
{
@@ -132,7 +132,7 @@ export class MigrateController
132132
{
133133
packageName: "@nativescript/types",
134134
minVersion: "7.0.0",
135-
desiredVersion: "~9.0.0",
135+
desiredVersion: "~9.1.0",
136136
isDev: true,
137137
},
138138
{
@@ -191,7 +191,7 @@ export class MigrateController
191191
{
192192
packageName: "@nativescript/angular",
193193
minVersion: "10.0.0",
194-
desiredVersion: "^20.0.0",
194+
desiredVersion: "~22.0.0",
195195
async shouldMigrateAction(
196196
dependency: IMigrationDependency,
197197
projectData: IProjectData,
@@ -242,7 +242,7 @@ export class MigrateController
242242
{
243243
packageName: "@nativescript/unit-test-runner",
244244
minVersion: "1.0.0",
245-
desiredVersion: "~3.0.0",
245+
desiredVersion: "~4.0.1",
246246
async shouldMigrateAction(
247247
dependency: IMigrationDependency,
248248
projectData: IProjectData,
@@ -263,7 +263,7 @@ export class MigrateController
263263
packageName: "typescript",
264264
isDev: true,
265265
minVersion: "3.7.0",
266-
desiredVersion: "~5.8.0",
266+
desiredVersion: "~6.0.0",
267267
},
268268
{
269269
packageName: "node-sass",
@@ -296,13 +296,13 @@ export class MigrateController
296296
{
297297
packageName: "@nativescript/ios",
298298
minVersion: "6.5.3",
299-
desiredVersion: "~9.0.0",
299+
desiredVersion: "~9.1.0",
300300
isDev: true,
301301
},
302302
{
303303
packageName: "@nativescript/android",
304304
minVersion: "7.0.0",
305-
desiredVersion: "~9.0.0",
305+
desiredVersion: "~9.1.0",
306306
isDev: true,
307307
},
308308
];
@@ -1246,6 +1246,8 @@ export class MigrateController
12461246
...new Set([...(configContents.compilerOptions.lib || []), "ESNext"]),
12471247
];
12481248

1249+
this.migrateTSConfigForTypeScript6(configContents.compilerOptions);
1250+
12491251
if (isAngular) {
12501252
// make sure polyfills.ts is in files
12511253
if (configContents.files) {
@@ -1267,6 +1269,43 @@ export class MigrateController
12671269
}
12681270
}
12691271

1272+
// TypeScript 6 errors on 'baseUrl' and 'downlevelIteration', rejects non-relative
1273+
// 'paths' targets once 'baseUrl' is gone, drops the implicit node_modules/@types entry
1274+
// whenever 'typeRoots' is set, and flips the 'strict' default from false to true.
1275+
private migrateTSConfigForTypeScript6(compilerOptions: any): void {
1276+
const baseUrl = compilerOptions.baseUrl ?? ".";
1277+
delete compilerOptions.baseUrl;
1278+
delete compilerOptions.downlevelIteration;
1279+
1280+
// rebase against the dropped baseUrl, since targets now resolve from the tsconfig
1281+
const toRelative = (target: string) => {
1282+
if (path.posix.isAbsolute(target)) {
1283+
return target;
1284+
}
1285+
const rebased = path.posix.join(baseUrl, target);
1286+
return rebased.startsWith(".") ? rebased : `./${rebased}`;
1287+
};
1288+
1289+
if (compilerOptions.paths) {
1290+
compilerOptions.paths = _.mapValues(
1291+
compilerOptions.paths,
1292+
(targets: string[]) => targets.map(toRelative),
1293+
);
1294+
}
1295+
1296+
if (compilerOptions.typeRoots) {
1297+
compilerOptions.typeRoots = [
1298+
...new Set([
1299+
...compilerOptions.typeRoots.map(toRelative),
1300+
"./node_modules/@types",
1301+
]),
1302+
];
1303+
}
1304+
1305+
compilerOptions.strict = compilerOptions.strict ?? false;
1306+
compilerOptions.skipLibCheck = compilerOptions.skipLibCheck ?? true;
1307+
}
1308+
12701309
private async checkOrCreatePolyfillsTS(
12711310
projectData: IProjectData,
12721311
): Promise<string> {
@@ -1311,7 +1350,7 @@ export class MigrateController
13111350

13121351
private async migrateNativeScriptAngular(): Promise<IMigrationDependency[]> {
13131352
const minVersion = "10.0.0";
1314-
const desiredVersion = "~20.2.0";
1353+
const desiredVersion = "~22.0.0";
13151354

13161355
const dependencies: IMigrationDependency[] = [
13171356
{
@@ -1371,7 +1410,7 @@ export class MigrateController
13711410
{
13721411
packageName: "zone.js",
13731412
minVersion: "0.11.1",
1374-
desiredVersion: "~0.15.0",
1413+
desiredVersion: "~0.16.0",
13751414
shouldAddIfMissing: true,
13761415
},
13771416

0 commit comments

Comments
 (0)