This repository has been archived by the owner on Sep 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Compiler): Issue an error on improper
@deferred
usage.
Closes #1538. PiperOrigin-RevId: 207997994
- Loading branch information
1 parent
3db5ab8
commit a1b4b60
Showing
5 changed files
with
122 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
@TestOn('vm') | ||
import 'package:_tests/compiler.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
// See https://github.com/dart-lang/angular/issues/1538. | ||
void main() { | ||
test('should disallow @deferred on a `<template>` element', () async { | ||
await compilesExpecting(""" | ||
import '$ngImport'; | ||
@Component( | ||
selector: 'example', | ||
directives: [DeferMe], | ||
template: r''' | ||
<template @deferred> | ||
<defer-me></defer-me> | ||
</template> | ||
''', | ||
) | ||
class Example {} | ||
@Component( | ||
selector: 'defer-me', | ||
template: '', | ||
) | ||
class DeferMe {} | ||
""", errors: [ | ||
contains('Invalid @deferred annotation'), | ||
]); | ||
}); | ||
|
||
test('should disallow @deferred with a structural directive', () async { | ||
await compilesExpecting(""" | ||
import '$ngImport'; | ||
@Component( | ||
selector: 'example', | ||
directives: [DeferMe, NgIf], | ||
template: r''' | ||
<defer-me *ngIf="true" @deferred></defer-me> | ||
''', | ||
) | ||
class Example {} | ||
@Component( | ||
selector: 'defer-me', | ||
template: '', | ||
) | ||
class DeferMe {} | ||
""", errors: [ | ||
contains('Invalid @deferred annotation'), | ||
]); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters