white-label icon indicating copy to clipboard operation
white-label copied to clipboard

why it is not strict ?

Open paolog22 opened this issue 4 years ago • 8 comments

can someone please explain why is it not strict thanks

paolog22 avatar Dec 01 '20 11:12 paolog22

@paolog22 what do you mean by ''why is it not strict thanks"

chouglesaud avatar Dec 01 '20 11:12 chouglesaud

are you talking about the TypeScript setting??

Meskat avatar Dec 01 '20 11:12 Meskat

@Meskat yes. when i try making it strict it produces a lot of errors .. @chouglesaud

paolog22 avatar Dec 01 '20 11:12 paolog22

The strict flag enables a wide range of type checking behavior that results in stronger guarantees of program correctness.

https://www.typescriptlang.org/tsconfig#strict

@paolog22

chouglesaud avatar Dec 01 '20 12:12 chouglesaud

@chouglesaud i know. but why the code is not ? sorry i am just trying to understand what is behind it .

paolog22 avatar Dec 01 '20 12:12 paolog22

but why the code is not

can you give an example so I can understand?

strict: true will enable all type checking rule like following

  • strictNullChecks
  • alwaysStrict
  • ...

for example if you set strictNullChecks to false typescript will just ignore the type checking for variable whether it is null or undefined. on the other hand, if you set to true then it will throw errors.

there is a simple example given in doc's checkout

chouglesaud avatar Dec 01 '20 12:12 chouglesaud

sorry i am just trying to understand what is behind it

everybody here is to learn and understand. I am not professional I just knew a little bit and you @paolog22 help me revising the topic.

chouglesaud avatar Dec 01 '20 12:12 chouglesaud

Hi there,

I had a typing problem on my project, here's and sample from the file AfterUserCreated :

    DomainEvents.register(this.onUserCreatedEvent.bind(this), UserCreatedEvent.name);
  }

Turn out that when enabling strict mode, the compiler complains with  Property 'user' is missing in type 'IDomainEvent' but required in type 'UserCreatedEvent'.

DadouBordeaux avatar Feb 04 '22 17:02 DadouBordeaux