Skip to content

Commit

Permalink
feat(schematics): replace any type with unknown type (#3827)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
timdeschryver committed Apr 10, 2023
1 parent 8d0ed8e commit 0ea2933
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Expand Up @@ -6,10 +6,10 @@ export const <%= prefix %><%= classify(name) %>s = createAction(

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

<% if (api) { %>export const <%= prefix %><%= classify(name) %>sFailure = createAction(
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s Failure',
props<{ error: any }>()
props<{ error: unknown }>()
);<% } %>
4 changes: 2 additions & 2 deletions modules/schematics/src/action/index.spec.ts
Expand Up @@ -99,9 +99,9 @@ describe('Action Schematic', () => {

expect(fileContent).toMatch(/export const loadFoos = createAction\(/);
expect(fileContent).toMatch(/\[Foo\] Load Foos Success/);
expect(fileContent).toMatch(/props<{ data: any }>\(\)/);
expect(fileContent).toMatch(/props<{ data: unknown }>\(\)/);
expect(fileContent).toMatch(/\[Foo\] Load Foos Failure/);
expect(fileContent).toMatch(/props<{ error: any }>\(\)/);
expect(fileContent).toMatch(/props<{ error: unknown }>\(\)/);
});

it.each(['load', 'delete', 'update'])(
Expand Down
@@ -1,3 +1,3 @@
export interface <%= classify(name) %> {
id?: any;
id?: unknown;
}
2 changes: 1 addition & 1 deletion modules/schematics/src/data/index.spec.ts
Expand Up @@ -108,7 +108,7 @@ describe('Data Schematic', () => {
const fileContent = tree.readContent(`${projectPath}/src/app/foo.ts`);

expect(fileContent).toMatch(/export interface Foo {/);
expect(fileContent).toMatch(/id\?: any;/);
expect(fileContent).toMatch(/id\?: unknown;/);
});

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

0 comments on commit 0ea2933

Please sign in to comment.