Improve semantic highlighting of `TypeAlias`
I wonder if:
-
Pylance could use
TypeAliasinstead of the type alias name for the type hinting for type aliases. According to PEP 613, the type hinting for type aliases should be TypeAlias. -
Pylance could use the same color to display type hintings regardless of whether they are native or type aliases. When I use the theme Horizon Extended Theme, native type hintings are in yellow and type aliases in red (like variables).
Example:

I am using:
- VS Code: Version: 1.70.0-insider (system setup) Commit: 13ba7bb446a638d37ebccb1a7d74e31c32bb9790 Date: 2022-07-22T05:17:00.353Z OS: Windows_NT x64 10.0.19044
- Python extension: 2022.11.12031009
- Pylance extension: 2022.7.41
Similarly, consider behavior of NewType -- https://github.com/microsoft/pylance-release/issues/3754
Any updates on this?
Sorry but this is not currently planned. However you can get this somewhat by yourself.
The TypeAlias is flagged with a typehint modifier in the semantic token. This allows you to override the color:
"editor.semanticTokenColorCustomizations": {
"[Default Dark Modern]": {
"rules": {
"*.typeHint": "#4EC9B0"
}
}
}
Which for me, gives the same color for the typehint as the original type.
Great, I'll try for it. Thanks!
It works for type hints only, so I think pylance should still provide separate semantic tokes for type aliases (or mark them as types or classes at least).
Anyway, the type hint trick is better than nothing, thanks for the suggestion.
Really need this feature!
Even after the changes made, this still seems to be broken.
This is with changes submitted to the main branch:
Oh it seems it's only for unions that it doesn't work.
This does:
I'll enter a new issue for unions. https://github.com/microsoft/pylance-release/issues/6854
This issue has been fixed in prerelease version 2025.1.100, which we've just released. You can find the changelog here: CHANGELOG.md