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

Proposal: Change native lib instead #53

Open
fregante opened this issue Jul 31, 2022 · 7 comments
Open

Proposal: Change native lib instead #53

fregante opened this issue Jul 31, 2022 · 7 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@fregante
Copy link
Contributor

I'm hesitant to use this library as is because to a new developer this looks unnecessary:

arrayIncludes(arr, value)

and will likely attempt to change it to:

arr.includes(value)

which may even pass the tests and continue being less strict.

What do you think about offering additional entry points to change the global lib instead? I do this pattern to make some Promise types stricter for example: microsoft/TypeScript#45602 (comment)

@sindresorhus
Copy link
Owner

sindresorhus commented Jul 31, 2022

I'm open to it as long as it's clearly documented that it should not be used in packaged.

@tychenjiajun
Copy link
Contributor

Do you mean declaration merging?

Maybe we can add a global.d.ts, users who want to use this pattern can use tsconfig.ts to include this merging?

{
  "compilerOptions": {
    "typeRoots": ["./node_modules/ts-extras/global.d.ts"]
  }
}

@fregante
Copy link
Contributor Author

fregante commented Aug 5, 2022

That's right. However I'm not entirely sure it can be loaded "as a whole" because maybe not all types are desired + it would cause more breaking releases.

Having to import specific "fixes" would be best, like Object.entries and Array#includes

@sindresorhus
Copy link
Owner

Seems verbose and annoying to import individual types for this though. Maybe we start by exporting all and see if it causes any problems? We would document that those types do not follow semver and need to be pinned.

@fregante
Copy link
Contributor Author

fregante commented Aug 7, 2022

It's literally less verbose than the current situation though 😃

Import object.entries once per project vs once per file.

I'm ok with the global to start though

@sindresorhus sindresorhus added enhancement New feature or request help wanted Extra attention is needed labels Aug 7, 2022
@privatenumber
Copy link
Sponsor

Note, overwriting typeRoots will remove the default behavior of automatically detecting node_module/@types.

@fregante
Copy link
Contributor Author

Found a WIP library that does this by default:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants