question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Still hitting `strictNullChekcs must be true in tsconfig`

See original GitHub issue

I am still hitting the error from https://github.com/ajv-validator/ajv/issues/1650 and can’t pass over it.

Environment:

~ npm list | grep ajv
├── ajv@8.4.0
~ npm list | grep tsc
├── tsc@2.0.4

~ cat tsconfig.json | grep strictNullCheck
    "strictNullChecks": true,

The ouput of npm run build:

 ~/g/a/2/c/awsiam-configrepo-aws-ppb   *…  cdk  npm run build

> awsiam-aws-app@0.1.0 build
> tsc

node_modules/ajv/dist/types/json-schema.d.ts:1:92 - error TS1005: '?' expected.

1 declare type StrictNullChecksWrapper<Name extends string, Type> = undefined extends null ? `strictNullChecks must be true in tsconfig to use ${Name}` : Type;
                                                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/ajv/dist/types/json-schema.d.ts:1:151 - error TS1005: ';' expected.

1 declare type StrictNullChecksWrapper<Name extends string, Type> = undefined extends null ? `strictNullChecks must be true in tsconfig to use ${Name}` : Type;
                                                                                                                                                        ~


Found 2 errors.

I am going to close comments on this issue - it is not really defined what this issue was, and the issue may be that you simply have an incorrect schema or that JSONSchemaType has limitations and cannot be used in your case.

Please submit a new issue with a full code sample from a clear repository once you’ve checked the following:

  1. strict mode is enabled in tsconfig.json (or at least strictNullChecks)
  2. TS version is >= 4.2.3
  3. you are importing the latest Ajv version (sometimes calling npm install ajv may install the previous version because some other dependency uses it - use npm install ajv@8 and try clean install: rm -rf node_modules && npm I
  4. check that your schema is indeed valid - that required properties are listed in “required”, that optional properties have nullable: true, that “type” is set in all schemas - in many cases what was reported as JSONSchemaType issue was a user error where their schema was incorrect - it correctly shown compilation error.
  5. Check other open issues related to JSONSchemaType - there are some known limitations.

A simple temporary workaround to use Ajv without using JSONSchemaType - it is optional.

_Originally posted by @epoberezkin in https://github.com/ajv-validator/ajv/issues/1650#issuecomment-871369910_

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
ianxmcommented, Jul 13, 2022

I had the same problem and the typescript version upgrade fixed it. thanks.

1reaction
epoberezkincommented, Mar 23, 2022

Ah - and looking at your npm ls - the minimum typescript version these type utilities can work with is 4.2.3 and you seem to have 2.0.4?

Read more comments on GitHub >

github_iconTop Results From Across the Web

strictNullChecks - TSConfig Option - TypeScript
When strictNullChecks is true , null and undefined have their own distinct types and you'll get a type error if you try to...
Read more >
Why I am not getting warnings about StrictNullChecks in ...
Turn on "strict": true, in the tsconfig.json to enable this warning. Or if you don't want all the strict options you in need:...
Read more >
StrictNullChecks in TypeScript - Best Practice - tsmean
The 'strictNullChecks' TypeScript compiler option allow you to catch null pointers at compile time, providing you with extra safety for your application.
Read more >
Strict null checking the Visual Studio Code codebase
In this post, I'd like to share a major engineering effort that the VS Code team recently completed: enabling TypeScript's strict null ...
Read more >
Chapter 1. Getting to Know TypeScript
TypeScript will still parse your code and emit JavaScript. (This is another key ... You should certainly set noImplicitAny before you set strictNullChecks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found