Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove const enum and add ErrorValue in index.d.ts#1317

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Siemienik merged 1 commit intoexceljs:masterfromaplum:remove-ts-const-enum
Jun 8, 2020

Conversation

@aplum
Copy link
Contributor

Summary

Usingconst enum in .d.ts files breaks compilation with--isolatedModules. Instead, normalenums have been used where a corresponding object exists at runtime.PaperSize does not exist at runtime, and so has been left asconst enum for backwards compatibility.

This also adds a declaration forErrorValue since it exists at runtime but had no TS definition. This does result in some duplication withCellErrorValue, but changingCellErrorValue to useErrorValue would be a breaking change.

A comparable fix and explanation for the problem with usingconst enum can be found atchalk/chalk#296, and some further explanation athttps://ncjamieson.com/dont-export-const-enums/ andthis comment.

Test plan

I created a small project to test this while making changes. Example file:

import{ValueType,CellModel}from'exceljs';letvt:ValueType=ValueType.Date;constvtString=ValueType.String;exportconstcm1:Partial<CellModel>={type:vt};exportconstcm2:Partial<CellModel>={type:vtString};exportconstcm3:Partial<CellModel>={type:ValueType.Boolean};

Before this PR:

  • No errors withisolatedModules: false
  • Errors withisolatedModules: true

With this PR:

  • No errors withisolatedModules: false
  • No errors withisolatedModules: true

Using `const enum` in .d.ts files breaks compilation with `--isolatedModules`. Instead, normal `enum`s have been used where a corresponding object exists at runtime. `PaperSize` does not exist at runtime, and so has been left as `const enum` for backwards compatibility.This also adds a declaration for `ErrorValue` since it exists at runtime but had no TS definition. This does result in some duplication with `CellErrorValue`, but changing `CellErrorValue` to use `ErrorValue` would be a breaking change.
@alubbealubbe requested a review fromSiemienikJune 8, 2020 09:11
@alubbe
Copy link
Member

@Siemienik do you think we could make the above typescript code into a test file and add it to our test suite?

@Siemienik
Copy link
Member

@aplum thanks 😄

aplum reacted with thumbs up emoji

@SiemienikSiemienik merged commitc0ead35 intoexceljs:masterJun 8, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@SiemienikSiemienikSiemienik approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@aplum@alubbe@Siemienik

[8]ページ先頭

©2009-2025 Movatter.jp