Skip to content

Intellisense provides different suggestions on autocomplete when using indexed access or dotted access #56096

Open

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

https://www.typescriptlang.org/play?ts=5.3.0-dev.20231013#code/PQKhCgAIUhxB5AggGQFyQOYEsBuBTAO0gEMjCBXAW0gHsAzSABxoGcWsAjAGz0j3wIAXFgBpIAd17jSgyIJpQYxNlgxEWNSr36FZjYgE8uNYgBM5Bxr3mQNW2g0EALbQOEA6RZC8AVF5AAnPBZZFicaci5zDDxZYkxCPACsAGNIACIAUTd0pkNjMxIVNTxTT2hIAHU8MWdCMTCIqMgOXmJuaxpILQCYlppnOX8QgPIUwXIgli9Sc1aSDsgsIjpyAnGsGgIWIeJZchZeGIIk1J2uLABraycsHa3eVuNxLxsaDkFiZaHefSMTcwhYgBQTLDCQOgBTQ-PhuCxWcogYDgcCmPApLjA3irdagrYQrBcQRJADCB3klGyugACvkAQAxGgBKlCAA8Pj4AA9iQRTDsSdSWcIAHwACjoTKF6B8AEp0PAOIcAjh2jxWQKhSwALLERgAbR8AF1hSjQBAKlqsJRUpcwYFOQArHY2Yg4GhYcxoqy8wgpAxLSjMEGKZHgQSWXgKpUqjqsgAawsgAF5IABvcAASBY5EVKWSrVFcsgUaSMbVCfAAF8ANymsCQZCxADkO1a2CISJRFGoGrcO3TGZJyAAkiSANLJjIYm3pESZ6nIRAATUn6UYmIMs8zJMQADkF8vVylSOvDFuMwel8Pd7BV6eDGDz9TEABVADKmTvxAOeHPmQASv+8D-quSRQgEf67gAIpkUGgT6pjnsgSBQW+PiIP+HIpukBSmG+nwgue-6ID4mQkgAEnusCfthAR7OiTikDE56VIgw4+Net7YdIWCggQGDnh+mRjpxq6HHgtr8YJmTCbBYl4BJpTnhxWqZC+1JQSRNEZKCWjkIwpj0eeABq8D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BaFKbQIgzhgHWMYFMdg+IOA83dPxfozhUCIIYagioOghCdI6HUq5TCKgzF5JcmAjCvC3MEPcngLA9TpHSIaZBKCAAF7zvAVD8NoVRqTaZTEiLIYBzg9hLC5i4f0jRIjmD2TQHAHprDiC6P9OgdAki6C8NmXpwgwEpHCKkYIkBRTEhCLTdJgxdxiy4P6fE8BxiQAAIwAGYZT1O+b84IgyKj5RfD4MQWAGDDkgLzEgKQaZsCGFCcgGBMm80EMScwTV1XOi6PEXFVgQT+hRUinY-NQjapiKy0wc4Ki8RAYEDBagsAAC9abKEgCqC4hreQSEmVweEpREShnFb0pxDz3ANSapcFqbUOoGvAMAfGkBs05tzXmyAAA9AA-FKwBtwdh3HldsYkZgxBBAgV631ZRIDQuaeJbKchTVKyxEIbl5NNl9oeMqhVZKgjrBuHsLw1odWyHmHUcpeAeWOH8LijolB0DmqSOGBdBhKnNPrTQRtfqdgktHboKNXY3ASu1voH8Gas35sfdm4tLCNFjkXSweAdAhTXsnJ4iNZCY01IebWTNuaX2luLAwCBkxoFGuCOwU5zgtU6pKWUip7qQiEnDYGj0F7wAQOrZATkk5RRAb6Q8qeycZ4lTKhVXcVUUDLxlKBh9haS0EdabIf0KYyNXtjf4-5j9nzvkLix+94Gi1AA

💻 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

BugA bug in TypeScriptDomain: Completion ListsThe issue relates to showing completion lists in an editorFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions