Infer from filtering mapped types
This implements a subset of the implied feature request from this issue: https://github.com/microsoft/TypeScript/issues/46602
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.
Can you open a bug for that implied feature request? It makes it a lot easier for me to guess how much we want this feature.
@sandersn I think that the referenced issue already does that. The reason why I didn't tag this PR as closing that issue is that the examples there are using renaming mapped types but I'm only fixing here filtering ones. The title of the issue is "Parameter type isn't inferred in values of mapped type with as." and this PR implements support for a subset of that.
Why I didn't cover the other part of the story? There is no machinery in the compiler for reverse mapping the "computed" property name (the source property name) against the target's name type. However, there are already a couple of places that specifically handle those "filtering" mapped types (as they are way easier to handle).
@jakebailey could you create a playground for this one? :)
@typescript-bot pack this
Heya @jakebailey, I've started to run the tarball bundle task on this PR at fe90e8aea80da78406bad91ac0ca5d5736446f31. You can monitor the build here.
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:
{
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/157832/artifacts?artifactName=tgz&fileId=4FF3D4BA8C1DA40FA9800B9EB1BF585E940A5781DAC01DFE8FB9C6791FE46B0902&fileName=/typescript-5.3.0-insiders.20230920.tgz"
}
}
and then running npm install.
There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;
@jakebailey could you build a fresh playground for this one?
@typescript-bot pack this
Starting jobs; this comment will be updated as builds start and complete.
| Command | Status | Results |
|---|---|---|
pack this |
✅ Started | ✅ Results |
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:
{
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/164232/artifacts?artifactName=tgz&fileId=38FDB090EBAD3697EEED729881CBE4740494F4C9FEABE090519C5163A57B8BB602&fileName=/typescript-5.8.0-insiders.20241127.tgz"
}
}
and then running npm install.
There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;