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

Bundle failure when export default "satisfies" any generic type, in Typescript 4.9.1-beta #1511

Open
gepz opened this issue Sep 25, 2022 · 10 comments

Comments

@gepz
Copy link

gepz commented Sep 25, 2022

Expected Behaviour

Output file is bundled correctly.

Actual Behaviour

The output file index.js only contains the 2 lines of the compiled entry file without bundling anything.

(()=>{"use strict"
simpleWrap(mainComponent,void 0)})()

Steps to Reproduce the Problem

Import anything and use it in export default,
Then add "satisfies Readonly" or satisfies any other generic type at the end

import mainComponent from '@/mainComponent';
import simpleWrap from '@/simpleWrap';

export default simpleWrap(
  mainComponent,
  undefined,
) satisfies Readonly<unknown>;

This only happens when export default satisfies a generic type, "satisfies unknown" or "satisfies () => void" work correctly.

Dependencies:

    "ts-loader": "^9.3.1",
    "typescript": "^4.9.1-beta",
    "webpack": "^5.74.0",
    "webpack-bundle-analyzer": "^4.6.1",
    "webpack-cli": "^4.10.0",
    "webpack-dev-server": "^4.10.1",

Location of a Minimal Repository that Demonstrates the Issue.

@johnnyreilly
Copy link
Member

It's likely this is a typescript issue rather than a ts-loader/webpack one. ts-loader uses the export from TSC - probably worth looking there first.

@gepz
Copy link
Author

gepz commented Sep 25, 2022

I'm not sure how to reproduce this with tsc only.
Does ts-loader/webpack use anything else from tsc other than the generated js and declaration files that can be obtained by running tsc cli?

@johnnyreilly
Copy link
Member

Just run tsc over your source files. It ships with the TypeScript npm package

@cjdell
Copy link

cjdell commented Nov 24, 2022

I encountered this issue when beginning to use the satisfies keyword for the first time in a WebPack project. I've narrowed it down to the smallest example of the bug occurring. Please see the following repo:

https://github.com/cjdell/ts-loader-satisfies-bug

Hope this is of help. Let me know if you want me to clarify anything. Also thank you to all contributors for giving this your valuable attention.

@johnnyreilly
Copy link
Member

Thanks for sharing a reproduction - I don't have bandwidth to look at it at present but I encourage others to do so. I'm surprised this is occurring as TSC should be stripping this

@cjdell
Copy link

cjdell commented Nov 24, 2022

Thanks @johnnyreilly. I actually have since narrowed it down further and I'm invoking the TS compile just as ts-loader does and it behaves the same way. Looks like a legitimate TS bug. Your instincts were correct. I will raise the issue on the TS repo. Thanks for replying so quickly.

@johnnyreilly
Copy link
Member

No worries!

@cjdell
Copy link

cjdell commented Nov 25, 2022

Link to the TypeScript issue for anyone following this:
microsoft/TypeScript#51642

@cjdell
Copy link

cjdell commented Dec 1, 2022

Looks like this will be fixed very shortly... :-)
microsoft/TypeScript#51704

@johnnyreilly
Copy link
Member

I hope you're satisfies @cjdell 😅

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

No branches or pull requests

3 participants