Skip to content

Improve Docs: Mention about strictNullChecks in tsconfig.json #32

@khoinguyen

Description

@khoinguyen

🚀 Feature request

This is not really a Feature Request, I spent hours to figure out the issue, but I don't think it is a bug too.

Current Behavior

No where mentioned about the "strictNullChecks": true must be set in tsconfig.json in order to let spectacles-ts to work correctly.

When I try spectacles-ts on experimental site, it works well: https://codesandbox.io/s/spectacles-ts-experiments-krc1x9?file=/tsconfig.json

But I created my own simple project with npm init and copy an tsconfig.json from my existing project, with following index.ts:

import { pipe } from "fp-ts/lib/function";
import { get } from "spectacles-ts";

export type DbAddress = {
  address?: string;
  city?: string;
  state?: string;
  country?: string;
  lat?: number;
  lng?: number;
  postCode?: string;
};

export type DbUserAddress = {
  record: DbAddress;
  streetAddress: string;
};

const got = (uaddr: DbUserAddress) => pipe(uaddr, get("record"));
// IDE show: const got: (uaddr: DbUserAddress) => DbUserAddress

I use the same code in experimental site, it infer correctly: const got: (uaddr: DbUserAddress) => DbAddress

I tried to change the version of dependencies but not works
Then I diff my tsconfig, and experimental tsconfig, remove/change this and that config.

After all, when I add strictNullChecks: true, it works like a charm.

Desired Behavior

Short description in the Installation about this.

Suggested Solution

Short description in the Installation about this.

Who does this impact? Who is this for?

Who have configure the tsconfig.json without strictNullChecks or set to false

Describe alternatives you've considered

Additional context

Your environment

Software Version(s)
spectacles-ts 1.0.6
fp-ts 2.11.9
TypeScript ^4.6.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions