3 ms·
Often, I find myself in need to find all references of "Active" from your example, which doesn't work with union values. This looks like a LSP limitation. Of co
by Klaster_1 2y ago
Often, I find myself in need to find all references of "Active" from your example, which doesn't work with union values. This looks like a LSP limitation. Of course, you can move assign values into consts and union these instead. But that means you are half way there to custom run-time enums, and all the way after you wrap the consts with an object in order to enumerate over values at run-time.
- mistercow 2y ago> Often, I find myself in need to find all references of "Active" from your example, which doesn't work with union values. I'm able to do that just fine in VS Code / Cursor. I set up a union like this: export type TestUnion = 'foo' | 'bar' | 'baz'; Then use it in another file like this: const bar: TestUnion = 'bar'; const barString: string = 'bar'; If I select 'bar' from the type and choose "Go to references", it shows me the `const bar` line, but not the `const barString` line, which is what I would expect.
- homebrewer 2y agoUse `const enum Foo`, they leave no traces in the transpiled JS and provide good IDE experience.