How do I set up my tsconfig with "strictNullChecks": true?

I added the “strictNullChecks”: true flag to my tsconfig:

  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "strictNullChecks": true,
    "lib": [
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  "include": [
  "exclude": [
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false

Then I tried doing something in my ts file that should cause a compiler error, but there are no errors:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

function trimAndLower(text) {
  return text.trim().toLowerCase();
let text;
text = 'some string';
text = null;

  selector: 'page-home',
  templateUrl: 'home.html'
export class HomePage {

  constructor(public navCtrl: NavController) {


I managed to get strictNullChecks working in a simple project with just one ts file and a tsconfig, but tried moving over to try in the Ionic framework and can’t get it to work. It’s just the basic started app (ionic start myApp blank), and I added nothing else other than what I’m showing above.

1 Like

Just realized that I’m an idiot and I didn’t actually declare the type.

1 Like