Description
The following code no longer compiles after upgrading from TypeScript 4.2.4 to 4.3.2
(Click here to expand)
import { App } from "@slack/bolt";
const app = new App();
app.command("/say_hi", async ({ ack, respond }) => {
await ack();
await respond({
blocks: [{ type: "section", text: { text: "hi", type: "plain_text" } }],
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// error TS2345: Argument of type '{ blocks: { type: string; text: { text: string; type: string; }; }[]; response_type: "ephemeral"; }' is not assignable to parameter of type 'string | RespondArguments'.
// Object literal may only specify known properties, and 'blocks' does not exist in type 'RespondArguments'. });
response_type: "ephemeral",
});
});
I have narrowed down the problem to the utility type KnownKeys<T> in /src/types/helpers.ts.
type type KnownKeys<T> = {
[K in keyof T]: string extends K ? never : number extends K ? never : K;
} extends { [_ in keyof T]: infer U }
? U
: never;
type Foo = {
foo: "Foo";
bar: "Bar";
[key: string]: any;
};
type Result = KnownKeys<Foo>;
// type of `Result` is `never` in TypeScript 4.3.2
// type of `Result` is `"foo" | "bar"` in TypeScript 4.2.4
KnownKeys<T> failing to resolve the keys has caused RespondArguments in /src/types/utilities.ts to omit the property "blocks" by calling Pick with never as the 2nd type argument:
type RespondArguments = Pick<
ChatPostMessageArguments,
Exclude<KnownKeys<ChatPostMessageArguments>, 'channel' | 'text'> // <-- KnownKeys<T> fails here
> & { /* ... */ };
...which in turn causes RespondFn to report an error when "blocks" is included in respond({ /* ... */ })
What type of issue is this? (place an x in one of the [ ])
Requirements (place an x in each of the [ ])
Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version: 3.3.0
node version: 15.12.0
OS version(s): OSX 11.3.1
Steps to reproduce:
(See description)
Also, /types-tests/utilities.test-d.ts should show an error after upgrading to TypeScript 4.3 (See attachment)
Expected result:
KnownKeys<T> should work properly in TypeScript 4.3.
Maybe add a test case to cover type Result = KnownKeys<Foo>; should not infer type never.
Actual result:
KnownKeys<T> infers never in TypeScript 4.3.
Attachments:

Description
The following code no longer compiles after upgrading from TypeScript 4.2.4 to 4.3.2
(Click here to expand)
I have narrowed down the problem to the utility type
KnownKeys<T>in/src/types/helpers.ts.KnownKeys<T>failing to resolve the keys has causedRespondArgumentsin/src/types/utilities.tsto omit the property "blocks" by callingPickwithneveras the 2nd type argument:...which in turn causes
RespondFnto report an error when "blocks" is included inrespond({ /* ... */ })What type of issue is this? (place an
xin one of the[ ])Requirements (place an
xin each of the[ ])Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
package version: 3.3.0
node version: 15.12.0
OS version(s): OSX 11.3.1
Steps to reproduce:
(See description)
Also,
/types-tests/utilities.test-d.tsshould show an error after upgrading to TypeScript 4.3 (See attachment)Expected result:
KnownKeys<T>should work properly in TypeScript 4.3.Maybe add a test case to cover
type Result = KnownKeys<Foo>;should not infer typenever.Actual result:
KnownKeys<T>infersneverin TypeScript 4.3.Attachments: