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

Typescript fails compiling with lib ESNext when importing @ulixee/hero-playground #181

Closed
IonelLupu opened this issue Nov 7, 2022 · 7 comments

Comments

@IonelLupu
Copy link

Hello everyone. I discovered a very very strange issue. It seems Hero breaks the typescript compiler. For example, having this project setup, makes typescript throw an error:

// tsconfig.json
{
  "compilerOptions": {
    "target": "es2020",
    "lib": ["ESNext"],
    "module": "commonjs",
    "strict": true,
    "skipLibCheck": true 
  }
}

// index.ts
import "@ulixee/hero-playground";
"test".replaceAll("t", '')

Compiling this will result in this error: "Property 'replaceAll' does not exist on type"

But (and here is the weird part), if I comment the "import", the typescript compiler doesn't complain anymore:

// index.ts
//import "@ulixee/hero-playground";
"test".replaceAll("t", '')

compiles with no errors

Does anyone have any idea why is this happening?

To note that replaceAll is a ES2021 feature. It seems @ulixee/hero-playground somehow removes this method from the String object. Is Hero updating the prototype of the String object?

@IonelLupu IonelLupu changed the title Typescript fails compiling when importing @ulixee/hero-playground Typescript fails compiling with lib ESNext when importing @ulixee/hero-playground Nov 7, 2022
@blakebyrnes
Copy link
Contributor

Hero doesn't manipulate any of the Javascript objects like String. I think this is just typescript deciding to downgrade the code compatibility standard. As to why... I don't have any idea. I'm not even sure we're publishing any typescript related files to npm besides the declaration files. Can you double check that your @ulixee /* npm modules don't include any tsconfig files? I'm fairly certain we're not publishing those, but worth checking

@blakebyrnes
Copy link
Contributor

@IonelLupu Any update here?

@IonelLupu
Copy link
Author

IonelLupu commented Nov 14, 2022

hey @blakebyrnes

I check my node_modules and I found these tsconfig.json files:

  • @ulixee/hero-core/injected-scripts/tsconfig.json from -> package version "2.0.0-alpha.11"
  • @ulixee/hero-timetravel/injected-scripts/tsconfig.json -> package version: "2.0.0-alpha.11"

@blakebyrnes
Copy link
Contributor

Does it fix your issue to remove those files?

@IonelLupu
Copy link
Author

Unfortunately, no.

I also tested by importing different modules from @ulixee and it seems that only a few of the contain the problem:

Problem (@ulixee/hero-core for example):
image

Not a problem (@ulixee/commons is OK):
image

@havardox
Copy link

havardox commented Jun 1, 2024

Can someone here post a working TypeScript project using this package? I can't for the life of me get the imports to work

@blakebyrnes
Copy link
Contributor

Can someone here post a working TypeScript project using this package? I can't for the life of me get the imports to work

Can you start a new discussion or issue with your code and the error you're seeing? I don't think many people have reported issues except that they had to set skipLibCheck to true

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