Skip to content

Commit 0ea2933

Browse files
feat(schematics): replace any type with unknown type (#3827)
BREAKING CHANGES: NgRx Schematics do not use `any` types to define actions, these are replaced with the `unknown` type. BEFORE: Schematics used the `any` type to declare action payload type. AFTER: Schematics use the `unknown` type to declare action payload type.
1 parent 8d0ed8e commit 0ea2933

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

modules/schematics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export const <%= prefix %><%= classify(name) %>s = createAction(
66

77
<% if (api) { %>export const <%= prefix %><%= classify(name) %>sSuccess = createAction(
88
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s Success',
9-
props<{ data: any }>()
9+
props<{ data: unknown }>()
1010
);<% } %>
1111

1212
<% if (api) { %>export const <%= prefix %><%= classify(name) %>sFailure = createAction(
1313
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s Failure',
14-
props<{ error: any }>()
14+
props<{ error: unknown }>()
1515
);<% } %>

modules/schematics/src/action/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ describe('Action Schematic', () => {
9999

100100
expect(fileContent).toMatch(/export const loadFoos = createAction\(/);
101101
expect(fileContent).toMatch(/\[Foo\] Load Foos Success/);
102-
expect(fileContent).toMatch(/props<{ data: any }>\(\)/);
102+
expect(fileContent).toMatch(/props<{ data: unknown }>\(\)/);
103103
expect(fileContent).toMatch(/\[Foo\] Load Foos Failure/);
104-
expect(fileContent).toMatch(/props<{ error: any }>\(\)/);
104+
expect(fileContent).toMatch(/props<{ error: unknown }>\(\)/);
105105
});
106106

107107
it.each(['load', 'delete', 'update'])(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export interface <%= classify(name) %> {
2-
id?: any;
2+
id?: unknown;
33
}

modules/schematics/src/data/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('Data Schematic', () => {
108108
const fileContent = tree.readContent(`${projectPath}/src/app/foo.ts`);
109109

110110
expect(fileContent).toMatch(/export interface Foo {/);
111-
expect(fileContent).toMatch(/id\?: any;/);
111+
expect(fileContent).toMatch(/id\?: unknown;/);
112112
});
113113

114114
it('should create spec class with right imports', async () => {

0 commit comments

Comments
 (0)