-
Notifications
You must be signed in to change notification settings - Fork 713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update typescript compiler options #1311
Conversation
…o update-typescript-compiler-options
…o update-typescript-compiler-options
package.json
Outdated
@@ -71,7 +71,7 @@ | |||
"ts-node": "9.1.1", | |||
"tsify": "^5.0.2", | |||
"tslint": "6.1.3", | |||
"typescript": "4.1.3", | |||
"typescript": "^4.2.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typescript creates false minor versions, we should ensure we are using the right version
"typescript": "^4.2.4", | |
"typescript": "4.2.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree
fix all failing test fix all failing build code
@tonyhallett @notaphplover I really want to get this merged eventually. Things at this moment should be correct for building but tests are failing and I really don't know what's happening there. Maybe some of you can have a second opinion on this. |
@PodaruDragos I am busy finishing a project at the moment. Might get the chance to take a look tomorrow or Thursday |
no worries, take your time |
@tonyhallett @notaphplover I've kept this branch up to date. There are 2 issues when running Can you also take a look at what's going on there maybe you have a clearer picture on how to solve those issues. |
Looking at it now |
Rectified with change to
|
I would also say that the pull by @leonardssh has introduced an issue in the typings.
When
Why should the second arguments be the same as the first ? This error can be seen in InversifyJS/test/inversify.test.ts Line 900 in 731aa75
Also note that because of unknown you have to provide the second generic to 'toFactory' ( or have unknown parameters ) |
After clearing the issue identified by ci build I then noticed in my error list that there were 50ish other errors with many that are not pertaining to 'update typescript compiler options' but are a result of the merge and the fix leaving the code in this present state. Please resolve resolver.test.ts and get Factory/FactoryCreator sorted. InversifyJS/src/interfaces/interfaces.ts Line 85 in 731aa75
Then I will help look at the decorator issues and any strange ci browser test issue that may present itself. |
@tonyhallett checked the branch right now, i don't have any issues but the one already mentioned |
I also formatted the code to have 2 spaces all over the place.. The 4 and 2 spaces randomly was really freaking me out. @tonyhallett hope that didn't cause you any discomfort. |
I will check to see what stupid mistake I made - apologies in advance |
@PodaruDragos |
yeah sorry , the one with cast to number that I modified to be as string. |
Ok 😉 |
@@ -58,7 +58,7 @@ The signature of a provider look as follows: | |||
|
|||
```ts | |||
interface Provider<T> extends NewableFunction { | |||
(...args: any[]): (((...args: any[]) => Promise<T>) | Promise<T>); | |||
(...args: unknown[]): (((...args: unknown[]) => Promise<T>) | Promise<T>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we replace the interface with the type that we are exporting ? Similarly with ProviderCreator.
src/interfaces/interfaces.ts
Outdated
export type Factory<T, U extends unknown[] = unknown[], V extends unknown[] = unknown[]> = (...args: U) => (((...args: V) => T) | T); | ||
export type SimpleFactory<T, U extends unknown[] = unknown[]> = (...args: U) => T; | ||
|
||
export type MultiFactory<T, U extends unknown[] = unknown[], V extends unknown[] = unknown[]> = (...args: U) => SimpleFactory<T,V> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PodaruDragos
Helper types added. We need a better name for MultiFactory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need some of the markdown files to be generated from actual tests so that required updates to markdown automatically occur when we change types. Will also prevent incorrect typing that I encountered when adding new functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about CompoundFactory
?
I also think MultiFactory
is fine
this should also be done |
You did two of them, I did the other. |
why are we not making this public ? |
oh sorry, I must have slipped that |
We want to control access through fluent syntax |
also we have a lot of tests where we do this
|
The binding tests are poor.
Why are we checking the serviceIdentifier ! Should be === on the binding. binding_when_on_syntax.test.ts and binding_in_when_on_syntax.test.ts Both of these just pass on, yet they do not test that they call with the correct parameter or return correctly ! Given that these types are never exposed there is no reason why we cannot make them public readonly Also given that these are all exposed with interfaces is there any reason why BindingToSyntax isn't the only binding syntax class ? |
I don't really understand what you are asking here. I have one more thing I want to propose. What if we do this Also do you think there is a way to properly cast Also regarding
Is this not more or less the same thing ? |
I don't really understand what you are asking here. I am saying why have separate binding syntax classes. Why not put all functionality in a single class that inherits all interfaces - BindingToSyntax given that it is the entry. The return values are interfaces and ensure correct call order. The single class just returns itself for the next call.
I assume that you mean replace injecting in setter with injecting the field.
Why are you doing this ? toConstructor should really be I think that we should do this
Going to have to come back to you
|
my apologies, didn't actually check the code ( I was curios just about the typings )
That would be better in every way, yes.
Yes seems to work, will have to double check tough.
looking forward |
remove more any's remove casts to any make metadata generic
@tonyhallett I have pushed another commit ( I honestly don't know how to get rid of the remaining I also resolved your feedback. |
Going to be busy for a few days. Will have a look soon. |
@PodaruDragos In case it adds any context, this looks to me like where the error in the test case may be originating from: It looks like Looking at the body of I'm inferring this because we use An interesting final piece of context, it seems about five months ago this change was made in the commit history which makes accessing Here is the associated PR: #1132 I am willing to bet the original code was meant to cover up an intermittent regression in accessing this property, and it was deemed unnecessary in the new PR and was thus removed. Maybe it was not time to move it yet and the root problem is still unsolved, or has returned? Here is a comment in the PR which discusses the change: https://github.com/inversify/InversifyJS/pull/1132/files#r623122372 cc: @tonyhallett |
I will look to see if the removal of the code was a bad idea. It seems like it was. |
Description
This PR aims to update Typescript version and add strict compiler options
Related Issue
#1222, #1271
Motivation and Context
We should try to use Typescript strict options in our project. This would help us to detect some typing issues such as #1222, which would have been detected.
How Has This Been Tested?
Types of changes
Checklist: