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

Error with multiple templates as indexes #50220

Closed
jer-sen opened this issue Aug 8, 2022 · 5 comments
Closed

Error with multiple templates as indexes #50220

jer-sen opened this issue Aug 8, 2022 · 5 comments
Labels
Duplicate An existing issue was already created

Comments

@jer-sen
Copy link

jer-sen commented Aug 8, 2022

Bug Report

I'm have some issues with the last version of MongoDB node.js driver. There is now a type check on the queries filter/update (which is really great!) but some complex types require to bypass it..
Cf mongodb/node-mongodb-native#3328

🔎 Search Terms

record object template index indexes key

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about common bugs that aren't bugs

⏯ Playground Link

https://www.typescriptlang.org/play?ts=4.8.0-dev.20220808#code/MYewdgzgLgBCCMAuGBvGBtA1kmADAhgHQAkKYArgLYBGApgE4C+uAuslPebTIzALyoMBEigAi+KLUJgQAdwAUASmZsYHLjxj4IMUJCgBuAFAB6E-wB8MAHIgYDeiHpGje6HABMyNFhzDSFDQMKuyc3LwCPv5iElIyCsqsoRqMxmaWMAAqAJ4ADtwA5D4AHsjQ9ACWYADmqtQgIAA2tPhgBjwFMBU6MrDaEBXVYPjUzWp2UHmFPtjI0YF0TElqYe2MBYQubrAgAMzeGLN4RAFUiyErXAA0h1541CILwcsAZviNEOH8gujR4pLSORKC7qWg3AoPAAMBWQbw+X20unA0DS5j4Vhy+RgRRg9BaABNwI1shhSjBylVash6k0Wm1cQSiSSIYRobD3p81p1ujBeloIAMhiMxlAJlNsTM-CcyGdnqpQe0sHdcA9TkElqo4ZyOptXMidgAWA6+ObSp4a5Jg25zVUy9UXLVfSJCaX-OJAxLysLgqEwmCOniojKY6aksocSl1BrNVrtFls-0c2hcro9EB9AWDYajbiitTinEm46PWUWy7J633Ev215JrmbIA

💻 Code

const o1: { [k1: `a.${number}`]: true } = { [`a.${Date.now()}`]: true } as const;
// => No error

const o2: { [k1: `a.${number}`]: true } = { [`a.${Date.now()}`]: true };
// => Type '{ [x: string]: boolean; }' is not assignable to type '{ [k1: `a.${number}`]: true; }'.

const o3: { [k1: `a.${number}`]: true, [k2: `b.${number}`]: false } = { [`a.${Date.now()}`]: true, 'b.0': false } as const;
// => Type '{ readonly [x: string]: boolean; readonly 'b.0': false; }' is not assignable to type '{ [k1: `a.${number}`]: true; [k2: `b.${number}`]: false; }'.

const o4: { [k1: `a.${number}`]: true, [k2: `b.${number}`]: false } = { [`a.${Date.now()}`]: true, 'b.0': false };
// => Type '{ [x: string]: boolean; 'b.0': false; }' is not assignable to type '{ [k1: `a.${number}`]: true; [k2: `b.${number}`]: false; }'.

🙁 Actual behavior

Errors with o3 and o4 declarations. I think o2 should work also.

🙂 Expected behavior

No errors.

@PythonCoderAS
Copy link

Make a bug report on the mongodb driver repo first.

@jer-sen
Copy link
Author

jer-sen commented Aug 8, 2022

The issue as nothing to do with mongodb driver since I have a repro without it. It was just a context information for the issue to be easily findable.

@jcalz
Copy link
Contributor

jcalz commented Aug 8, 2022

Looks like a duplicate of #13948, see my comment there

@jer-sen
Copy link
Author

jer-sen commented Aug 8, 2022

@jcalz yes it looks the same

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Aug 8, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants