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: add stringConcat and/or arrayJoin #42

Open
tychenjiajun opened this issue Mar 7, 2022 · 4 comments
Open

Proposal: add stringConcat and/or arrayJoin #42

tychenjiajun opened this issue Mar 7, 2022 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@tychenjiajun
Copy link
Contributor

No description provided.

@sindresorhus
Copy link
Owner

How would it improve the types compared to the built-ins?

@sindresorhus
Copy link
Owner

Bump

@tychenjiajun
Copy link
Contributor Author

Sorry for being late. In my company, use https://github.com/primus/eventemitter3 in our projects. We may have an event emitter

const ee = new EventEmitter<{
    'fish.ADD': [Fish],
    'cat.ADD': [Cat]
}>();

And we also have an event handler that listens to all animals adding event

const ANIMALS = ['fish', 'cat'] as const;

function animalAddingHandler(a: Animal) {}

ANIMALS.forEach(a => ee.on(a + '.ADD', animalAddingHandler)); // Argument of type 'string' is not assignable to parameter of type '"fish.ADD" | "cat.ADD"'.(2345)

Playground

We may use as and https://github.com/sindresorhus/type-fest/blob/main/source/join.d.ts to solve this but a stringConcat and/or arrayJoin would be helpful

@sindresorhus
Copy link
Owner

Alright 👍

@sindresorhus sindresorhus added enhancement New feature or request help wanted Extra attention is needed labels Apr 3, 2022
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

2 participants