I have a simple typing error detected with cli flag --strict
$ ./node_modules/.bin/tsc --strict main.ts
main.ts:6:5 - error TS2322: Type 'null' is not assignable to type 'Person'.
6 return null;
~~~~~~~~~~~~
When I try to put the strict
flag inside tsconfig.json
it doesn't work:
$ cat tsconfig.json
{ "compilerOptions": { "strict": true } }
$ ./node_modules/.bin/tsc main.ts
$ # no typing errors found πππ
The actual source code is (probably) irrelevant, but for completeness reasons:
class Person {
constructor(private lastName: string){}
public getFriend(name: string): Person {
if (name == "Someone") { return new Person("Mr."); }
return null;
}
}