Skip to content

Migrate to TypeScript#147

Merged
gajus merged 1 commit intogajus:masterfrom
nam-hle:typescript
Apr 19, 2021
Merged

Migrate to TypeScript#147
gajus merged 1 commit intogajus:masterfrom
nam-hle:typescript

Conversation

@nam-hle
Copy link
Collaborator

@nam-hle nam-hle commented Apr 15, 2021

This PR is for migrating the package to TypeScript (#146) with major changes (but should not contain breaking changes 🙏):

  • Remove/replace all flow and babel packages/commands
  • Remove unnecessary JSdocs
  • Expose type declarations. The users would not need to @types/table now.
  • Reduce the unpacked size by 24% (112.4 kB now), the number of shipped files by 42% (33 files now)

Additionally, the schema definitions could generate from type definitions with third-party libraries like ts-json-schema-generator. By doing that, we can safely remove most of the checking code lines and maybe primitive type checking package like is-boolean, is-number,... But of course, we should do it later :D

@coveralls
Copy link

coveralls commented Apr 15, 2021

Pull Request Test Coverage Report for Build 279

  • 154 of 154 (100.0%) changed or added relevant lines in 24 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.1%) to 100.0%

Totals Coverage Status
Change from base Build 277: 1.1%
Covered Lines: 345
Relevant Lines: 345

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 266

  • 88 of 88 (100.0%) changed or added relevant lines in 23 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-1.2%) to 97.718%

Totals Coverage Status
Change from base Build 264: -1.2%
Covered Lines: 346
Relevant Lines: 349

💛 - Coveralls

@nam-hle nam-hle marked this pull request as ready for review April 17, 2021 07:33

const config = makeConfig(rows, userConfig);

rows = truncateTableData(rows, config);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old version is:

rows = truncateTableData(data, config);

But I think it is a suitable modification :)

Comment on lines +27 to +41
const openRed = '\u001b[31m';
const closeRed = '\u001b[39m';
describe('subject is lesser than the chunk size', () => {
it.skip('returns subject in a single chunk', () => {
expect(wrapString(chalk.red('aaa'), 3)).to.deep.equal([
'\u001B[31m\u001B[31m\u001B[31m\u001B[31m\u001B[31maaa\u001B[39m',
it('returns subject in a single chunk', () => {
expect(wrapString(`${openRed}aa${closeRed}`, 3)).to.deep.equal([
`${openRed}aa${closeRed}`,
]);
});
});
describe('subject is larger than the chunk size', () => {
it.skip('returns subject sliced into multiple chunks', () => {
expect(wrapString(chalk.red('aaabbbc'), 3)).to.deep.equal([
'\u001B[31m\u001B[31m\u001B[31m\u001B[31m\u001B[31maaa\u001B[39m',
'\u001B[31m\u001B[31m\u001B[31m\u001B[31m\u001B[31mbbb\u001B[39m',
'\u001B[31m\u001B[31m\u001B[31m\u001B[31m\u001B[31mc\u001B[39m',
it('returns subject sliced into multiple chunks', () => {
expect(wrapString(`${openRed}aaabbbc${closeRed}`, 3)).to.deep.equal([
`${openRed}aaa${closeRed}`,
`${openRed}bbb${closeRed}`,
`${openRed}c${closeRed}`,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a workaround for the unexpected behaviors of chalk while testing.

@gajus gajus merged commit 803fe15 into gajus:master Apr 19, 2021
@gajus
Copy link
Owner

gajus commented Apr 19, 2021

🥳

@gajus
Copy link
Owner

gajus commented Apr 19, 2021

🎉 This PR is included in version 6.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Apr 19, 2021
@nam-hle
Copy link
Collaborator Author

nam-hle commented Apr 19, 2021

Awesome 🤩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants