microsoft / microsoft/TypeScript

Mapped types created from reverse mapped types with union/intersection constraints don't have declaration linked

Ouverte
#57,211 0 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Domain: Mapped Types Help Wanted Possible Improvement
Langage dominant
Go
Étoiles
111k
Forks
14.4k
Merge moyen
1 j 19 h
PR mergées (30 j)
117

Description

🔎 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

https://www.typescriptlang.org/play?ts=5.4.0-dev.20240128#code/C4TwDgpgBAysBOBLAxsA8mYiD2A7AcgIYC20AvFAES7YCSxYANiosAIK4iVQA+VAzghTB8AV0aMAwgAsIyANb9KAbgBQiXMAjwAZoWTRJ2BokbaMWPPygBvVVAdRE-bI0JaAJgFlsH8RH4AfgAuKAAjbFcIQlw1RygaeiYWdk4Q8MizGLjHQSRUdIio7PtcoVQxCRk5RULM6NjShwA3bTD3RGIfPzMYEE1CAA864saAX1VQSCgjEzN4CxxcAGkIEGsKeTXsHVsmqABtZadcKC2QHZnjMFNzTCXrQms8jQBzKAhBrVwPa2PAhIQVrwKChZYAXVCMRAajGag8cjc8GgOlEuFQSygrwgwDg+XQ9zwADVCIxRBAABTIa63BaE3D8UKzG7zRZWAA0UB0bleoTxwjZBBIEAAlKEillGgjkEiUWiMXgoMhke4IMzRJ5mbTBfwADwAFQ+XwgP2sACU5Nh4B5dS9cK9OVrWfTVusDuCAHweinYemMvbxI4nKAU86XQ0AMiuczulhWa34It4sHKBLjRFIkID8UcCMgPxNyEQAVC+qO4JyOaV1w1EBJZIgoSpNOdcf9AAUUPJdU7Yw9Occ+GWIQdcKJiGFtJ6k2QPVAAKKDGWiBE9lt9qzlzlohE6DQQDweytQOGqMZiqBTCCXX1ttSqakM4DVhi1jxQCjK6JadWa9d0tsKTsBxnFcVVvF8fx-WA3MIHzBF0WLf0DkoYF2iwLpIN6fpgCGShwXZfZqVfLR63JJtiJZDcGRnOcYPiZFgFEeBTgAQlYil9niSjtT9AA6UC3E8booN4PgeNbB4+LQjpMJ6CA+gGQYuKgEVjzGQiHA00pEgYZgi1SEBQnoqA8xNBCixLQ5KBeVB8M0xxKNrMjGxDCTqMTD86JUxjmNObFcVTQUXObGMAP7KhdOSAyOC4NT9m0rSHNskRxCkWQFGg-YzILRCrJQlL7KImtSNJci3P-HVaOzBicT8rEcX5VBgrKyl3PCjkBFTSp0pqJR4viRKT0I8970fQQGuAWh+GmsDhKwgIPxfMA3wElwhIPESzH4AB6AAqABGPadr4pzSobVRLquq6gA

💻 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.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par la reproduction TypeScript Playground liée et inspectez la requête go-to-definition au niveau de marker 1, en vous concentrant sur le reverse mapped type et son modifiersType. Comparez le résultat avec la propriété attendue à la ligne 21. C’est terminé lorsque go-to-definition depuis computed.isolatedModules.computeValue aboutit à cette déclaration de propriété.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
compilers
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
38/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.