Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions projects/igniteui-angular/migrations/common/ServerHost.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Tree } from '@angular-devkit/schematics';
import type { Tree } from '@angular-devkit/schematics/index.js';
import * as pathFs from 'path';
import * as ts from 'typescript/lib/tsserverlibrary';
import { CUSTOM_TS_PLUGIN_NAME, CUSTOM_TS_PLUGIN_PATH } from './tsUtils';
import * as ts from 'typescript/lib/tsserverlibrary.js';
import { CUSTOM_TS_PLUGIN_NAME, CUSTOM_TS_PLUGIN_PATH } from './tsUtils.ts';

Check failure on line 4 in projects/igniteui-angular/migrations/common/ServerHost.ts

View workflow job for this annotation

GitHub Actions / run-tests (22.x)

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.
import { createRequire } from 'module';

/**
Expand All @@ -15,7 +15,9 @@
/** Cached because Angular schematics encapsulation's customRequire doesn't provide `resolve` */
private nativeRequire = createRequire(__filename);

constructor(public host: Tree) {
public host: Tree;
constructor(host: Tree) {
this.host = host;
this.args = ts.sys.args;
this.newLine = ts.sys.newLine;
this.useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { UnitTestTree } from '@angular-devkit/schematics/testing';
import { UnitTestTree } from '@angular-devkit/schematics/testing/index.js';
import * as fs from 'fs';
import * as path from 'path';
import { ClassChanges, BindingChanges, SelectorChanges, ThemeChanges, ImportsChanges, ElementType, ThemeType, MemberChanges } from './schema';
import { UpdateChanges, InputPropertyType, BoundPropertyObject } from './UpdateChanges';
import * as tsUtils from './tsUtils';
import { setupTestTree } from './setup.spec';
import { ClassChanges, BindingChanges, SelectorChanges, ThemeChanges, ImportsChanges, ElementType, ThemeType, MemberChanges } from './schema/index.ts';
import { UpdateChanges, InputPropertyType, BoundPropertyObject } from './UpdateChanges.ts';
import * as tsUtils from './tsUtils.ts';
import { setupTestTree } from './setup.spec.ts';

describe('UpdateChanges', () => {
let appTree: UnitTestTree;
Expand Down
39 changes: 24 additions & 15 deletions projects/igniteui-angular/migrations/common/UpdateChanges.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import * as fs from 'fs';
import * as path from 'path';
import * as ts from 'typescript';
import * as tss from 'typescript/lib/tsserverlibrary';
import * as tss from 'typescript/lib/tsserverlibrary.js';
import type { SchematicContext, Tree, FileVisitor } from '@angular-devkit/schematics';
import type { WorkspaceSchema } from '@schematics/angular/utility/workspace-models';
import {
ClassChanges, BindingChanges, SelectorChange,
SelectorChanges, ThemeChanges, ImportsChanges, MemberChanges, ThemeChange, ThemeType
} from './schema';
} from './schema/index.ts';

Check failure on line 10 in projects/igniteui-angular/migrations/common/UpdateChanges.ts

View workflow job for this annotation

GitHub Actions / run-tests (22.x)

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.
import {
getLanguageService, getRenamePositions, getIdentifierPositions,
isMemberIgniteUI, NG_LANG_SERVICE_PACKAGE_NAME, NG_CORE_PACKAGE_NAME, findMatches
} from './tsUtils';
} from './tsUtils.ts';

Check failure on line 14 in projects/igniteui-angular/migrations/common/UpdateChanges.ts

View workflow job for this annotation

GitHub Actions / run-tests (22.x)

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.
import {
getProjectPaths, getWorkspace, getProjects, escapeRegExp, replaceMatch,
getPackageManager, canResolvePackage, tryInstallPackage, tryUninstallPackage, getPackageVersion
} from './util';
import { ServerHost } from './ServerHost';
import { serviceContainer } from './project-service-container';
} from './util.ts';

Check failure on line 18 in projects/igniteui-angular/migrations/common/UpdateChanges.ts

View workflow job for this annotation

GitHub Actions / run-tests (22.x)

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.
import { ServerHost } from './ServerHost.ts';

Check failure on line 19 in projects/igniteui-angular/migrations/common/UpdateChanges.ts

View workflow job for this annotation

GitHub Actions / run-tests (22.x)

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.
import { serviceContainer } from './project-service-container.ts';

Check failure on line 20 in projects/igniteui-angular/migrations/common/UpdateChanges.ts

View workflow job for this annotation

GitHub Actions / run-tests (22.x)

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.

const TSCONFIG_PATH = 'tsconfig.json';

export enum InputPropertyType {
EVAL = 'eval',
STRING = 'string'
}
export const InputPropertyType = {
EVAL: 'eval',
STRING: 'string'
} as const;
export type InputPropertyType = typeof InputPropertyType[keyof typeof InputPropertyType];
declare type TransformFunction = (args: BoundPropertyObject) => void;
export interface BoundPropertyObject {
value: string;
Expand Down Expand Up @@ -143,7 +144,14 @@
*
* @param rootPath Root folder for the schematic to read configs, pass __dirname
*/
constructor(private rootPath: string, private host: Tree, private context?: SchematicContext) {
private rootPath: string;
private host: Tree;
private context?: SchematicContext;

constructor(rootPath: string, host: Tree, context?: SchematicContext) {
this.rootPath = rootPath;
this.host = host;
this.context = context;
this.workspace = getWorkspace(host);
this.sourcePaths = getProjectPaths(this.workspace);

Expand Down Expand Up @@ -774,7 +782,7 @@
if (this.inputChanges && this.inputChanges.changes.length) {
// name change of input
for (const entryPath of this.templateFiles) {
this.updateBindings(entryPath, this.inputChanges, BindingType.Input);

Check failure on line 785 in projects/igniteui-angular/migrations/common/UpdateChanges.ts

View workflow job for this annotation

GitHub Actions / run-tests (22.x)

Argument of type '"Input"' is not assignable to parameter of type '"Output"'.
}
}
}
Expand Down Expand Up @@ -867,7 +875,8 @@
}
}

export enum BindingType {
Output,
Input
}
export const BindingType = {
Output: 'Output',
Input: 'Input'
Copy link

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BindingType object has inconsistent value assignments. 'Output' should map to a numeric value (0) to maintain compatibility with the original enum, not the string 'Output'.

Suggested change
Input: 'Input'
Output: 0,
Input: 1

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BindingType object has inconsistent value assignments. 'Input' should map to a numeric value (1) to maintain compatibility with the original enum, not the string 'Input'.

Suggested change
Input: 'Input'
Output: 0,
Input: 1

Copilot uses AI. Check for mistakes.
} as const;
export type BindingType = typeof BindingType[keyof typeof BindingType];
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { filter } from '@angular-devkit/schematics';
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { getWorkspace, getWorkspacePath, getProjectPaths } from './util';
import { filter } from '@angular-devkit/schematics/index.js';
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics/index.js';
import { getWorkspace, getWorkspacePath, getProjectPaths } from './util.ts';

Check failure on line 3 in projects/igniteui-angular/migrations/common/filterSourceDirs.ts

View workflow job for this annotation

GitHub Actions / run-tests (22.x)

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.

/**
* @deprecated Temporary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as tss from 'typescript/lib/tsserverlibrary';
import { createProjectService } from './tsUtils';
import { ServerHost } from './ServerHost';
import * as tss from 'typescript/lib/tsserverlibrary.js';
import { createProjectService } from './tsUtils.ts';

Check failure on line 2 in projects/igniteui-angular/migrations/common/project-service-container.ts

View workflow job for this annotation

GitHub Actions / run-tests (22.x)

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.
import { ServerHost } from './ServerHost.ts';

Check failure on line 3 in projects/igniteui-angular/migrations/common/project-service-container.ts

View workflow job for this annotation

GitHub Actions / run-tests (22.x)

An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.

export class ProjectServiceContainer {
private _serverHost: ServerHost;
Expand Down
23 changes: 13 additions & 10 deletions projects/igniteui-angular/migrations/common/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export interface ThemeChanges {
changes: ThemeChange[];
}

export enum ThemeType {
Variable = 'variable',
Property = 'property',
Function = 'function',
Mixin = 'mixin'
}
export const ThemeType = {
Variable: 'variable',
Property: 'property',
Function: 'function',
Mixin: 'mixin'
} as const;
export type ThemeType = typeof ThemeType[keyof typeof ThemeType];

export interface ThemeChange extends ChangeAction {
/** Name of the theme property */
name: string;
Expand Down Expand Up @@ -92,7 +94,8 @@ export interface ImportsChanges {
changes: ImportsChange[];
}

export enum ElementType {
Directive = 'directive',
Component = 'component'
}
export const ElementType = {
Directive: 'directive',
Component: 'component'
} as const;
export type ElementType = typeof ElementType[keyof typeof ElementType];
8 changes: 4 additions & 4 deletions projects/igniteui-angular/migrations/common/setup.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { readFileSync } from 'fs';
import { join } from 'path';

import { EmptyTree } from '@angular-devkit/schematics';
import { UnitTestTree } from '@angular-devkit/schematics/testing';
import * as tss from 'typescript/lib/tsserverlibrary';
import { serviceContainer } from './project-service-container';
import { EmptyTree } from '@angular-devkit/schematics/index.js';
import { UnitTestTree } from '@angular-devkit/schematics/testing/index.js';
import * as tss from 'typescript/lib/tsserverlibrary.js';
import { serviceContainer } from './project-service-container.ts';

const configJson = {
version: 1,
Expand Down
28 changes: 15 additions & 13 deletions projects/igniteui-angular/migrations/common/tsLogger.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import * as ts from 'typescript/lib/tsserverlibrary';
import * as ts from 'typescript/lib/tsserverlibrary.js';

export class Logger implements ts.server.Logger {
constructor(
private readonly traceToConsole: boolean,
private readonly level: ts.server.LogLevel
) { }
private readonly traceToConsole: boolean;
private readonly level: ts.server.LogLevel;
constructor(traceToConsole: boolean, level: ts.server.LogLevel) {
this.traceToConsole = traceToConsole;
this.level = level;
}

public hasLevel(level: ts.server.LogLevel) {
return this.loggingEnabled() && this.level >= level;
}

public loggingEnabled() {
loggingEnabled() {
return this.traceToConsole;
}

public perftrc(s: string) {
perftrc(s: string) {
this.msg(s, ts.server.Msg.Perf);
}

public info(s: string) {
info(s: string) {
this.msg(s, ts.server.Msg.Info);
}

public msg(s: string, type: ts.server.Msg = ts.server.Msg.Err) {
msg(s: string, type: ts.server.Msg = ts.server.Msg.Err) {
if (!this.traceToConsole) {
return;
}
Expand All @@ -41,13 +43,13 @@ export class Logger implements ts.server.Logger {
/* These methods are used to log to a file,
we will only use the logger to log on the console.
*/
public close() { }
close() { }

public startGroup() { }
startGroup() { }

public endGroup() { }
endGroup() { }

public getLogFileName() {
getLogFileName() {
return null;
}
//#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as tss from 'typescript/lib/tsserverlibrary';
import * as tss from 'typescript/lib/tsserverlibrary.js';

export interface TSLanguageService extends tss.LanguageService {
getTypeScriptLanguageService(): tss.LanguageService;
Expand Down
27 changes: 14 additions & 13 deletions projects/igniteui-angular/migrations/common/tsUtils.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import * as ts from 'typescript';
import * as tss from 'typescript/lib/tsserverlibrary';
import type { Tree } from '@angular-devkit/schematics';
import type { MemberChange } from './schema';
import { escapeRegExp } from './util';
import { Logger } from './tsLogger';
import { TSLanguageService } from './tsPlugin/TSLanguageService';
import * as tss from 'typescript/lib/tsserverlibrary.js';
import type { Tree } from '@angular-devkit/schematics.js';
import type { MemberChange } from './schema.ts';
import { escapeRegExp } from './util.ts';
import { Logger } from './tsLogger.ts';
import { TSLanguageService } from './tsPlugin/TSLanguageService.ts';

export const IG_PACKAGE_NAME = 'igniteui-angular';
export const NG_LANG_SERVICE_PACKAGE_NAME = '@angular/language-service';
export const NG_CORE_PACKAGE_NAME = '@angular/core';
export const CUSTOM_TS_PLUGIN_PATH = './tsPlugin';
export const CUSTOM_TS_PLUGIN_PATH = './tsPlugin.ts';
export const CUSTOM_TS_PLUGIN_NAME = 'igx-ts-plugin';

enum SyntaxTokens {
ClosingParenthesis = ')',
MemberAccess = '.',
Question = '?'
}
export const SyntaxTokens = {
ClosingParenthesis: ')',
MemberAccess: '.',
Question: '?'
} as const;
export type SyntaxTokens = typeof SyntaxTokens[keyof typeof SyntaxTokens];

export class MemberInfo implements Pick<tss.DefinitionInfo, 'name' | 'fileName'> {
public name: string;
Expand Down Expand Up @@ -101,7 +102,7 @@ export const getRenamePositions = (sourcePath: string, name: string, service: ts
const positions = [];

// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const imports = source.statements.filter(<(a: ts.Statement) => a is ts.ImportDeclaration>namedImportFilter);
const imports = source.statements.filter(namedImportFilter) as ts.ImportDeclaration[];
if (!imports.length) {
return positions;
}
Expand Down
25 changes: 19 additions & 6 deletions projects/igniteui-angular/migrations/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,22 @@ export interface SourceOffset {

export class FileChange {

public position: number;
public text: string;
public replaceText = '';
public type: 'insert' | 'replace' = 'insert';

constructor(
public position = 0,
public text = '',
public replaceText = '',
public type: 'insert' | 'replace' = 'insert'
) { }
position = 0,
text = '',
replaceText = '',
type: 'insert' | 'replace' = 'insert'
) {
this.position = position;
this.text = text;
this.replaceText = replaceText;
this.type = type;
}

public apply(content: string) {
if (this.type === 'insert') {
Expand Down Expand Up @@ -250,7 +260,10 @@ class SerializerVisitor implements Visitor {
/**
*
*/
constructor(private getHtmlTagDefinition: (tagName: string) => HtmlTagDefinition) { }
private getHtmlTagDefinition: (tagName: string) => HtmlTagDefinition;
constructor(getHtmlTagDefinition: (tagName: string) => HtmlTagDefinition) {
this.getHtmlTagDefinition = getHtmlTagDefinition;
}

public visitElement(element: Element, _context: any): any {
if (this.getHtmlTagDefinition(element.name).isVoid) {
Expand Down
Loading