microsoft / microsoft/TypeScript
TypeScript emits d.ts file that is invalid for complex mapped type.
@weswigham ya está trabajando en esto.
Desde el 14/6/2024.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
🔎 Search Terms
d.ts emit type error
🕗 Version & Regression Information
This is a compile error when consuming a d.ts file emitting by the same version and configuration of TypeScript
This in 3.5.1, 4.0.5, 5.4.5 and 5.5.0-dev.20240528, but NOT in 3.3.3
⏯ Playground Link
💻 Code
export function adaptEnum<TEnum extends Record<string, string>>(
) {
type Part1 = {
[Property in keyof TEnum]: () => TEnum[Property]
};
const factoryOut = () => {
return (0 as unknown as typeof factoryOut & Part1)[0 as unknown as keyof TEnum]()
};
return factoryOut;
}
🙁 Actual behavior
Emits:
export declare function adaptEnum<TEnum extends Record<string, string>>(): () => TEnum[string] | TEnum[number] | TEnum[symbol];
Which Errors:
Type 'number' cannot be used to index type 'TEnum'.(2536)
🙂 Expected behavior
I expect TypeScript to either error when trying to emit a d.ts file, or generate a valid d.ts file it can consume without error.
Additional information about the issue
This issue report is derived from minimizing the same code that produced https://github.com/microsoft/TypeScript/issues/56718 (which is now fixed) and is similar to that issue. The same workaround I have from that case still works, so this isn't blocking anything except removing that workaround.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Evaluación
Este issue todavía no se ha evaluado.