test/com/google/javascript/jscomp/Es6TranspilationIntegrationTest.java
/** Check that the types from the getter/setter are copied to the declaration on the prototype. */
Check that the types from the getter/setter are copied to the declaration on the prototype.
Check that the types from the getter / setter are copied to the declaration on the prototype .
@Test
  public void testEs5GettersAndSettersClassesWithTypes() {
    setLanguageOut(LanguageMode.ECMASCRIPT5);
    test(
        "class C { /** @return {number} */ get value() { return 0; } }",
        lines(
            "/** @constructor @struct */",
            "var C = function() {};",
            "/** @type {number} */",
            "C.prototype.value;",
            "$jscomp.global.Object.defineProperties(C.prototype, {",
            "  value: {",
            "    configurable: true,",
            "    enumerable: true,",
            "    /**",
            "     * @return {number}",
            "     * @this {C}",
            "     */",
            "    get: function() {",
            "      return 0;",
            "    }",
            "  }",
            "});"));
    test(
        "class C { /** @param {string} v */ set value(v) { } }",
        lines(
            "/** @constructor @struct */",
            "var C = function() {};",
            "/** @type {string} */",
            "C.prototype.value;",
            "$jscomp.global.Object.defineProperties(C.prototype, {",
            "  value: {",
            "    configurable: true,",
            "    enumerable: true,",
            "    /**",
            "     * @this {C}",
            "     * @param {string} v",
            "     */",
            "    set: function(v) {}",
            "  }",
            "});"));
    testError(
        lines(
            "class C {",
            "  /** @return {string} */",
            "  get value() { }",
            "",
            "  /** @param {number} v */",
            "  set value(v) { }",
            "}"),
        CONFLICTING_GETTER_SETTER_TYPE);
  }
@ Test public void testEs5GettersAndSettersClassesWithTypes ( ) { setLanguageOut ( LanguageMode . ECMASCRIPT5 ) ; test ( "class C { /** @return {number} */ get value() { return 0; } }" , lines ( "/** @constructor @struct */" , "var C = function() {};" , "/** @type {number} */" , "C.prototype.value;" , "$jscomp.global.Object.defineProperties(C.prototype, {" , "  value: {" , "    configurable: true," , "    enumerable: true," , "    /**" , "     * @return {number}" , "     * @this {C}" , "     */" , "    get: function() {" , "      return 0;" , "    }" , "  }" , "});" ) ) ; test ( "class C { /** @param {string} v */ set value(v) { } }" , lines ( "/** @constructor @struct */" , "var C = function() {};" , "/** @type {string} */" , "C.prototype.value;" , "$jscomp.global.Object.defineProperties(C.prototype, {" , "  value: {" , "    configurable: true," , "    enumerable: true," , "    /**" , "     * @this {C}" , "     * @param {string} v" , "     */" , "    set: function(v) {}" , "  }" , "});" ) ) ; testError ( lines ( "class C {" , "  /** @return {string} */" , "  get value() { }" , "" , "  /** @param {number} v */" , "  set value(v) { }" , "}" ) , CONFLICTING_GETTER_SETTER_TYPE ) ; }
Check that the types from the getter/setter are copied to the declaration on the prototype.
Check that the types from the getter / setter are copied to the declaration on the prototype .