google / google/closure-compiler

Losing type information - "Property get never defined on formData of type FormData"

Open
#2,436 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Hi all,

I'm getting some strange compiler warnings. It's like the compiler forgets the externs for FormData - see here:

```
[npm 04/13/17 2:30:27] nps-plugin/index.js:150: WARNING - Property get never defined on formData of type FormData
[npm 04/13/17 2:30:27] this.userName || formData.get('user_name'),
[npm 04/13/17 2:30:27] ^^^^^^^^^^^^
[npm 04/13/17 2:30:27]
[npm 04/13/17 2:30:27] nps-plugin/index.js:152: WARNING - Property get never defined on formData of type FormData
[npm 04/13/17 2:30:27] formData.get('score'),
[npm 04/13/17 2:30:27] ^^^^^^^^^^^^
[npm 04/13/17 2:30:27]
[npm 04/13/17 2:30:27] nps-plugin/index.js:153: WARNING - Property get never defined on formData of type FormData
[npm 04/13/17 2:30:27] this.productId || formData.get('product_id'),
[npm 04/13/17 2:30:27] ^^^^^^^^^^^^
[npm 04/13/17 2:30:27]
[npm 04/13/17 2:30:27] nps-plugin/index.js:154: WARNING - Property get never defined on formData of type FormData
[npm 04/13/17 2:30:27] formData.get('comments')));
```

I'm not sure if it's related, but the properties on the Form elements `elements` property seem to be obfuscated as well:

I have to use `form.elements['score'].value` rather than what I had before, which was `form.elements.score.value`. Come to think of it, since the "score" element is dynamically defined (and thusly the compiler'd have no way of preserving the token), I have no idea why that was working before...

Here's my compiler info:

*VERSION*: 20161201.0.0

*FLAGS*:
java -jar
node_modules/google-closure-compiler/compiler.jar
--js="nps-plugin/index.js"
--js="node_modules/google-closure-library/closure/goog/.js"
--js="!node_modules/google-closure-library/closure/goog/_test.js"
--dependency_mode=STRICT
--compilation_level=ADVANCED_OPTIMIZATIONS
--entry_point=lnkd.NpsPlugin
--output_wrapper="(function(){%output%})();"
--new_type_inf
--jscomp_warning=newCheckTypes
--jscomp_off=newCheckTypesExtraChecks
--hide_warnings_for=node_modules/google-closure-library/
--output_manifest="build/report/manifest.MF"
--js_output_file=nps-plugin.js

Let me know if you can help... thanks so much!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.