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

Replace flow + babel with tsc #15

Merged
merged 7 commits into from
Feb 20, 2020
Merged

Replace flow + babel with tsc #15

merged 7 commits into from
Feb 20, 2020

Conversation

muan
Copy link
Contributor

@muan muan commented Feb 18, 2020

This replace Flow with TypeScript and removes babel.

Ref:

@muan muan changed the base branch from test to master February 19, 2020 18:32
muan added 2 commits February 19, 2020 13:43
Note: selectionStart/End only applies to input elements of certain types
so it could be null and throws. This fallbacks to 0.
https://html.spec.whatwg.org/#do-not-apply

export default function subscribe(el: Element): Subscription {
export default function subscribe(el: HTMLElement): Subscription {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(1/2) This is to ensure event listeners are correctly typed.

const beginning = textarea.value.substring(0, textarea.selectionStart)
const remaining = textarea.value.substring(textarea.selectionEnd)
const beginning = textarea.value.substring(0, textarea.selectionStart || 0)
const remaining = textarea.value.substring(textarea.selectionEnd || 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(2/2) selectionStart and selectionEned only applies to input elements of certain types. https://html.spec.whatwg.org/#do-not-apply

@muan muan requested a review from a team February 19, 2020 18:47
@muan muan marked this pull request as ready for review February 19, 2020 18:47
const el = document.createElement('div')
el.innerHTML = html
return el.querySelector('table')
}

function hasTable(transfer: DataTransfer): ?Element {
function hasTable(transfer: DataTransfer): HTMLElement | null | void {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can avoid the void return type if you just return null instead of the bare returns in the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is edited in the followup PR.

Comment on lines +25 to +27
"dist/index.d.ts",
"dist/index.esm.js",
"dist/index.umd.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not all of dist/?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dist contains *.d.ts for all the *.ts files even though we only outputted one.


const pkg = require('./package.json')

import typescript from 'rollup-plugin-typescript2'
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am hoping that rollup-plugin-typescript2 will down the line be improved to only produce declaration for the output file. tsc would not know about the final output in that case.

Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Changes LGTM 👍

@muan muan merged commit 2e14bea into master Feb 20, 2020
@muan muan deleted the tsc branch February 24, 2020 16:33
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.

3 participants