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

Don't use TypeScript const enum #50

Merged
merged 1 commit into from Dec 29, 2020
Merged

Don't use TypeScript const enum #50

merged 1 commit into from Dec 29, 2020

Conversation

threepointone
Copy link
Contributor

@threepointone threepointone commented Dec 28, 2020

This PR replaces the const enum in index.d.ts with a regular enum. This lets boxen (or any packages that depend on it) be used in projects whose tsconfig has the setting isolatedModules:true.


Hi! I was going to make an issue, but figured I'd make a PR with a suggested fix too.

Problem: I want to use update-notifier in a typescript project. My project has isolatedModules: true (because we're compiling with babel-preset-typescript, and trying to match variations across the two). Trying to typecheck this project fails with

$ node_modules/.bin/tsc
node_modules/boxen/index.d.ts:172:22 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

172  BorderStyle: typeof BorderStyle;
                         ~~~~~~~~~~~


Found 1 error.

which is expected, of course. But I can't seem to figure out a workaround for this that doesn't rely on using skipLibCheck: true, which would suck. Would it be possible for you to replace the const enum here with a regular enum? I made this change locally and it appeared to work fine, but I'm not clear what the broader implications are.

Please and thank you!

This PR replaces the const enum in index.d.ts with a regular enum. This let's enum be used in projects whose tsconfig has the setting `isolatedModules:true`.
@sindresorhus sindresorhus changed the title Replace the const enum with a regular enum Don't use TypeScript const enum Dec 29, 2020
@sindresorhus sindresorhus merged commit 117409e into sindresorhus:master Dec 29, 2020
@threepointone threepointone deleted the patch-1 branch December 29, 2020 10:54
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

Successfully merging this pull request may close these issues.

None yet

2 participants