microsoft / microsoft/TypeScript
Mapped types created from reverse mapped types with union/intersection constraints don't have declaration linked
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
🔎 Search Terms
reverse mapped type go to definition union intersection constraint declarations
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
type StrictOptionName = "noImplicitAny" | "strictNullChecks";
interface CompilerOptions {
isolatedModules?: boolean;
noImplicitAny?: boolean;
strict?: boolean;
strictNullChecks?: boolean;
verbatimModuleSyntax?: boolean;
}
type CompilerOptionKeys = keyof {
[K in keyof CompilerOptions as string extends K ? never : K]: any;
};
declare function getStrictOptionValue(compilerOptions: CompilerOptions, flag: StrictOptionName): boolean;
declare function createComputedCompilerOptions<T extends Record<string, CompilerOptionKeys[]>>(options: {
[K in (keyof T & CompilerOptionKeys) | StrictOptionName]: {
dependencies: T[K];
computeValue: (compilerOptions: Pick<CompilerOptions, K | T[K][number]>) => Exclude<CompilerOptions[K], undefined>;
};
}): typeof options;
const computed = createComputedCompilerOptions({
isolatedModules: {
dependencies: ["verbatimModuleSyntax"],
computeValue: (compilerOptions) => {
return !!(
compilerOptions.isolatedModules || compilerOptions.verbatimModuleSyntax
);
},
},
noImplicitAny: {
dependencies: ["strict"],
computeValue: (compilerOptions) => {
return getStrictOptionValue(compilerOptions, "noImplicitAny");
},
},
strictNullChecks: {
dependencies: ["strict"],
computeValue: (compilerOptions) => {
return getStrictOptionValue(compilerOptions, "strictNullChecks");
},
},
});
const getIsIsolatedModules = computed.isolatedModules/*1*/.computeValue
🙁 Actual behavior
Go to definition doesn't go anywhere at marker 1
🙂 Expected behavior
Go to definition should go to the property at the line 21
Additional information about the issue
modifiersType for this mapped type is unknown. I think that potentially the modifiers type when iterating over any reverse mapped type (when reversed.mappedType === (mappedType.target || mappedType) could use that reversed.source as the modifiers type. If not that then at least declarations could be outsourced to that type for linking properties.
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.
Línea de trabajo
Comienza con la reproducción vinculada de TypeScript Playground e inspecciona la solicitud de go-to-definition en marker 1, centrándote en el reverse mapped type y su modifiersType. Compara el resultado con la propiedad esperada en la línea 21. Se considera terminado cuando go-to-definition desde computed.isolatedModules.computeValue resuelve a esa declaración de propiedad.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100