Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting type errors with Typescript version < 5 #2318

Open
nadetastic opened this issue Dec 11, 2024 · 1 comment
Open

Getting type errors with Typescript version < 5 #2318

nadetastic opened this issue Dec 11, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation sandbox Related to the sandbox experience

Comments

@nadetastic
Copy link
Member

Environment information

System:
  OS: macOS 14.7
  CPU: (11) arm64 Apple M3 Pro
  Memory: 161.77 MB / 18.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 18.20.1 - ~/.nvm/versions/node/v18.20.1/bin/node
  Yarn: 1.22.22 - ~/.nvm/versions/node/v18.20.1/bin/yarn
  npm: 10.5.0 - ~/.nvm/versions/node/v18.20.1/bin/npm
  pnpm: 9.1.2 - ~/.nvm/versions/node/v18.20.1/bin/pnpm
NPM Packages:
  @aws-amplify/auth-construct: 1.5.1
  @aws-amplify/backend: 1.9.0
  @aws-amplify/backend-auth: 1.4.2
  @aws-amplify/backend-cli: 1.4.3
  @aws-amplify/backend-data: 1.2.2
  @aws-amplify/backend-function: 1.9.0
  @aws-amplify/backend-output-schemas: 1.4.0
  @aws-amplify/backend-output-storage: 1.1.4
  @aws-amplify/backend-secret: 1.1.5
  @aws-amplify/backend-storage: 1.2.4
  @aws-amplify/cli-core: 1.2.1
  @aws-amplify/client-config: 1.5.3
  @aws-amplify/deployed-backend-client: 1.4.2
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.9
  @aws-amplify/platform-core: 1.3.0
  @aws-amplify/plugin-types: 1.6.0
  @aws-amplify/sandbox: 1.2.7
  @aws-amplify/schema-generator: 1.2.6
  aws-amplify: 6.10.2
  aws-cdk: 2.172.0
  aws-cdk-lib: 2.172.0
  typescript: 4.8.4
No AWS environment variables
No CDK environment variables

Describe the bug

Using an older version of Angular (v14) which only supports Typescript versions >=4.6.2 and <4.9.0 running the dev build throws a number of errors that all seem to be coming from @aws-amplify/data-schema, for example:

Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelIndex.d.ts:13:132 - error TS1011: An element access expression should take an argument.

13     sortKeys<FieldKeys extends ModelFieldKeys = ModelFieldKeys, const SK extends ReadonlyArray<Exclude<FieldKeys, PK>> = readonly []>(sortKeys: SK): ModelIndexType<FieldKeys, PK, SK, QueryField, K | 'sortKeys'>;
                                                                                                                                      


Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelIndex.d.ts:13:143 - error TS1005: ')' expected.

13     sortKeys<FieldKeys extends ModelFieldKeys = ModelFieldKeys, const SK extends ReadonlyArray<Exclude<FieldKeys, PK>> = readonly []>(sortKeys: SK): ModelIndexType<FieldKeys, PK, SK, QueryField, K | 'sortKeys'>;
                                                                                                                                                 ~


Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelIndex.d.ts:13:145 - error TS1434: Unexpected keyword or identifier.

13     sortKeys<FieldKeys extends ModelFieldKeys = ModelFieldKeys, const SK extends ReadonlyArray<Exclude<FieldKeys, PK>> = readonly []>(sortKeys: SK): ModelIndexType<FieldKeys, PK, SK, QueryField, K | 'sortKeys'>;
                                                                                                                                                   ~~


Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelIndex.d.ts:13:147 - error TS1128: Declaration or statement expected.

13     sortKeys<FieldKeys extends ModelFieldKeys = ModelFieldKeys, const SK extends ReadonlyArray<Exclude<FieldKeys, PK>> = readonly []>(sortKeys: SK): ModelIndexType<FieldKeys, PK, SK, QueryField, K | 'sortKeys'>;
                                                                                                                                                     ~


Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelIndex.d.ts:13:148 - error TS1128: Declaration or statement expected.

13     sortKeys<FieldKeys extends ModelFieldKeys = ModelFieldKeys, const SK extends ReadonlyArray<Exclude<FieldKeys, PK>> = readonly []>(sortKeys: SK): ModelIndexType<FieldKeys, PK, SK, QueryField, K | 'sortKeys'>;
                                                                                                                                                      ~

Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelIndex.d.ts:14:14 - error TS1005: ',' expected.

14     name(name: string): ModelIndexType<ModelFieldKeys, PK, SK, QueryField, K | 'name'>;

Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelType.d.ts:69:308 - error TS1005: ',' expected.

69     secondaryIndexes<const SecondaryIndexFields = ExtractSecondaryIndexIRFields<T>, const SecondaryIndexPKPool extends string = keyof SecondaryIndexFields & string, const Indexes extends readonly ModelIndexType<string, string, unknown, readonly [], any>[] = readonly [], const IndexesIR extends readonly any[] = SecondaryIndexToIR<Indexes, SecondaryIndexFields>>(callback: (index: <PK extends SecondaryIndexPKPool>(pk: PK) => ModelIndexType<SecondaryIndexPKPool, PK, ReadonlyArray<Exclude<SecondaryIndexPKPool, PK>>>) => Indexes): ModelType<SetTypeSubArg<T, 'secondaryIndexes', IndexesIR>, UsedMethod | 'secondaryIndexes'>;
                                                                                                                                                                                                                                                                                                                      ~


Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelType.d.ts:69:361 - error TS1005: ',' expected.

69     secondaryIndexes<const SecondaryIndexFields = ExtractSecondaryIndexIRFields<T>, const SecondaryIndexPKPool extends string = keyof SecondaryIndexFields & string, const Indexes extends readonly ModelIndexType<string, string, unknown, readonly [], any>[] = readonly [], const IndexesIR extends readonly any[] = SecondaryIndexToIR<Indexes, SecondaryIndexFields>>(callback: (index: <PK extends SecondaryIndexPKPool>(pk: PK) => ModelIndexType<SecondaryIndexPKPool, PK, ReadonlyArray<Exclude<SecondaryIndexPKPool, PK>>>) => Indexes): ModelType<SetTypeSubArg<T, 'secondaryIndexes', IndexesIR>, UsedMethod | 'secondaryIndexes'>;
                                                                                                                                                                                                                                                                                                                                                                           ~


Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelType.d.ts:69:372 - error TS1005: ')' expected.

69     secondaryIndexes<const SecondaryIndexFields = ExtractSecondaryIndexIRFields<T>, const SecondaryIndexPKPool extends string = keyof SecondaryIndexFields & string, const Indexes extends readonly ModelIndexType<string, string, unknown, readonly [], any>[] = readonly [], const IndexesIR extends readonly any[] = SecondaryIndexToIR<Indexes, SecondaryIndexFields>>(callback: (index: <PK extends SecondaryIndexPKPool>(pk: PK) => ModelIndexType<SecondaryIndexPKPool, PK, ReadonlyArray<Exclude<SecondaryIndexPKPool, PK>>>) => Indexes): ModelType<SetTypeSubArg<T, 'secondaryIndexes', IndexesIR>, UsedMethod | 'secondaryIndexes'>;
                                                                                                                                                                                                                                                                                                                                                                                      ~


Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelType.d.ts:69:529 - error TS1005: ';' expected.

69     secondaryIndexes<const SecondaryIndexFields = ExtractSecondaryIndexIRFields<T>, const SecondaryIndexPKPool extends string = keyof SecondaryIndexFields & string, const Indexes extends readonly ModelIndexType<string, string, unknown, readonly [], any>[] = readonly [], const IndexesIR extends readonly any[] = SecondaryIndexToIR<Indexes, SecondaryIndexFields>>(callback: (index: <PK extends SecondaryIndexPKPool>(pk: PK) => ModelIndexType<SecondaryIndexPKPool, PK, ReadonlyArray<Exclude<SecondaryIndexPKPool, PK>>>) => Indexes): ModelType<SetTypeSubArg<T, 'secondaryIndexes', IndexesIR>, UsedMethod | 'secondaryIndexes'>;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ~


Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelType.d.ts:69:530 - error TS1128: Declaration or statement expected.

69     secondaryIndexes<const SecondaryIndexFields = ExtractSecondaryIndexIRFields<T>, const SecondaryIndexPKPool extends string = keyof SecondaryIndexFields & string, const Indexes extends readonly ModelIndexType<string, string, unknown, readonly [], any>[] = readonly [], const IndexesIR extends readonly any[] = SecondaryIndexToIR<Indexes, SecondaryIndexFields>>(callback: (index: <PK extends SecondaryIndexPKPool>(pk: PK) => ModelIndexType<SecondaryIndexPKPool, PK, ReadonlyArray<Exclude<SecondaryIndexPKPool, PK>>>) => Indexes): ModelType<SetTypeSubArg<T, 'secondaryIndexes', IndexesIR>, UsedMethod | 'secondaryIndexes'>;

Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelType.d.ts:71:78 - error TS1005: ',' expected.

71     authorization<AuthRuleType extends Authorization<any, any, any>>(callback: (allow: Omit<AllowModifier, 'resource'>) => AuthRuleType | AuthRuleType[]): ModelType<SetTypeSubArg<T, 'authorization', AuthRuleType[]>, UsedMethod | 'authorization'>;
                                                                                ~


Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelType.d.ts:71:152 - error TS1011: An element access expression should take an argument.

71     authorization<AuthRuleType extends Authorization<any, any, any>>(callback: (allow: Omit<AllowModifier, 'resource'>) => AuthRuleType | AuthRuleType[]): ModelType<SetTypeSubArg<T, 'authorization', AuthRuleType[]>, UsedMethod | 'authorization'>;
                                                                                                                                                          


Error: node_modules/@aws-amplify/data-schema/dist/esm/ModelType.d.ts:71:154 - error TS1005: ';' expected.

71     authorization<AuthRuleType extends Authorization<any, any, any>>(callback: (allow: Omit<AllowModifier, 'resource'>) => AuthRuleType | AuthRuleType[]): ModelType<SetTypeSubArg<T, 'authorization', AuthRuleType[]>, UsedMethod | 'authorization'>;

Reproduction steps

  1. In an Angular 14 project, add Amplify Gen 2 dependencies and add data backend at minimum.
  2. Typescript version needs to be between >=4.6.2 and <4.9.0 to be compatible with Angular 14
  3. Run dev build ng serve
  4. Errors thrown in terminal
@nadetastic nadetastic added the pending-triage Incoming issues that need categorization label Dec 11, 2024
@ykethan
Copy link
Member

ykethan commented Dec 17, 2024

Hey, thank you for filing this. Marking this a documentation to update the pages.

Due to the frontend typescript version requirements, you should be able to create the backend as a separate resource with latest version of typescript.

@ykethan ykethan added documentation Improvements or additions to documentation sandbox Related to the sandbox experience and removed pending-triage Incoming issues that need categorization labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation sandbox Related to the sandbox experience
Projects
None yet
Development

No branches or pull requests

2 participants