Skip to content

Commit fbcb7ee

Browse files
committed
Align TypeScript configuration with the new Angular CLI project
With this we enable the remaining strict options and fix any new errors. The change ensures that the generated declaration files include `undefined`/`null` types, so that the library can be used by the projects which have `strictNullChecks` enabled. Fixes #469
1 parent eb9807e commit fbcb7ee

21 files changed

+106
-65
lines changed

.github/workflows/check.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
- run: yarn test:schematics
2323
- run: yarn build
2424
- run: yarn build:schematics
25+
- run: yarn build:demo
2526
- run: yarn test:demo
2627
- run: yarn add -D chromedriver@~`google-chrome --version | awk '{print $3}' | awk -F. '{print $1}'`
2728
- run: yarn test:integration
@@ -46,6 +47,7 @@ jobs:
4647
- run: yarn test:schematics
4748
- run: yarn build
4849
- run: yarn build:schematics
50+
- run: yarn build:demo
4951
- run: yarn test:demo
5052
- run: yarn add -D chromedriver@~`google-chrome --version | awk '{print $3}' | awk -F. '{print $1}'`
5153
- run: yarn test:integration

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"start": "ng serve demo",
1414
"start:ssr": "ng serve demo --configuration development-ssr",
1515
"build": "ng build angular-fontawesome",
16+
"build:demo": "ng build demo",
1617
"build:watch": "ng build angular-fontawesome -c development --watch",
1718
"build:schematics": "tsc -p projects/schematics/tsconfig.json && ts-node -O '{\"module\":\"commonjs\"}' tasks/build-schematics.ts",
1819
"format": "prettier --write --ignore-path .gitignore '**/*.{js,ts,json,html}'",

projects/demo/.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"project": [
99
"projects/demo/tsconfig.app.json",
1010
"projects/demo/tsconfig.spec.json",
11+
"projects/demo/tsconfig.server.json",
1112
"projects/demo/e2e/tsconfig.json"
1213
],
1314
"createDefaultProgram": true

projects/demo/e2e/src/app.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { browser, ElementFinder, logging } from 'protractor';
1+
import { browser, logging } from 'protractor';
22
import { appPage } from './app.page';
33

44
describe('Angular FontAwesome demo', () => {
@@ -14,7 +14,7 @@ describe('Angular FontAwesome demo', () => {
1414
});
1515

1616
it('should only add styles once', async () => {
17-
const styles: string[] = await appPage.styles.map((style: ElementFinder) => style.getAttribute('innerHTML'));
17+
const styles: string[] = await appPage.styles.map((style) => style!.getAttribute('innerHTML'));
1818
const fontAwesomeStyles = styles.filter((style) => style.includes('.svg-inline--fa'));
1919

2020
expect(fontAwesomeStyles.length).toBe(1);

projects/demo/e2e/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"module": "commonjs",
66
"target": "es2018",
77
"types": ["jasmine", "jasminewd2", "node"]
8-
}
8+
},
9+
"include": ["src/**/*.ts"]
910
}

projects/demo/src/app/app.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ <h3>Layers</h3>
166166
<fa-icon [icon]="faBell"></fa-icon>
167167
<fa-layers-counter
168168
[position]="selectedPosition"
169-
[content]="notificationsCounter | number"
169+
[content]="$any(notificationsCounter | number)"
170170
title="Unread Messages"
171171
></fa-layers-counter>
172172
</fa-layers>
@@ -179,4 +179,4 @@ <h3>Fallback icon</h3>
179179
Icon uses a fallback icon when the main icon parameter is not specified. Useful for when the icon is loaded
180180
asynchronously. If no fallback icon is specified, the icon will not appear. (Not shown in this example.)
181181
</p>
182-
<fa-icon [icon]="undefined"></fa-icon>
182+
<fa-icon [icon]="undefined!"></fa-icon>

projects/demo/src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class AppComponent {
5454
isAnimated = true;
5555
magicLevel = 0;
5656

57-
selectedPosition: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
57+
selectedPosition: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' = 'bottom-right';
5858

5959
constructor() {
6060
// Notice that we're adding two different icon objects to the library.

projects/demo/tsconfig.app.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../../out-tsc/app",
5-
"types": ["node"]
5+
"types": []
66
},
7-
"files": ["src/main.ts", "src/main.server.ts", "server.ts"],
8-
"include": ["src/**/*.d.ts"]
7+
"include": ["src/**/*.ts"],
8+
"exclude": ["src/**/*.spec.ts"]
99
}

projects/demo/tsconfig.server.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../out-tsc/app",
5+
"types": ["node"]
6+
},
7+
"files": ["server.ts"]
8+
}

projects/demo/tsconfig.spec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../../out-tsc/spec",
5-
"types": ["node", "jasmine"]
5+
"types": ["jasmine"]
66
},
7-
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
7+
"include": ["src/**/*.ts"]
88
}

0 commit comments

Comments
 (0)