Commit 48ff382 1 parent dcfde7f commit 48ff382 Copy full SHA for 48ff382
File tree 1 file changed +30
-0
lines changed
test/com/google/javascript/jscomp
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -364,6 +364,36 @@ public void testJsMessageOnPublicField() {
364
364
assertThat (msg .asJsMessageString ()).isEqualTo ("Greetings" );
365
365
}
366
366
367
+ @ Test
368
+ public void testJsMessageOnPublicField_directAlias () {
369
+ extractMessagesSafely (
370
+ lines (
371
+ "/** @desc Something */" ,
372
+ "const MSG_SOMETHING = goog.getMsg('Something');" ,
373
+ "class Foo {" ,
374
+ " MSG_SOMETHING = MSG_SOMETHING;" ,
375
+ "}" ));
376
+ assertThat (assertOneMessage ().getKey ()).isEqualTo ("MSG_SOMETHING" );
377
+ }
378
+
379
+ // Note: This may be undesirable but represents the current behavior.
380
+ // Ideally the assignment to this MSG in the constructor should be sufficient to avoid the error.
381
+ @ Test
382
+ public void testJsMessageOnPublicField_indirectAliasPresentlyErrors () {
383
+ extractMessages (
384
+ lines (
385
+ "/** @desc Anything */" ,
386
+ "const MSG_ANYTHING = goog.getMsg('Anything');" ,
387
+ "class Baz {" ,
388
+ " MSG_ANYTHING;" ,
389
+ " constructor() {" ,
390
+ " this.MSG_ANYTHING = MSG_ANYTHING;" ,
391
+ " }" ,
392
+ "}" ));
393
+ assertOneError (MESSAGE_HAS_NO_VALUE );
394
+ assertThat (compiler .getWarnings ()).isEmpty ();
395
+ }
396
+
367
397
@ Test
368
398
public void testErrorOnPublicFields () {
369
399
extractMessages (
You can’t perform that action at this time.
0 commit comments