Enable "strictNullChecks" option for TS definitions
See original GitHub issueA clean version of joint 2.1.0, obtained by running npm i jointjs
, results in the following TypeScript errors:
(2062,38): Type 'undefined' does not satisfy the constraint 'Model'.
(2092,38): Type 'undefined' does not satisfy the constraint 'Model'.
Replacing mvc.View<undefined>
by mvc.View<Backbone.Model>
seems to fix it, but I can imagine undefined
being a more concrete implementation of Backbone.Model
.
How should I fix this?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
strictNullChecks - TSConfig Option
When strictNullChecks is false , null and undefined are effectively ignored by the language. This can lead to unexpected errors at runtime.
Read more >StrictNullChecks in TypeScript - Best Practice
The 'strictNullChecks' TypeScript compiler option allow you to catch null pointers at compile time, providing you with extra safety for your application.
Read more >Typescript strictNullChecks with limited scope
It's a global setting that changes how all interpretations of types behave. There's not even a coherent definition of what it would mean...
Read more >TypeScript "strictNullChecks" - a migration guide
Enabling this option effectively narrows the set of possible types for every variable, which means that the editor can infer more about the ......
Read more >Writing safer code with TypeScript strict null checks & type ...
Uncaught ReferenceError: foo is not defined Uncaught TypeError: ... It can be enabled by adding the –strictNullChecks flag as an option to ...
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
@swenmeeuwes In
tsconfig.json
, you can set"skipLibCheck": true
to let Typescript skip checking the libraries in strict mode, and you can add back"strictNullChecks": true
, or maybe even"strict": true
.One suggestion to JointJS Typescript declarations regarding strictNullChecks in Typescript. Some of the type declarations are not strict. For example:
getCell(id: string | number | Cell): Cell;
But when the id doesn’t exist, this function returns undefined, so it’s better to writegetCell(id: string | number | Cell): Cell | undefined;
Hi vtalas,
First I stripped down my project to only use TypeScript en JointJs. After still getting the error I compared my project with the demo project and spotted a difference in tsconfig.json.
This line was the villain:
"strictNullChecks": true,
Setting it to ‘false’ fixed the issue. Although I’d rather leave this setting on for code safety reasons.
Is there going to be support for this in the future? To reproduce you can just use the ts-demo and add
"strictNullChecks": true
to the tsconfig.json.