-
Notifications
You must be signed in to change notification settings - Fork 17
TypeScript #15
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
TypeScript #15
Conversation
Co-authored-by: Mu-An Chiou <me@muanchiou.com>
Co-authored-by: Mu-An Chiou <me@muanchiou.com>
Co-authored-by: Mu-An Chiou <me@muanchiou.com>
Co-authored-by: Mu-An Chiou <me@muanchiou.com>
Co-authored-by: Mu-An Chiou <me@muanchiou.com>
Co-authored-by: Mu-An Chiou <me@muanchiou.com>
Co-authored-by: Mu-An Chiou <me@muanchiou.com>
Co-authored-by: Mu-An Chiou <me@muanchiou.com>
Co-authored-by: Mu-An Chiou <me@muanchiou.com>
super() | ||
this.currentQuery = null | ||
this.debounceInputChange = debounce(() => fetchResults(this)) | ||
this.boundFetchResults = () => fetchResults(this) |
There was a problem hiding this comment.
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
.
@@ -74,7 +81,7 @@ async function fetchResults(remoteInput: RemoteInputElement, checkCurrentQuery: | |||
let errored = false | |||
let html = '' | |||
try { | |||
response = await fetch(url, { | |||
response = await fetch(url.toString(), { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 👍
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.