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

Cannot find name 'AggregateError'.ts(2304) #58971

Open
hungnkb opened this issue Jun 22, 2024 · 3 comments
Open

Cannot find name 'AggregateError'.ts(2304) #58971

hungnkb opened this issue Jun 22, 2024 · 3 comments
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@hungnkb
Copy link

hungnkb commented Jun 22, 2024

πŸ”Ž Search Terms

Cannot find name 'AggregateError'.ts(2304) AggregateError typescript

πŸ•— Version & Regression Information

[email protected]

⏯ Playground Link

No response

πŸ’» Code

// Your code here

πŸ™ Actual behavior

With [email protected] - in lib.es2022.error.d.ts get problems about this:
interface AggregateErrorConstructor { new ( errors: Iterable<any>, message?: string, options?: ErrorOptions, ): AggregateError; ( errors: Iterable<any>, message?: string, options?: ErrorOptions, ): AggregateError; }

I get found Cannot find name 'AggregateError'.ts(2304)
image

πŸ™‚ Expected behavior

Maybe missing include AggregateError interface?

Additional information about the issue

No response

@MartinJohns
Copy link
Contributor

What is your tsconfig looking like? Make sure your target is at least es2021.

@hungnkb
Copy link
Author

hungnkb commented Jun 22, 2024

What is your tsconfig looking like? Make sure your target is at least es2021.

my tsconfig here:
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2022",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"allowJs": true
},
"exclude": ["node_modules", "dist"]
}

Btw, im using node version 22.3

@RyanCavanaugh RyanCavanaugh added Needs Investigation This issue needs a team member to investigate its status. labels Jun 24, 2024
@RyanCavanaugh RyanCavanaugh modified the milestone: TypeScript 5.6.0 Jun 24, 2024
@rbuckton
Copy link
Member

rbuckton commented Jun 24, 2024

Odd, if you are using "target": "es2022" without a "lib": [] override, then you shouldn't be getting an error, and I wasn't able to reproduce this with only the tsconfig you provided. If you set "target": "es2022" then we load es2022 by default, es2022 loads both es2022.error and es2021, and es2021 loads es2021.promise, which contains the definition for AggregateError.

Are you using tsc to build your project, or a third-party build tool that uses the TypeScript API to build (i.e., ngc, a webpack plugin, ts-node, etc.)? If you're using a third-party build tool, I would recommend checking as to whether it is the latest version in the event the installed version might have issues with TypeScript 5.5.

If a third-party build tool was not the issue, then can you try adding "lib": ["es2022.full"] to your "compilerOptions" in tsconfig.json? If that works, then something in your dependencies might be interfering with default lib detection. If that doesn't work, then try "lib": ["es2022.full", "es2021.promise"] as a workaround and report back.

You could also try running tsc with --listFilesOnly to print a list of all files in the compilation. If es2021.promise is in that list, then I'll need to follow up with additional steps to diagnose further. If es2021.promise is not in that list, then you would need to go through all of the files in that list that come from your dependencies to see if any dependency contains the text /// <reference no-default-lib="true"/>, as that would interfere with default lib detection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

4 participants