-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
🔎 Search Terms
"autocomplete suggestions intellisense differences between indexed access and dotted access"
"indexed access vs dotted access suggested properties"
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
I tested it in TS Playground with Nightly and TS 5.2.
⏯ Playground Link
💻 Code
/**
* Mimicking rxjs to avoid dependency import
*/
type Observable<X> = {
subscribe(): Observable<X>
};
enum CPEvents {
CLICK = "click",
PLAY = "play",
CANPLAY = "canplay",
PLAYING = "playing",
PAUSE = "pause",
ERROR = "error",
ENDED = "ended",
LOADSTART = "loadStart",
RATECHANGE = "ratechange",
WAITING = "waiting",
SEEKING = "seeking",
SEEKED = "seeked",
TIMEUPDATE = "timeupdate",
VOLUMECHANGE = "volumechange",
DURATIONCHANGE = "durationchange",
ADDTRACK = "addtrack",
EMSG = "emsg",
PLAYBACK_BEGIN_HALTED = "playbackBeginHalted",
START_TIME_AVAILABLE = "startTimeAvailable",
CONTENT_STATE_CHANGED = "contentStateChanged",
AUDIO_PLAY_RIGHT_ACQUIRED = "audioPlayRightAcquired",
STATS_UPDATE = "statsUpdate",
}
// Payloads have been replaced for the repro-case, but they do not matter right now.
interface CPMappedEvents {
[CPEvents.EMSG]: unknown;
[CPEvents.DURATIONCHANGE]: unknown;
[CPEvents.VOLUMECHANGE]: unknown;
[CPEvents.TIMEUPDATE]: unknown;
[CPEvents.ERROR]: unknown;
[CPEvents.RATECHANGE]: unknown;
[CPEvents.ADDTRACK]: unknown;
[CPEvents.CONTENT_STATE_CHANGED]: unknown;
[CPEvents.START_TIME_AVAILABLE]: unknown;
[CPEvents.PLAYBACK_BEGIN_HALTED]: unknown;
[CPEvents.STATS_UPDATE]: unknown;
[CPEvents.AUDIO_PLAY_RIGHT_ACQUIRED]: unknown;
[CPEvents.SEEKING]: unknown;
[CPEvents.SEEKED]: unknown;
}
type CPUnmappedEvents = {
[K in Exclude<CPEvents, keyof CPMappedEvents>]: Event;
};
export type CPEventsMap = CPMappedEvents & CPUnmappedEvents;
export type CPObservableEvents = {
[K in keyof CPEventsMap]: Observable<CPEventsMap[K]>;
};
declare const eventObservables: CPObservableEvents;
🙁 Actual behavior
Intellisense (autocomplete) suggests two different subset of valid values when accessing a mapped object through dotted access and indexed access, but accessing with a dotted access to an unsuggested (available in indexed access and there fore still valid) property seems to be still valid and well-recognized.
🙂 Expected behavior
The suggested values should be the same if there is not a specific indexed signature.
Additional information about the issue
No response
salvatore-esposito-greenEmiyaYang
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorFix AvailableA PR has been opened for this issueA PR has been opened for this issue