-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Emtpy interface reduced to never
in nested generic function
#49536
Comments
More versions tested:
|
@RyanCavanaugh if we just want some kind of workaround that preserves the |
Hello, Unfortunately, I was unable to make the workaround above work (suggested by @weswigham I have the same issue in a slightly different use case. There is a TS project which contains the code like this: type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
interface IProps {
size: '1' | '2';
}
// It is empty during build time, but will be changed via module augmentation by external code
export interface IEmpty {}
type MyType = DistributiveOmit<IProps, keyof IEmpty> & IEmpty;
function withMods<T>() {
// just an example
return null as (T & { a: 1 });
}
export const Button = withMods<MyType>(); My goal is to compile the project, generate DTS, and then use module augmentation in a separate TypeScript project to dynamically modify the Actual behavior Code sandbox: link Expected behavior Thanks in advance. |
Fixed in v5.5.2 😄 |
Bug Report
I can't find the docs about this behavior or google. I am not sure this is a bug.
My intention was define the
IEmpty
interface and augment it later, but the compiler reduce theIEmpty
interface tonever
, my current workaround that have to define two dummy properties or not use nested function(or closure).Is there a right way to force the compiler to keep the
IEmpty
in nested generic function?🔎 Search Terms
closure, nested, generic, emtpy interface, never, narrow
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
.D.TS
output:🙂 Expected behavior
.D.TS
output:The text was updated successfully, but these errors were encountered: