Default assigned generic type isn't generated
See original GitHub issue- Version: 3.0.2
- Rollup Version: 2.76.0
- Operating System and version (if applicable): Windows 10
- Node Version (if applicable): 16.15.0
- Does it work with
tsc
(if applicable): Yes
Reproduction
I have two files: index.ts
and SomeElse.ts
:
// index.ts
export * from "./SomeElse";
// SomeElse.ts
export type SomeGeneric<T extends {} = any> = [string, T];
The input for rollup is the index.ts
file.
Note: if the input file would be SomeElse.ts
(so the re-export isn’t happening) the output would be correct.
Not very familiar with repl, but here is a link: https://replit.com/@KingSora/rollup-plugin-ts-bug
The setup is actually really small, please just re-create it on your local machine if needed.
Run npm run build
to build the output.
Expected Behavior
The type is exported correctly:
type SomeGeneric<T extends {} = any> = [string, T];
export { SomeGeneric };
Actual Behavior
The type is exported without the default assigned type any
:
type SomeGeneric<T extends {}> = [
string,
T
];
export { SomeGeneric };
Issue Analytics
- State:
- Created a year ago
- Reactions:10
- Comments:6
Top Results From Across the Web
Why is it that we cannot assign default value to generic type ...
I'm not quite sure what the error message means, but it seems that logically, the signature is completely valid. Is this just not...
Read more >Type Inference does not work for generics with default types
Currently generic type inference happens only when no generic type arguments are provided. specifying at least one disables all generic ...
Read more >Java Generics Example Tutorial - Generic Method, Class ...
A generic type is a class or interface that is parameterized over ... type of A can be assigned to generic type of...
Read more >Generic Types - Learning the Java Language
A generic type is a generic class or interface that is parameterized over types. The following Box class will be modified to demonstrate...
Read more >Constraints on type parameters - C# Programming Guide
If your generic class or method uses any operation on the generic members beyond simple assignment or calling any methods not supported by ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @tihuan, as you suggested, but instead of downgrading, I upgraded to “typescript”: “4.8.2” and now it works. But 4.8.2 version of TS seems to introduce quite many breaking changes and deprecation notes. I saw these notes when I built my project.
if you’re blocked by this, try typescript 4.6. It worked for us!