Still hitting `strictNullChekcs must be true in tsconfig`
See original GitHub issueI 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:
- strict mode is enabled in tsconfig.json (or at least strictNullChecks)
- TS version is >= 4.2.3
- you are importing the latest Ajv version (sometimes calling
npm install ajv
may install the previous version because some other dependency uses it - usenpm install ajv@8
and try clean install:rm -rf node_modules && npm I
- 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. - 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:
- Created 2 years ago
- Comments:10 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same problem and the typescript version upgrade fixed it. thanks.
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?