-
Notifications
You must be signed in to change notification settings - Fork 10
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
[Feature]: Migrating nested type definitions from v2 to v3 #225
Comments
Yes. The transformation for top-level Input/Output types was added in #209 Most of the type definitions are same between v2 and v3. Some of them are not required like:
We'll have to write a script, similar to generateNewClientTests, which reads models from v2 and creates a mapping of types between v2 and v3. |
I posted a draft PR providing an example of complex case of type differences between v2 and v3. |
Support for basic type definitions was added in #276, and released in https://github.com/awslabs/aws-sdk-js-codemod/releases/tag/v0.8.0 $ npx aws-sdk-js-codemod --version
aws-sdk-js-codemod: 0.8.1
jscodeshift: 0.14.0
- babel: 7.20.5
- babylon: 7.20.5
- flow: 0.196.1
- recast: 0.21.5
$ cat example.ts
import { S3 } from "aws-sdk";
const testTags: S3.Tag[] = [{ Key: "abc", Value: "value" }];
$ npx aws-sdk-js-codemod -t v2-to-v3 example.ts
$ cat example.ts
import AWS_S3, { S3 } from "@aws-sdk/client-s3";
const testTags: AWS_S3.Tag[] = [{ Key: "abc", Value: "value" }]; |
For supporting these transformation, the solution we internally agreed on is to create a data structure which stores types in v2 which are either native types, or a superset of native types as follows:
The codemod will check if the key exists in v2 application code, and add equivalent native type in generated v3 application code, likely in https://github.com/awslabs/aws-sdk-js-codemod/blob/d16d0daf27a06a6c2686e179457d0fdc89f23347/src/transforms/v2-to-v3/ts-type/getV3ClientTypeName.ts#L16C3-L18 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Self-service
Test Comand
Input code
Current Output
Expected Output
Additional context
Would it be possible to migrate the import of Typescript type definitions from v2 to v3?
My project has a global store that uses the AWS SDK types to store objects and tags. During migration, it'll be great to also have those types updated to their v3 references.
The text was updated successfully, but these errors were encountered: