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

Add type annotations for closure-compiler support #117

Merged
merged 2 commits into from
Nov 23, 2016

Conversation

ChadKillingsworth
Copy link
Contributor

I'm using Fuse in a project with Closure-Compiler using ADVANCED optimizations. The fuse code was extremely close to being fully compatible. Just a couple type annotations are needed.

The only actual code changes required was initializing the initial options object was using reflection. I changed that in a way that is compatible with the compiler.

@@ -20,7 +20,8 @@
;(function (global) {
'use strict'

function log () {
/** @param {...*} var_args */
function log (var_args) {
Copy link
Owner

Choose a reason for hiding this comment

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

Is this change necessary? Not a huge fan of 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.

So apparently this works too - I didn't know that until I tried it just now:

/** @type {function(...*) */
function log() {}

for (i = 0, keys = ['searchFn', 'sortFn', 'keys', 'getFn', 'include', 'tokenSeparator'], len = keys.length; i < len; i++) {
key = keys[i]
this.options[key] = options[key] || defaultOptions[key]
for (key in defaultOptions) {
Copy link
Owner

Choose a reason for hiding this comment

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

Good thinking refactoring 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.

I actually didn't have a choice. Closure-compiler renames properties in ADVANCED mode and breaks these references without this refactor. Glad you like it this way.

@krisk krisk merged commit a7be77f into krisk:master Nov 23, 2016
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.

2 participants