Skip to content

Commit 13c549f

Browse files
committed
refactor: move version export to core entry-point
* Moves the `VERSION` export to the the `core` secondary entry-point. This ensures that the V8 package schematics don't resolve the `VERSION` symbol to the incorrect `@angular/material/typings` module name. * Removes the unused and outdated material subpackages test case that has been replaced with a working one. * Ensures that the V8 material imports rule resolves the symbol from the imported identifier and not from the aliased one (minor cleanup; no effect as we resolve the identifer to the original symbol anyway; just slower)
1 parent fe56952 commit 13c549f

File tree

9 files changed

+13
-148
lines changed

9 files changed

+13
-148
lines changed

src/lib/core/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
export * from './version';
910
export * from './animation/animation';
1011
export * from './common-behaviors/index';
1112
export * from './datetime/index';
File renamed without changes.

src/lib/public-api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
export * from './version';
109
export * from '@angular/material/autocomplete';
1110
export * from '@angular/material/badge';
1211
export * from '@angular/material/bottom-sheet';

src/lib/schematics/ng-update/test-cases/misc/material-imports.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import {join} from 'path';
55

66
describe('v8 material imports', () => {
77

8-
function writeSecondaryEntryPoint(materialPath: string, name: string) {
8+
function writeSecondaryEntryPoint(materialPath: string, name: string, exportName = name) {
99
const entryPointPath = join(materialPath, name);
1010
mkdirpSync(entryPointPath);
11-
writeFileSync(join(entryPointPath, 'index.d.ts'), `export const ${name} = '';`);
11+
writeFileSync(join(entryPointPath, 'index.d.ts'), `export const ${exportName} = '';`);
1212
}
1313

1414
it('should report imports for deleted animation constants', async () => {
@@ -21,11 +21,13 @@ describe('v8 material imports', () => {
2121
export * from './a';
2222
export * from './b';
2323
export * from './c';
24+
export * from './core';
2425
`);
2526

2627
writeSecondaryEntryPoint(materialPath, 'a');
2728
writeSecondaryEntryPoint(materialPath, 'b');
2829
writeSecondaryEntryPoint(materialPath, 'c');
30+
writeSecondaryEntryPoint(materialPath, 'core', 'VERSION');
2931

3032
await runFixers();
3133

src/lib/schematics/ng-update/test-cases/misc/material-imports_expected_output.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ import { b } from "@angular/material/b";
1010
import { c } from "@angular/material/c";
1111

1212
import { /* comment */ a as a3 } from "@angular/material/a";
13+
14+
// primary entry-point export
15+
import { VERSION } from "@angular/material/core";

src/lib/schematics/ng-update/test-cases/misc/material-imports_input.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ import {a as a2} from '@angular/material';
66
import {c, b, a} from '@angular/material';
77

88
import {/* comment */ a as a3} from '@angular/material';
9+
10+
// primary entry-point export
11+
import {VERSION} from '@angular/material';

src/lib/schematics/ng-update/test-cases/v8/material-subpackage_expected_output.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/lib/schematics/ng-update/test-cases/v8/material-subpackage_input.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/lib/schematics/ng-update/upgrade-rules/package-imports-v8/updateAngularMaterialImportsRule.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,13 @@ function walk(ctx: Lint.WalkContext<boolean>, checker: ts.TypeChecker): void {
9494

9595
// Determine the subpackage each symbol in the namedBinding comes from.
9696
for (const element of declaration.importClause.namedBindings.elements) {
97-
// Ensure the import specifier name is statically analyzable.
98-
if (!ts.isIdentifier(element.name)) {
99-
return ctx.addFailureAtNode(element, element.getText() + Rule.SYMBOL_NOT_FOUND_FAILURE_STR);
100-
}
97+
const elementName = element.propertyName ? element.propertyName : element.name;
10198

10299
// Get the symbol for the named binding element. Note that we cannot determine the
103100
// value declaration based on the type of the element as types are not necessarily
104101
// specific to a given secondary entry-point (e.g. exports with the type of "string")
105102
// would resolve to the module types provided by TypeScript itself.
106-
const symbol = getDeclarationSymbolOfNode(element.name, checker);
103+
const symbol = getDeclarationSymbolOfNode(elementName, checker);
107104

108105
// If the symbol can't be found, add failure saying the symbol
109106
// can't be found.

0 commit comments

Comments
 (0)