Skip to content
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

types: avoid "interface can only extend object types with statically known members" error in TypeScript 4 #13871

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

vkarpov15
Copy link
Collaborator

@vkarpov15 vkarpov15 commented Sep 17, 2023

Fix #13775

Summary

In #13577, we removed FlatRecord from Schema definition because we didn't think it was necessary. And it doesn't look like FlatRecord is necessary in TypeScript 5, but for some reason is necessary in certain cases with TypeScript 4.

Will add FlatRecord back since it doesn't seem to break anything, and fixes #13577. But we will undo this change for 8.0, and we should make a note that we no longer support TypeScript 4.x or older.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typescript can be weird sometimes, especially when trying to support multiple versions

@vkarpov15 vkarpov15 added this to the 7.5.3 milestone Sep 18, 2023
@vkarpov15
Copy link
Collaborator Author

@hasezoey do you know of a way to set minimum TypeScript version without using peerDependencies?

@vkarpov15 vkarpov15 merged commit 8776c4b into master Sep 18, 2023
3 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-13775 branch September 18, 2023 18:35
@hasezoey
Copy link
Collaborator

do you know of a way to set minimum TypeScript version without using peerDependencies?

aside from keeping the minimal and installed typescript version in-sync, i dont know of a way. even this way will cause problems (because future typescript versions may make something invalid or change interfaces)

for typegoose i just set the minimal typescript version (the one mentioned in the readme / quick start guide) to be what is installed in the package.json (and use semver symbol ~) and only update the typescript version if required (like mongoose making a breaking type change (which happened quite often in the 5.11 to 6.something times)) or in major typegoose updates

@vkarpov15
Copy link
Collaborator Author

I guess the problem is that Mongoose doesn't require TypeScript, so there isn't a good way for us to indicate supported TypeScript version in package.json. We will just add that to the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression? Fields named id cause problems.
2 participants