Skip to content

Conversation

@dgraham
Copy link
Contributor

@dgraham dgraham commented Oct 17, 2019

Converts the Flow + Babel toolchain to TypeScript.

The original motivation was to be able to use private instance variables without using the # syntax, but the private modifier is a compile-time only check. We need microsoft/TypeScript#30829 before we can replace our WeakMap state pattern with private fields.

There is no escaping the # syntax.

@dgraham dgraham requested a review from a team October 17, 2019 20:01
super()
this.currentQuery = null
this.debounceInputChange = debounce(() => fetchResults(this))
this.boundFetchResults = () => fetchResults(this)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TypeScript's strict-property-initialization test caught these null instance variables previously assigned in the connectedCallback.

let html = ''
try {
response = await fetch(url, {
response = await fetch(url.toString(), {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch by TypeScript where the Fetch API doesn't accept URL values.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interestingly, fetch does accept URL values, it just implicitly casts them to string: https://twitter.com/Keithamus/status/1185127977249574912

Copy link
Contributor

@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.

Looks great 👍

@dgraham dgraham merged commit 9bf99a4 into master Oct 18, 2019
@dgraham dgraham deleted the typescript branch October 18, 2019 17:05
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