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

Infer from filtering mapped types #52972

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

This implements a subset of the implied feature request from this issue: #46602

@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Feb 25, 2023
@sandersn
Copy link
Member

sandersn commented Mar 7, 2023

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 sandersn self-assigned this Mar 7, 2023
@Andarist
Copy link
Contributor Author

Andarist commented Mar 7, 2023

@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).

…apped-types

# Conflicts:
#	src/compiler/checker.ts
@Andarist Andarist force-pushed the infer-from-filterin-mapped-types branch from 379bc27 to 22fec49 Compare March 19, 2023 17:13
@Andarist
Copy link
Contributor Author

@jakebailey could you create a playground for this one? :)

@Andarist Andarist force-pushed the infer-from-filterin-mapped-types branch from f6f759b to fe90e8a Compare September 20, 2023 09:48
@jakebailey
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 20, 2023

Heya @jakebailey, I've started to run the tarball bundle task on this PR at fe90e8a. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 20, 2023

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/pr-build@5.3.0-pr-52972-6".;

@Andarist
Copy link
Contributor Author

@jakebailey could you build a fresh playground for this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Waiting on reviewers
Development

Successfully merging this pull request may close these issues.

5 participants