Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: channel unions (#3918 69d69f2) #3978

Merged
merged 4 commits into from
Mar 27, 2020

Conversation

SpaceEEC
Copy link
Member

@SpaceEEC SpaceEEC commented Mar 21, 2020

Please describe the changes this PR makes and why it should be merged:

This PR reverts #3918 / 69d69f2.
(Aside from StoreChannel#type and GuildChannel#setParent, as those are unrelated to this)

Taking the following example here:

guild.channels.cache.get(someID).setName('foo').then(channel => {
  console.log(`New name: ${channel.name}`);
});

Results in an error like this:

This expression is not callable.
  Each member of the union type
(<TResult1 = CategoryChannel, TResult2 = never>(onfulfilled?:
(value: CategoryChannel) =>TResult1 | PromiseLike<TResult1>, onrejected?:
(reason: any) => TResult2 | PromiseLike<...>) => Promise<...>)
| (<TResult1 = NewsChannel, TResult2 = never>(onfulfilled?: (value: NewsChannel) =>
TResult1 | PromiseLike<...>, onre...
has signatures, but none of those signatures are compatible with each other.

However using async / await seems to work fine:

const channel = await guild.channels.cache.get(someID).setName('foo');
console.log(`New name: ${channel.name}`);

Considering that it works when using async / await, this feels like an issue with TS rather than our typings.

A d.js-free example of this error:

function a() {
	return Promise.resolve('a');
}

function b() {
	return Promise.resolve([1]);
}

function c() {
	if (Math.random() > 0.5) return a();
	return b();
}

c().then(thing => {
	console.log(`thing has a length of ${thing.length}`);
});

However there probably is nothing we can really do about this for now, except reverting.

Status

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

@iCrawl iCrawl merged commit b441469 into discordjs:master Mar 27, 2020
@SpaceEEC SpaceEEC deleted the revert/channel_type_unions branch March 27, 2020 20:52
ctsstc added a commit to osu-cascades/hackbot that referenced this pull request Apr 24, 2020
@ctsstc

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants