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

Fixes #8: Migrate code base to TypeScript #9

Merged
merged 1 commit into from
Mar 31, 2022
Merged

Conversation

baltpeter
Copy link
Member

This results in a (slight) external API change:

website previously did imports like this:

import { formatAddress, stripTags } from 'letter-generator/utility';
import Letter from 'letter-generator/Letter';
import Template from 'letter-generator/Template';

We don't support that anymore, you now need to import like this:

import { Letter, Template, formatAddress, stripTags } from 'letter-generator';

So, I think it would make sense to start a new major version for this.

@baltpeter
Copy link
Member Author

So, I think it would make sense to start a new major version for this.

Although, to be fair, manually importing from package files instead of the package itself is kind of like using private APIs and you really have to expect that to break in future versions. Eh, anyway.

Copy link
Member

@zner0L zner0L left a comment

Choose a reason for hiding this comment

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

Looks good :)

src/types.d.ts Outdated Show resolved Hide resolved
src/Letter.ts Show resolved Hide resolved
// The `marginTop` is missing in the type definitions.
type PdfMakeSignature = (ContentText | ContentImage) & { marginTop: number };

const _parseTags = (content: string) => {
Copy link
Member

Choose a reason for hiding this comment

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

This could use a return type.

Copy link
Member Author

Choose a reason for hiding this comment

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

Anything wrong with the inferred type? Looks fine to me.

Copy link
Member

@zner0L zner0L Mar 31, 2022

Choose a reason for hiding this comment

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

I like the code to be expressive actually.

}

/** Render the letter as a string, used e.g. for emails. */
toString() {
Copy link
Member

Choose a reason for hiding this comment

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

This also (even though it is obvious).

Copy link
Member Author

Choose a reason for hiding this comment

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

Same here. TS infers string just fine. I'm not a big fan of being unnecessarily explicit with types when TS can infer them correctly.

src/Letter.ts Outdated Show resolved Hide resolved
src/Letter.ts Outdated Show resolved Hide resolved
This results in a (slight) external API change:

`website` previously did imports like this:

```js
import { formatAddress, stripTags } from 'letter-generator/utility';
import Letter from 'letter-generator/Letter';
import Template from 'letter-generator/Template';
```

We don't support that anymore, you now need to import like this:

```js
import { Letter, Template, formatAddress, stripTags }
    from 'letter-generator';
```

So, I think it would make sense to start a new major version for this.
@baltpeter baltpeter requested a review from zner0L March 29, 2022 20:38
@zner0L zner0L merged commit e234c08 into master Mar 31, 2022
@zner0L zner0L deleted the b_ts-conversion branch March 31, 2022 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants