aws-amplify / aws-amplify/amplify-codegen
Angular API.service.ts TS2352 errors from codegen
- Dominant language
- TypeScript
- Stars
- 59
- Forks
- 64
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-js/issues?q=is%3Aissue+) and [discussions](https://github.com/aws-amplify/amplify-js/discussions).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-js/blob/main/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
### JavaScript Framework
Angular
### Amplify APIs
GraphQL API
### Amplify Categories
api
### Environment information
```
System:
OS: macOS 13.0.1
CPU: (10) arm64 Apple M1 Max
Memory: 14.54 GB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.12.0 - ~/.asdf/installs/nodejs/16.12.0/bin/node
Yarn: 1.22.19 - ~/.asdf/installs/nodejs/16.12.0/bin/yarn
npm: 9.1.1 - ~/.asdf/plugins/nodejs/shims/npm
Browsers:
Chrome: 107.0.5304.110
Firefox: 100.0
npmPackages:
@angular-devkit/build-angular: ^14.2.9 => 14.2.9
@angular/animations: ^14.2.0 => 14.2.10
@angular/cli: ~14.2.9 => 14.2.9
@angular/common: ^14.2.0 => 14.2.10
@angular/compiler: ^14.2.0 => 14.2.10
@angular/compiler-cli: ^14.2.0 => 14.2.10
@angular/core: ^14.2.0 => 14.2.10
@angular/forms: ^14.2.0 => 14.2.10
@angular/platform-browser: ^14.2.0 => 14.2.10
@angular/platform-browser-dynamic: ^14.2.0 => 14.2.10
@angular/router: ^14.2.0 => 14.2.10
@aws-amplify/api-graphql: ^3.0.1 => 3.0.1
@aws-amplify/auth: ^5.0.1 => 5.0.1
@aws-amplify/core: ^5.0.1 => 5.0.1
@aws-amplify/datastore: ^4.0.1 => 4.0.1
@aws-amplify/storage: ^5.0.1 => 5.0.1
@aws-amplify/ui-angular: ^3.0.0 => 3.0.0
@types/jasmine: ~4.0.0 => 4.0.3
jasmine-core: ~4.3.0 => 4.3.0
karma: ~6.4.0 => 6.4.1
karma-chrome-launcher: ~3.1.0 => 3.1.1
karma-coverage: ~2.2.0 => 2.2.0
karma-jasmine: ~5.1.0 => 5.1.0
karma-jasmine-html-reporter: ~2.0.0 => 2.0.0
rxjs: ~7.5.0 => 7.5.7 (6.6.7)
rxjs/ajax: undefined ()
rxjs/fetch: undefined ()
rxjs/internal-compatibility: undefined ()
rxjs/operators: undefined ()
rxjs/testing: undefined ()
rxjs/webSocket: undefined ()
tslib: ^2.3.0 => 2.4.1 (1.14.1)
typescript: ~4.7.2 => 4.7.4
zen-observable-ts: ^1.1.0 => 1.1.0
zone.js: ~0.11.4 => 0.11.8
npmGlobalPackages:
@angular/cli: 14.2.9
@aws-amplify/cli: 10.4.1
corepack: 0.15.1
npm-check-updates: 16.4.1
npm: 9.1.1
sass: 1.56.1
```
### Describe the bug
```shell
Error: src/app/API.service.ts:1388:12 - error TS2352: Conversion of type 'Observable> | Promise>' to type 'Observable>>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Type 'Promise>' is missing the following properties from type 'Observable>>': subscribe, forEach, map, filter, and 4 more.
1388 return API.graphql(
~~~~~~~~~~~~
1389 graphqlOperation(statement, gqlAPIServiceArguments)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
1391 SubscriptionResponse>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1392 >;
```
These repeat mostly for all GraphQLResults at bottom of file. Fails to compile.
I attempted to roll back to older versions but have not made it go away.
### Expected behavior
It compiles w/o error.
### Reproduction steps
1. Installed Node 16+, Angular 14+, Amplify CLI
2. Created ng new 14Test project
3. amplify init
4. amplify add api
5. Used graphql, boilerplate example
6. performed codegen
7. API.service.ts created
8. add to project
9. ng s -o (serve and open) - fails
I've attempted to roll back to older versions of @aws-amplify/api-graphql but that did not have any effect.
### Code Snippet
```javascript
OnCreateBlogListener(
filter?: ModelSubscriptionBlogFilterInput
): Observable<
SubscriptionResponse>
> {
const statement = `subscription OnCreateBlog($filter: ModelSubscriptionBlogFilterInput) {
onCreateBlog(filter: $filter) {
__typename
id
name
posts {
__typename
nextToken
}
createdAt
updatedAt
}
}`;
const gqlAPIServiceArguments: any = {};
if (filter) {
gqlAPIServiceArguments.filter = filter;
}
return API.graphql(
graphqlOperation(statement, gqlAPIServiceArguments)
) as Observable<
SubscriptionResponse>
>;
}
```
### Log output
```
// Put your logs below this line
```
### aws-exports.js
_No response_
### Manual configuration
_No response_
### Additional configuration
_No response_
### Mobile Device
_No response_
### Mobile Operating System
_No response_
### Mobile Browser
_No response_
### Mobile Browser Version
_No response_
### Additional information and screenshots
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.