TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Infer from filtering mapped types

Open Andarist opened this issue 2 years ago • 11 comments

This implements a subset of the implied feature request from this issue: https://github.com/microsoft/TypeScript/issues/46602

Andarist avatar Feb 25 '23 17:02 Andarist

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 avatar Feb 25 '23 17:02 typescript-bot

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 avatar Mar 07 '23 00:03 sandersn

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

Andarist avatar Mar 07 '23 09:03 Andarist

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

Andarist avatar Sep 20 '23 09:09 Andarist

@typescript-bot pack this

jakebailey avatar Sep 20 '23 13:09 jakebailey

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

typescript-bot avatar Sep 20 '23 13:09 typescript-bot

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]".;

typescript-bot avatar Sep 20 '23 13:09 typescript-bot

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

Andarist avatar Nov 26 '24 23:11 Andarist

@typescript-bot pack this

jakebailey avatar Nov 27 '24 01:11 jakebailey

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results

typescript-bot avatar Nov 27 '24 01:11 typescript-bot

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]".;

typescript-bot avatar Nov 27 '24 01:11 typescript-bot