Skip to content

Commit ca6db8f

Browse files
authored
Update Angular 10 (#247)
1 parent 3cf9512 commit ca6db8f

33 files changed

+4061
-3541
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ indent_size = 2
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11+
[*.ts]
12+
quote_type = single
13+
1114
[*.md]
1215
max_line_length = off
1316
trim_trailing_whitespace = false

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
{
2+
"auto-close-tag.activationOnLanguage": [
3+
"html"
4+
],
5+
26
"editor.codeActionsOnSave": {
37
"source.fixAll": true
48
},
59

10+
"files.associations": {
11+
"*.json": "jsonc",
12+
"package.json": "json"
13+
},
14+
615
"files.trimTrailingWhitespace": true,
716

817
"[markdown]": {

angular.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"projectType": "application",
1010
"prefix": "app",
1111
"schematics": {
12+
"@schematics/angular:application": {
13+
"strict": true
14+
},
1215
"@schematics/angular:component": {
1316
"styleext": "scss"
1417
}
@@ -56,6 +59,10 @@
5659
"node_modules/prismjs/components/prism-typescript.min.js",
5760
"node_modules/emoji-toolkit/lib/js/joypixels.js",
5861
"node_modules/katex/dist/katex.min.js"
62+
],
63+
"allowedCommonJsDependencies": [
64+
"gumshoejs",
65+
"hammerjs"
5966
]
6067
},
6168
"configurations": {
@@ -77,13 +84,13 @@
7784
"budgets": [
7885
{
7986
"type": "initial",
80-
"maximumWarning": "2mb",
81-
"maximumError": "5mb"
87+
"maximumWarning": "500kb",
88+
"maximumError": "1mb"
8289
},
8390
{
8491
"type": "anyComponentStyle",
85-
"maximumWarning": "6kb",
86-
"maximumError": "10kb"
92+
"maximumWarning": "2kb",
93+
"maximumError": "4kb"
8794
}
8895
]
8996
}

demo/browserslist

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
# For additional information regarding the format and rule options, please see:
33
# https://github.com/browserslist/browserslist#queries
44

5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
58
# You can see what browsers were selected by your queries by running:
69
# npx browserslist
710

8-
> 0.5%
9-
last 2 versions
11+
last 1 Chrome version
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major version
15+
last 2 iOS major versions
1016
Firefox ESR
1117
not dead
1218
IE 11

demo/src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ <h1>ngx-markdown</h1>
2020
[routerLink]="route.path"
2121
routerLinkActive>
2222
<img src="assets/icon-{{route.path}}.svg">
23-
<span>{{ route.data.label }}</span>
23+
<span>{{ route.data?.label }}</span>
2424
</a>
2525
</nav>
2626

demo/src/app/app.component.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export class AppComponent implements OnInit {
2323
tabHeader: ElementRef;
2424

2525
@HostListener('document:click', ['$event'])
26-
onDocumentClick(event: Event) {
26+
onDocumentClick(event: Event): void {
2727
this.anchorService.interceptClick(event);
2828
}
2929

3030
@HostListener('window:scroll')
31-
onWindowScroll() {
31+
onWindowScroll(): void {
3232
const tabHeader = this.tabHeader.nativeElement as HTMLElement;
3333
const tabHeaderOffset = Math.ceil(tabHeader.offsetTop);
3434
const windowOffset = Math.ceil(window.pageYOffset);
@@ -47,18 +47,18 @@ export class AppComponent implements OnInit {
4747
private router: Router,
4848
) { }
4949

50-
ngOnInit() {
50+
ngOnInit(): void {
5151
this.routes = this.router.config.filter(route => route.data && route.data.label);
5252
this.setTheme(localStorage.getItem('theme') || 'light');
5353
}
5454

55-
handleFragment() {
55+
handleFragment(): void {
5656
this.anchorService.scrollToAnchor();
5757
}
5858

59-
setTheme(theme: string) {
59+
setTheme(theme: string): void {
6060
this.theme = theme;
61-
const bodyClassList = this.document.querySelector('body').classList;
61+
const bodyClassList = this.document.querySelector('body')!.classList;
6262
const removeClassList = /\w*-theme\b/.exec(bodyClassList.value);
6363
if (removeClassList) {
6464
bodyClassList.remove(...removeClassList);
@@ -67,13 +67,13 @@ export class AppComponent implements OnInit {
6767
localStorage.setItem('theme', this.theme);
6868
}
6969

70-
getRouteAnimation(outlet: RouterOutlet) {
70+
getRouteAnimation(outlet: RouterOutlet): string {
7171
return outlet
7272
&& outlet.activatedRouteData
7373
&& outlet.activatedRouteData.label;
7474
}
7575

76-
toggleTheme() {
76+
toggleTheme(): void {
7777
this.setTheme(this.theme === 'light' ? 'dark' : 'light');
7878
}
7979
}

demo/src/app/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function markedOptionsFactory(anchorService: AnchorService): MarkedOption
1717
const renderer = new MarkedRenderer();
1818

1919
// fix `href` for absolute link with fragments so that _copy-paste_ urls are correct
20-
renderer.link = (href, title, text) => {
20+
renderer.link = (href: string, title: string, text: string) => {
2121
return MarkedRenderer.prototype.link.call(renderer, anchorService.normalizeExternalUrl(href), title, text);
2222
};
2323

demo/src/app/bindings/bindings.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ export class MarkdownDemoComponent {
4848
private elementRef: ElementRef<HTMLElement>,
4949
) { }
5050

51-
ngOnInit() {
51+
ngOnInit(): void {
5252
this.setHeadings();
5353
}
5454

55-
private setHeadings() {
56-
const headings = [];
55+
private setHeadings(): void {
56+
const headings: Element[] = [];
5757
this.elementRef.nativeElement
5858
.querySelectorAll('h2')
5959
.forEach(x => headings.push(x));

demo/src/app/cheat-sheet/cheat-sheet.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export class CheatSheetComponent implements OnInit {
2525
private elementRef: ElementRef<HTMLElement>,
2626
) { }
2727

28-
ngOnInit() {
28+
ngOnInit(): void {
2929
this.setHeadings();
3030
}
3131

32-
private setHeadings() {
33-
const headings = [];
32+
private setHeadings(): void {
33+
const headings: Element[] = [];
3434
this.elementRef.nativeElement
3535
.querySelectorAll('h2')
3636
.forEach(x => headings.push(x));

demo/src/app/get-started/get-started.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ export class GetStartedComponent {
1414
private elementRef: ElementRef<HTMLElement>,
1515
) { }
1616

17-
onLoad() {
17+
onLoad(): void {
1818
this.stripContent();
1919
this.setHeadings();
2020
}
2121

22-
private setHeadings() {
23-
const headings = [];
22+
private setHeadings(): void {
23+
const headings: Element[] = [];
2424
this.elementRef.nativeElement
2525
.querySelectorAll('h2')
2626
.forEach(x => headings.push(x));
2727
this.headings = headings;
2828
}
2929

30-
private stripContent() {
30+
private stripContent(): void {
3131
this.elementRef.nativeElement
32-
.querySelector('markdown')
32+
.querySelector('markdown')!
3333
.querySelectorAll('markdown > p:nth-child(-n + 2), #ngx-markdown, #table-of-contents + ul, #table-of-contents')
3434
.forEach(x => x.remove());
3535
}

demo/src/app/plugins/plugins.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ $f(x) = \\int_{-\\infty}^\\infty \\hat f(\\xi) e^{2 \\pi i \\xi x} d\\xi$`;
2525
private elementRef: ElementRef<HTMLElement>,
2626
) { }
2727

28-
ngOnInit() {
28+
ngOnInit(): void {
2929
this.setHeadings();
3030
}
3131

32-
private setHeadings() {
33-
const headings = [];
32+
private setHeadings(): void {
33+
const headings: Element[] = [];
3434
this.elementRef.nativeElement
3535
.querySelectorAll('h2')
3636
.forEach(x => headings.push(x));

demo/src/app/shared/anchor/anchor.service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ export class AnchorService {
2929
* when `href` is an internal URL not handled by `routerLink` directive.
3030
* @param event The event to evaluated for link click.
3131
*/
32-
interceptClick(event: Event): boolean {
32+
interceptClick(event: Event): void {
3333
const element = event.target;
3434
if (!(element instanceof HTMLAnchorElement)) {
3535
return;
3636
}
37-
const href = element.getAttribute('href');
37+
const href = element.getAttribute('href') || '';
3838
if (this.isExternalUrl(href) || this.isRouterLink(element)) {
3939
return;
4040
}
@@ -47,7 +47,7 @@ export class AnchorService {
4747
* @param url Destination path to navigate to.
4848
* @param replaceUrl If `true`, replaces current state in browser history.
4949
*/
50-
navigate(url: string, replaceUrl = false) {
50+
navigate(url: string, replaceUrl = false): void {
5151
const urlTree = this.getUrlTree(url);
5252
this.router.navigated = false;
5353
this.router.navigateByUrl(urlTree, { replaceUrl });
@@ -70,7 +70,7 @@ export class AnchorService {
7070
/**
7171
* Scroll view to the anchor corresponding to current route fragment.
7272
*/
73-
scrollToAnchor() {
73+
scrollToAnchor(): void {
7474
const url = this.router.parseUrl(this.router.url);
7575
if (url.fragment) {
7676
this.navigate(this.router.url, true);
@@ -79,7 +79,7 @@ export class AnchorService {
7979

8080
private getUrlTree(url: string): UrlTree {
8181
const urlPath = this.stripFragment(url) || this.stripFragment(this.router.url);
82-
const urlFragment = this.router.parseUrl(url).fragment;
82+
const urlFragment = this.router.parseUrl(url).fragment || undefined;
8383
return this.router.createUrlTree([urlPath], { relativeTo: this.route, fragment: urlFragment });
8484
}
8585

@@ -92,6 +92,6 @@ export class AnchorService {
9292
}
9393

9494
private stripFragment(url: string): string {
95-
return /[^#]*/.exec(url)[0];
95+
return /[^#]*/.exec(url)![0];
9696
}
9797
}

demo/src/app/shared/scrollspy-nav-layout/scrollspy-nav-layout.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ export class ScrollspyNavLayoutComponent {
1717
showScrollUpButton = false;
1818

1919
@HostListener('window:scroll')
20-
onWindowScroll() {
20+
onWindowScroll(): void {
2121
this.showScrollUpButton = Math.ceil(window.pageYOffset) > 64;
2222
}
2323

24-
onScrollUp() {
24+
onScrollUp(): void {
2525
window.scrollTo(0, 0);
2626
location.hash = '';
2727
}

demo/src/app/shared/scrollspy-nav/scrollspy-nav.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ export class ScrollspyNavComponent implements OnChanges, OnDestroy {
2020
private zone: NgZone,
2121
) { }
2222

23-
ngOnChanges(changes: SimpleChanges) {
23+
ngOnChanges(changes: SimpleChanges): void {
2424
if (changes.headings && changes.headings.currentValue) {
2525
this.setScrollSpy();
2626
}
2727
}
2828

29-
ngOnDestroy() {
29+
ngOnDestroy(): void {
3030
this.destroyScrollSpy();
3131
}
3232

33-
destroyScrollSpy() {
33+
destroyScrollSpy(): void {
3434
if (this.scrollSpy) {
3535
this.scrollSpy.destroy();
3636
}
3737
}
3838

39-
setScrollSpy() {
39+
setScrollSpy(): void {
4040
if (this.scrollSpy) {
4141
this.scrollSpy.setup();
4242
return;

demo/src/app/syntax-highlight/syntax-highlight.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export class SyntaxHighlightComponent implements OnInit {
1616
private elementRef: ElementRef<HTMLElement>,
1717
) { }
1818

19-
ngOnInit() {
19+
ngOnInit(): void {
2020
this.setHeadings();
2121
}
2222

23-
private setHeadings() {
24-
const headings = [];
23+
private setHeadings(): void {
24+
const headings: Element[] = [];
2525
this.elementRef.nativeElement
2626
.querySelectorAll('h2')
2727
.forEach(x => headings.push(x));

demo/src/global.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
declare module 'gumshoejs' {
2+
namespace Gumshoe {}
3+
class Gumshoe {
4+
constructor(selector: string, options: any);
5+
destroy(): void;
6+
setup(): void;
7+
}
8+
export = Gumshoe;
9+
}

demo/src/polyfills.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import 'web-animations-js'; // Run `npm install --save web-animations-js`.
3535
* will put import in the top of bundle, so user need to create a separate file
3636
* in this directory (for example: zone-flags.ts), and put the following flags
3737
* into that file, and then add the following code before importing zone.js.
38-
* import './zone-flags.ts';
38+
* import './zone-flags';
3939
*
4040
* The flags allowed in zone-flags.ts are listed here.
4141
*

demo/src/scss/material-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
code:not([class*="language-"]) {
3737
background: mat-color($foreground, secondary-text, 0.07);
3838
border-radius: 3px;
39-
font-size: 1em;
39+
font-size: 0.94em;
4040
padding: 0px 6px 2px;
4141
}
4242

demo/tsconfig.app.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2-
"extends": "../tsconfig.json",
2+
"extends": "../tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "../out-tsc/app",
5+
"strictPropertyInitialization": false,
56
"types": [
67
"node"
7-
]
8+
],
89
},
910
"files": [
1011
"src/main.ts",

0 commit comments

Comments
 (0)