Microsoft/TypeScript
Voir sur GitHubWrong elementwise error location on optional object property that allows arrays too
Open
#57 541 ouverte le 26 févr. 2024
Domain: Related Error SpansHelp WantedPossible Improvement
Métriques du dépôt
- Stars
- (48 455 stars)
- Métriques de merge PR
- (Merge moyen 6j 17h) (9 PRs mergées en 30 j)
Description
🔎 Search Terms
error location elementwise elaboration array optional object
🕗 Version & Regression Information
- This is a crash
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
⏯ Playground Link
💻 Code
type SingleOrArray<T> = T | readonly T[];
type ProvidedActor = {
src: string;
input?: unknown;
};
type MachineConfig<TActors extends ProvidedActor> = {
invoke?: SingleOrArray<TActors>;
};
declare function setup<TActors extends ProvidedActor>(): {
createMachine: (config: MachineConfig<TActors>) => void;
};
setup<{ src: "fetchUser"; input: string }>().createMachine({
invoke: {
src: "fetchUser",
input: 10,
},
});
🙁 Actual behavior
invoke property gets highlighted
🙂 Expected behavior
input property should get highlighted as it's the one that it's not correct and it's more specific than invoke
Additional information about the issue
we can observe the error location to change when:
- we remove optionality from
invoke - we make the provided type argument a union