Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(migrations): resolve property type from definition file path first #9417

Merged
merged 2 commits into from
Apr 26, 2021
Merged
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
47 changes: 47 additions & 0 deletions projects/igniteui-angular/migrations/common/UpdateChanges.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,4 +856,51 @@ export class AppModule { }`);
}
});
});

describe('Language Service migrations', () => {

it('Should be able to replace property of an event', () => {
pending('set up tests for migrations through lang service');
const membersConfig = {
member: 'onGridKeydown',
replaceWith: 'gridKeydown',
definedIn: [
'IgxGridComponent',
'IgxTreeGridComponent',
'IgxHierarchicalGridComponent',
'IgxRowIslandComponent'
]
};
const fileContent =
`import { Component } from '@angular/core';
import { IGridCreatedEventArgs } from 'igniteui-angular';
@Component({
selector: 'app-custom-grid',
template: ''
})
export class CustomGridComponent {
public childGridCreated(event: IGridCreatedEventArgs) {
event.grid.onGridKeydown.subscribe(() => {});
}
}
`;
appTree.create('test.component.ts', fileContent);
const expectedFileContent =
`import { Component } from '@angular/core';
import { IGridCreatedEventArgs } from 'igniteui-angular';
@Component({
selector: 'app-custom-grid',
template: ''
})
export class CustomGridComponent {
public childGridCreated(event: IGridCreatedEventArgs) {
event.grid.gridKeydown.subscribe(() => {});
}
}
`;
const update = new UnitUpdateChanges(__dirname, appTree);
update.applyChanges();
expect(appTree.readContent('test.component.ts')).toEqual(expectedFileContent);
});
});
});
2 changes: 1 addition & 1 deletion projects/igniteui-angular/migrations/common/tsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export const getTypeDefinitionAtPosition =
definition.name = maybeReturnType.kind === 'className' ? maybeReturnType.text : '';
return definition;
}
let typeDefs = getTypeDefinitions(langServ, entryPath, definition.textSpan.start);
let typeDefs = getTypeDefinitions(langServ, definition.fileName || entryPath, definition.textSpan.start);
// if there are no type definitions found, the identifier is a ts property, referred in an internal/external template
// or is a reference in a decorator
if (!typeDefs) {
Expand Down