Skip to content

Commit 7fe5d9b

Browse files
authored
Update to ng19 and set standalone property for all components (#683)
* chore(ng version): update dev dependencies to ng 19 * chore(ng 19 migration): set `standalone` on every declarable For ng < 19, we need to keep `standalone: true`. For ng >= 19, we need `standalone: false` on components, directives, and pipes. * fix(build): spread expression is always truthy ```ts const mock: any = { ...template } || {}; ``` causes a compiler error. * chore(ng 19 migration): set `standalone` on every declarable * chore(schematics): commit schematic build output * docs(changelog): changelog entries for this PR * fix(formatting): format change caused by migration * fix(matchers): fix broken matchers (jest and jasmine) Matchers were broken by typescript upgrade: As of TypeScript 5.5, the compiler no longer emits triple-slash directives to the output files by default. However, there is a way to preserve these directives in specific cases: Use `preserve="true"` attribute in your triple-slash directive. * docs(changelog): add commit references * docs(changelog): revert unnecessary line * Revert "docs(changelog): changelog entries for this PR" This reverts commit 515f484.
1 parent 4719e89 commit 7fe5d9b

File tree

80 files changed

+2984
-2872
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2984
-2872
lines changed

package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@
3131
},
3232
"devDependencies": {
3333
"@angular-builders/jest": "^18.0.0",
34-
"@angular-devkit/build-angular": "^18.0.2",
35-
"@angular-devkit/schematics": "^18.0.2",
36-
"@angular-eslint/builder": "18.0.1",
37-
"@angular-eslint/eslint-plugin": "18.0.1",
38-
"@angular-eslint/eslint-plugin-template": "18.0.1",
39-
"@angular-eslint/schematics": "18.0.1",
40-
"@angular-eslint/template-parser": "18.0.1",
41-
"@angular/animations": "^18.0.1",
42-
"@angular/cdk": "^18.0.1",
43-
"@angular/cli": "^18.0.2",
44-
"@angular/common": "^18.0.1",
45-
"@angular/compiler": "^18.0.1",
46-
"@angular/compiler-cli": "^18.0.1",
47-
"@angular/core": "^18.0.1",
48-
"@angular/forms": "^18.0.1",
49-
"@angular/language-service": "^18.0.1",
50-
"@angular/platform-browser": "^18.0.1",
51-
"@angular/platform-browser-dynamic": "^18.0.1",
52-
"@angular/router": "18.0.1",
34+
"@angular-devkit/build-angular": "^19.0.1",
35+
"@angular-devkit/schematics": "^19.0.1",
36+
"@angular-eslint/builder": "18.4.2",
37+
"@angular-eslint/eslint-plugin": "18.4.2",
38+
"@angular-eslint/eslint-plugin-template": "18.4.2",
39+
"@angular-eslint/schematics": "18.4.2",
40+
"@angular-eslint/template-parser": "18.4.2",
41+
"@angular/animations": "^19.0.0",
42+
"@angular/cdk": "^19.0.0",
43+
"@angular/cli": "^19.0.1",
44+
"@angular/common": "^19.0.0",
45+
"@angular/compiler": "^19.0.0",
46+
"@angular/compiler-cli": "^19.0.0",
47+
"@angular/core": "^19.0.0",
48+
"@angular/forms": "^19.0.0",
49+
"@angular/language-service": "^19.0.0",
50+
"@angular/platform-browser": "^19.0.0",
51+
"@angular/platform-browser-dynamic": "^19.0.0",
52+
"@angular/router": "19.0.0",
5353
"@commitlint/cli": "17.3.0",
5454
"@commitlint/config-angular": "17.3.0",
5555
"@commitlint/config-conventional": "17.3.0",
@@ -76,14 +76,14 @@
7676
"karma-jasmine": "5.1.0",
7777
"karma-jasmine-html-reporter": "2.1.0",
7878
"lint-staged": "^13.1.0",
79-
"ng-packagr": "18.0.0",
79+
"ng-packagr": "19.0.1",
8080
"prettier": "3.2.5",
8181
"rxjs": "7.8.1",
8282
"standard-version": "^9.1.0",
8383
"ts-node": "10.1.0",
8484
"tslib": "^2.6.2",
85-
"typescript": "5.4.5",
86-
"zone.js": "0.14.3"
85+
"typescript": "5.6.3",
86+
"zone.js": "0.15.0"
8787
},
8888
"config": {
8989
"commitizen": {

projects/spectator/jest/src/lib/mock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type SpyObject<T> = BaseSpyObject<T> & {
1313
* @publicApi
1414
*/
1515
export function createSpyObject<T>(type: Type<T> | AbstractType<T>, template?: Partial<Record<keyof T, any>>): SpyObject<T> {
16-
const mock: any = { ...template } || {};
16+
const mock: any = { ...template };
1717

1818
installProtoMethods(mock, type.prototype, () => {
1919
const jestFn = jest.fn();

projects/spectator/jest/src/public_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// <reference types="jest" />
2-
/// <reference path="./lib/matchers-types.ts" />
2+
/// <reference path="./lib/matchers-types.ts" preserve="true" />
33
export * from './lib/dom-selectors';
44
export * from './lib/mock';
55
export * from './lib/spectator';

projects/spectator/jest/test/auto-focus.directive.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import { createDirectiveFactory, createHostFactory, SpectatorDirective, Spectato
33

44
import { AutoFocusDirective } from '../../test/auto-focus/auto-focus.directive';
55

6-
@Component({ selector: 'custom-host', template: '' })
6+
@Component({
7+
selector: 'custom-host',
8+
template: '',
9+
standalone: false,
10+
})
711
class CustomHostComponent {
812
public isFocused = false;
913
}

projects/spectator/jest/test/defer-block.spec.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ describe('DeferBlock', () => {
1010
<button data-test="button--isVisible" (click)="isVisible = !isVisible">Toggle</button>
1111
1212
@defer (when isVisible) {
13-
<div>empty defer block</div>
14-
} ,
13+
<div>empty defer block</div>
14+
}
1515
`,
1616
standalone: true,
1717
})
@@ -45,15 +45,16 @@ describe('DeferBlock', () => {
4545
selector: 'app-root',
4646
template: `
4747
@defer (on viewport) {
48-
<div>empty defer block</div>
48+
<div>empty defer block</div>
4949
} @placeholder {
50-
<div>this is the placeholder text</div>
50+
<div>this is the placeholder text</div>
5151
} @loading {
52-
<div>this is the loading text</div>
52+
<div>this is the loading text</div>
5353
} @error {
54-
<div>this is the error text</div>
54+
<div>this is the error text</div>
5555
}
5656
`,
57+
standalone: false,
5758
})
5859
class DummyComponent {}
5960

@@ -112,45 +113,44 @@ describe('DeferBlock', () => {
112113
selector: 'app-root',
113114
template: `
114115
@defer (on viewport) {
115-
<div>complete state #1</div>
116-
117-
<!-- nested defer block -->
118-
@defer {
119-
<div>complete state #1.1</div>
120-
121-
<!-- Deep nested defer block #1 -->
122-
@defer {
123-
<div>complete state #1.1.1</div>
124-
} @placeholder {
125-
<div>placeholder state #1.1.1</div>
126-
}
127-
<!-- /Deep nested defer block #1-->
128-
129-
<!-- Deep nested defer block #2 -->
130-
@defer {
131-
<div>complete state #1.1.2</div>
132-
} @placeholder {
133-
<div>placeholder state #1.1.2</div>
134-
}
135-
<!-- /Deep nested defer block #2-->
136-
137-
} @placeholder {
138-
<div>nested placeholder text</div>
139-
} @loading {
140-
<div>nested loading text</div>
141-
} @error {
142-
<div>nested error text</div>
143-
}
144-
<!-- /nested defer block -->
145-
116+
<div>complete state #1</div>
117+
118+
<!-- nested defer block -->
119+
@defer {
120+
<div>complete state #1.1</div>
121+
122+
<!-- Deep nested defer block #1 -->
123+
@defer {
124+
<div>complete state #1.1.1</div>
125+
} @placeholder {
126+
<div>placeholder state #1.1.1</div>
127+
}
128+
<!-- /Deep nested defer block #1-->
129+
130+
<!-- Deep nested defer block #2 -->
131+
@defer {
132+
<div>complete state #1.1.2</div>
133+
} @placeholder {
134+
<div>placeholder state #1.1.2</div>
135+
}
136+
<!-- /Deep nested defer block #2-->
137+
} @placeholder {
138+
<div>nested placeholder text</div>
139+
} @loading {
140+
<div>nested loading text</div>
141+
} @error {
142+
<div>nested error text</div>
143+
}
144+
<!-- /nested defer block -->
146145
} @placeholder {
147-
<div>placeholder state #1</div>
146+
<div>placeholder state #1</div>
148147
} @loading {
149-
<div>loading state #1</div>
148+
<div>loading state #1</div>
150149
} @error {
151-
<div>error state #1</div>
150+
<div>error state #1</div>
152151
}
153152
`,
153+
standalone: false,
154154
})
155155
class DummyComponent {}
156156

projects/spectator/jest/test/fg/fg.component.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
44

55
import { FgComponent } from '../../../test/fg/fg.component';
66

7-
@Component({ selector: 'app-custom-host', template: '' })
7+
@Component({
8+
selector: 'app-custom-host',
9+
template: '',
10+
standalone: false,
11+
})
812
class CustomHostComponent {
913
public group = new FormGroup({
1014
name: new FormControl('name'),

projects/spectator/jest/test/form-select/form-select.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Component, ChangeDetectionStrategy } from '@angular/core';
1010
</select>
1111
`,
1212
changeDetection: ChangeDetectionStrategy.OnPush,
13+
standalone: false,
1314
})
1415
export class FormSelectComponent {
1516
/**

projects/spectator/jest/test/matchers/matchers.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface Dummy {
2121
<custom-element style="visibility: hidden"></custom-element>
2222
<div id="computed-style"></div>
2323
`,
24+
standalone: false,
2425
})
2526
export class MatchersComponent {}
2627

projects/spectator/jest/test/override-component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class MockStandaloneComponentWithDependency {
3434
@Component({
3535
selector: `app-non-standalone`,
3636
template: `<div id="standalone">Non standalone</div>`,
37+
standalone: false,
3738
})
3839
export class MockNonStandaloneComponent {
3940
constructor() {}

projects/spectator/jest/test/override-directive.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export class StandaloneDirectiveWithDependency {
1515

1616
@Directive({
1717
selector: `app-non-standalone-directive`,
18+
standalone: false,
1819
})
1920
export class MockNonStandaloneDirective {
2021
constructor() {}

0 commit comments

Comments
 (0)