../node_modules/aws-xray-sdk-core/lib/patchers/aws3_p.ts:7:40 - error TS2307: Cannot find module '@aws-sdk/config-resolver' or its corresponding type declarations.
7 import type { RegionInputConfig } from '@aws-sdk/config-resolver';
~~~~~~
../node_modules/aws-xray-sdk-core/lib/patchers/aws3_p.ts:85:43 - error TS2339: Property 'serviceId' does not exist on type 'Configuration'.
85 const serviceIdentifier = client.config.serviceId;
~~~~~
Found 2 errors.
The typescript compiler is giving the above errors on build.
I have the same error now compiling a project in typescript
Apologies for the issue! We're taking a look.
Hey everyone,
Does anyone have a clean reproduction case? Or, additional stack traces would be beneficial.
@organic-scholar @Dema1348 I'm attempting to reproduce this issue with a TypeScript sample app but am having no luck. I'm using v3.7.3 of tsc, v9.1.1 of ts-node to run my sample TypeScript app. My tsconfig.json is:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"strict": true,
"strictNullChecks": true,
"declaration": true,
"esModuleInterop": true
},
"files": ["index.ts"]
}
Can you provide the details of your setup requested by @awssandra so we can try to reproduce this locally?
@organic-scholar @Dema1348 I've released v3.3.1 which rolls back the AWS SDK V3 support and should resolve your compiler issues for now while we work to resolve the underlying issue. Please let me know if upgrading to 3.3.1 fixes this problem.
Thanks, @willarmiros v3.3.1 compiled successfully,
my project has the following ts version and config
typescript: ~3.9.7
{
"compilerOptions": {
"target": "ES2018",
"module": "CommonJS",
"lib": ["es2018"],
"declaration": false,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"incremental": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"esModuleInterop": true,
"inlineSources": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictPropertyInitialization": false,
"outDir": "build",
},
"include": ["src", "typings"]
}
Thank @willarmiros , my project now works
typescript 3.7.4
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"lib": ["ES2020.Promise"],
"skipLibCheck": true,
"allowJs": true
}
}
Thanks both for your info! I was able to reproduce the initial error posted by @organic-scholar. Interestingly, it didn't seem to have anything to do with the contents of my tsconfig, but instead depended on the version of TypeScript I was compiling with. When I compile with TypeScript 4.x, I get the errors that you've described. When compiling with TS 3.7.4 and 3.9.7, keeping everything else the same, I just get these errors:
node_modules/@aws-sdk/types/dist/types/util.d.ts:92:42 - error TS1005: ',' expected.
92 export declare type UserAgentPair = [name: string, version?: string];
~
node_modules/@aws-sdk/types/dist/types/util.d.ts:92:60 - error TS1005: ',' expected.
92 export declare type UserAgentPair = [name: string, version?: string];
~
Found 2 errors.
Which are documented in https://github.com/aws/aws-sdk-js-v3/issues/1842 and fixed for TypeScript 4.x users. So that leaves me with 2 questions:
tsc --version on your local machine.@aws-sdk/smithy-client@aws-sdk/types@aws-sdk/config-resolver@aws-sdk/node-config-providerCurrently, we only have a dev dependency on those packages because we only used them for their Types. This is fine for JavaScript consumers of the SDK because they only consume the compiled aws3_p.js file, which no longer has any dependency on these packages. But we did not account for TypeScript consumers who would pull in the original aws3_p.ts file which does have references to these modules. Including these as runtime dependencies adds a small amount of bloat (just 1 kilobyte or so per package, according to Bundlephobia) in return for reliable builds for all customers, which seems like the right tradeoff to me.
The change introduces a runtime dependency for AWS SDK v3. The team should decide what's the best route there. Introducing a runtime dependency for AWS SDK v3 could have some costs in terms of bundle size or node_modules size for users who are either not using any AWS SDK or using AWS SDK v2 (and also, are not tree-shaking their output).
Another way to accomplish this could be to move the AWS SDK v3 support to another package which can depend on both this X-Ray SDK and the AWS SDK v3 (Proof of concept needed)
About TypeScript 3, it looks like compilation fails because of the lack of support for tuples.
@juancri thanks a ton for investigating & weighing in on this. We'll have a discussion on the team to see whether to do a separate module or bundle them in the main package. I'll also discuss about having a minimum supported TS version based on those 3.x errors.
Fixed as of v3.3.3.
Most helpful comment
@juancri thanks a ton for investigating & weighing in on this. We'll have a discussion on the team to see whether to do a separate module or bundle them in the main package. I'll also discuss about having a minimum supported TS version based on those 3.x errors.