Skip to content

Commit c167d1d

Browse files
committed
chore: 🚨 Add Typescript strict mode
1 parent b3aad75 commit c167d1d

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

projects/ngx-mat-datefns-date-adapter/src/lib/ngx-mat-datefns-date-adapter.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { LOCALE_ID } from '@angular/core';
22
import { inject, TestBed, waitForAsync } from '@angular/core/testing';
33
import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
4-
import { parse, parseJSON } from 'date-fns';
4+
import { parseJSON } from 'date-fns';
55
import { da, ja } from 'date-fns/esm/locale';
66
import {
77
NgxDateFnsDateAdapter,
@@ -31,7 +31,7 @@ describe('NgxDateFnsDateAdapter', () => {
3131
expect(adapter.isDateInstance(d)).not.toBeNull(
3232
`Expected ${d} to be a date instance`
3333
);
34-
expect(adapter.isValid(d)).toBe(
34+
expect(adapter.isValid(d as Date)).toBe(
3535
valid,
3636
`Expected ${d} to be ${valid ? 'valid' : 'invalid'},` +
3737
` but was ${valid ? 'invalid' : 'valid'}`
@@ -321,6 +321,7 @@ describe('NgxDateFnsDateAdapter', () => {
321321
});
322322

323323
it('should throw when attempting to load null locale', () => {
324+
// @ts-expect-error - Argument of type 'Date | null' is not assignable to parameter of type 'Date'.
324325
expect(() => adapter.setLocale(null)).toThrowError(
325326
/setLocale should be called with the string locale code or date-fns Locale object/
326327
);

projects/ngx-mat-datefns-date-adapter/src/lib/ngx-mat-datefns-date-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const UTC_TIMEZONE = 'UTC';
5454

5555
@Injectable()
5656
export class NgxDateFnsDateAdapter extends DateAdapter<Date> {
57-
private _dateFnsLocale: Locale;
57+
private _dateFnsLocale!: Locale;
5858
private getLocale = (localeCodeOrLocale: string | Locale): Locale => {
5959
if (localeCodeOrLocale && (localeCodeOrLocale as Locale).code) {
6060
return localeCodeOrLocale as Locale;

tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
"experimentalDecorators": true,
1010
"module": "es2020",
1111
"moduleResolution": "node",
12+
"noErrorTruncation": true,
13+
"pretty": true,
14+
"resolveJsonModule": true,
15+
"skipDefaultLibCheck": true,
16+
"strict": true,
17+
"noFallthroughCasesInSwitch": true,
18+
"noImplicitReturns": true,
19+
"noUnusedLocals": true,
20+
"noUnusedParameters": true,
1221
"importHelpers": true,
1322
"target": "es2015",
1423
"lib": ["es2018", "dom"],

0 commit comments

Comments
 (0)