-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Generics and TypeScript limited to 4.6.* #17
Conversation
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.
Thanks for your PR! I've looked through it and added a few comments :)
@@ -76,7 +76,7 @@ | |||
"crosspath": "^1.0.0", | |||
"ts-node": "^10.8.0", | |||
"npm-check-updates": "^13.0.3", | |||
"typescript": "^4.6.4", | |||
"typescript": "~4.6.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.
Note that this is just the development dependency of TypeScript, and won't restrict library consumers from installing and using TypeScript 4.7. If your intention is to restrict the consumer facing version of TypeScript, it will need to be addressed below it in the package.json file under peer dependencies. However, I would prefer not to do that, and instead look into what the root cause of this apparent regression may be.
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.
I agree - my intent wasn't to fix the TS 4.7 issue, but to enable the tests to pass (and bring your attention to the 4.7 issue).
Glad to back this out - is that what you would prefer?
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.
Yes, I would prefer that we look into this TS 4.7 issue you mention here, maybe in a separate issue
@@ -44,7 +44,7 @@ export function visitCallExpression( | |||
factory.createPropertyAssignment( | |||
"identifier", | |||
factory.createStringLiteral( | |||
node.typeArguments[0].getFullText().trim() | |||
node.typeArguments[0].getFirstToken()!.getFullText().trim() |
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.
That NonNullAssertion there feels a bit unsafe. I would prefer that we handle it a bit more gracefully, ideally by taking the full text of the first token if it present, and falling back to taking the full text of the first type argument otherwise.
Something like:
// Move it up in a constant
const [firstTypeArgument] = node.typeArguments;
return factory.updateCallExpression(
node,
node.expression,
node.typeArguments,
[
factory.createObjectLiteralExpression([
factory.createPropertyAssignment(
"identifier",
factory.createStringLiteral(
(firstTypeArgument.getFirstToken()?.getFullText() ?? firstTypeArgument.getFullText()).trim()
)
),
]),
]
);
### Bug fixes | ||
|
||
* Fixed issue with generics to allow `container.register<IService<Generic>, Service<Generic>>()`. | ||
* Restricted `typescript` to minor version updates from `~4.6.4` as version 4.7 is currently incompatible. |
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.
The changelog is actually auto-generated based on the commit log whenever a new version is released. So, unfortunately these two lines would actually be lost. To achieve the same result, you can write commit messages along these lines :)
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.
Sweet. I'll back this out.
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.
Awesome!
Sorry about the closures ... turns out git was very unhappy with my branch name ( |
This pull addresses two things:
package.json
to~4.6.4
, as recently released 4.7 does not currently work. Obviously back out this change when 4.7 is supported.Passes all tests, and change #1 has been in my rig for a couple months now.
I did bump the version number and add a change log. Sorry if this was inappropriate - some smaller projects like it when I assist with the details, others find it a major faux pas! In the change log I refer to the labeled version, which of course does not exist yet. Glad to fix the repo to remove that if you prefer.