-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Webpack complain about d.ts #16907
Comments
Hello, Sameish issue here, my ambiant typings file is not found anymore when compiling. I am using the ambiant definition file below :
This file is referenced in my top level tsconfig file Everything worked fine with the latest 8.x version but is not working anymore since the migration. |
@Seemspyo, Can you setup a minimal repro please? You can read here why this is needed. A good way to make a minimal repro is to create a new app via This might be related to your directory structure so its really important to get an accurate repro to diagnose this. |
I think there is my same problem try to add this in tsconfig.app.json "include": [
"**/*.d.ts"
] |
@alan-agius4 The weird thing is, I have simular project that have type definitions in subdirectory here. But in that project build command working fine. So my wild guess is this might be a lazy loading module issue in route setting. @Toso82 "include": [
"src/**/*.d.ts"
] Also I have added |
Hi @Seemspyo, I tried to build both your applications and I didn't manage to replicate the error
|
@alan-agius4 First, I have to say thank you for your affort. Both $ ng build --prod
ERROR in ./src/app/account/my-account/my-account.component.ts
Module not found: Error: Can't resolve '../@types' in 'D:\Projects\eunsatio.io\front-end\blog\src\app\account\my-account'
resolve '../@types' in 'D:\Projects\eunsatio.io\front-end\blog\src\app\account\my-account'
using description file: D:\Projects\eunsatio.io\front-end\blog\package.json (relative path: ./src/app/account/my-account)
Field 'browser' doesn't contain a valid alias configuration
using description file: D:\Projects\eunsatio.io\front-end\blog\package.json (relative path: ./src/app/account/@types)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.ts doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.tsx doesn't exist
.mjs
Field 'browser' doesn't contain a valid alias configuration
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.mjs doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.js doesn't exist
as directory
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types doesn't exist
[D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types]
[D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.ts]
[D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.tsx]
[D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.mjs]
[D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.js]
@ ./src/app/account/my-account/my-account.component.ts 8:0-50
@ ./src/app/account/account-routing.module.ts
@ ./src/app/account/account.module.ts
@ ./src/app/app-routing.module.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
ERROR in ./src/app/account/sign-up/sign-up.component.ts
Module not found: Error: Can't resolve '../@types' in 'D:\Projects\eunsatio.io\front-end\blog\src\app\account\sign-up'
resolve '../@types' in 'D:\Projects\eunsatio.io\front-end\blog\src\app\account\sign-up'
using description file: D:\Projects\eunsatio.io\front-end\blog\package.json (relative path: ./src/app/account/sign-up)
Field 'browser' doesn't contain a valid alias configuration
using description file: D:\Projects\eunsatio.io\front-end\blog\package.json (relative path: ./src/app/account/@types)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.ts doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.tsx doesn't exist
.mjs
Field 'browser' doesn't contain a valid alias configuration
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.mjs doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.js doesn't exist
as directory
D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types doesn't exist
[D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types]
[D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.ts]
[D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.tsx]
[D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.mjs]
[D:\Projects\eunsatio.io\front-end\blog\src\app\account\@types.js]
@ ./src/app/account/sign-up/sign-up.component.ts 7:0-50
@ ./src/app/account/account-routing.module.ts
@ ./src/app/account/account.module.ts
@ ./src/app/app-routing.module.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts |
@Seemspyo as a workaround you can try to rename to |
I followed these steps and was able to reproduce:
|
I can also confirm that renaming the file from But I can't reproduce this without |
Seems to be related specifically to the
Removing the reference also removes the error. |
Tried to get the compilation result for
@alan-agius4 could the changes in #16822 have caused this behaviour? |
@filipesilva that change takes only effect when That being said, I’ll need to take a deeper look in the coming days to confirm if this is indeed ta regression caused by that change. |
Looked a bit at this and it seems that this regression has been caused by the introduction of https://github.com/angular/angular-cli/blob/2f1a9db87235907b86a6cb21977427ba415903bf/packages/ngtools/webpack/src/transformers/remove-ivy-jit-support-calls.ts When the transformer runs the |
I digged a bit deeper and the issue seems to be caused that the However, when having a syntax like the below; import { AccountComponentChild } from '../@types';
export class SignUpComponent implements AccountComponentChild{} The |
Great work getting to the bottom of this @alan-agius4! Maybe our elider should ignore type args, if that's feasible. |
@filipesilva seeing the TS implementation of their internal helpers it should be /* @internal */
function isTypeReferenceType(node) {
return node.kind === 168 /* TypeReference */ || node.kind === 215 /* ExpressionWithTypeArguments */;
}
ts.isTypeReferenceType = isTypeReferenceType; |
Running the `remove-ivy-jit-support-calls` and `remove_decorators` transformers causes the following TS bug microsoft/TypeScript#17552 which is why the `elide-imports` transformer exists in the first place. However, when having a syntax like the below; ```ts import { AccountComponentChild } from '../@types'; export class SignUpComponent implements AccountComponentChild{} ``` The `implements` parts of the class is called a `HeritageClause` with child statements of `ExpressionWithTypeArguments` also the same is for `abstract`. With this change we check the token of the `HeritageClause` and if it's an `ImplementsKeyword` we elide the import. Closes #16907
Running the `remove-ivy-jit-support-calls` and `remove_decorators` transformers causes the following TS bug microsoft/TypeScript#17552 which is why the `elide-imports` transformer exists in the first place. However, when having a syntax like the below; ```ts import { AccountComponentChild } from '../@types'; export class SignUpComponent implements AccountComponentChild{} ``` The `implements` parts of the class is called a `HeritageClause` with child statements of `ExpressionWithTypeArguments` also the same is for `abstract`. With this change we check the token of the `HeritageClause` and if it's an `ImplementsKeyword` we elide the import. Closes #16907
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Running the `remove-ivy-jit-support-calls` and `remove_decorators` transformers causes the following TS bug microsoft/TypeScript#17552 which is why the `elide-imports` transformer exists in the first place. However, when having a syntax like the below; ```ts import { AccountComponentChild } from '../@types'; export class SignUpComponent implements AccountComponentChild{} ``` The `implements` parts of the class is called a `HeritageClause` with child statements of `ExpressionWithTypeArguments` also the same is for `abstract`. With this change we check the token of the `HeritageClause` and if it's an `ImplementsKeyword` we elide the import. Closes angular#16907
🐞 Bug report
Command (mark with an
x
)ng build --prod
Is this a regression?
Yes, the previous version in which this bug was not present was: 8.2.14Description
I have updated my project to 9.0.0 and this happend.
I have component with type imports from
'../@types.d.ts'
, but when run build, CLI throw an error that can't resolve'../@types'
(+Field 'browser' doesn't contain a valid alias configuration
). If I fixed it like'../@types.d'
it passes, but throw another error which'../@types.d.ts' is missing from typescript compilation
and I should include it's path.But things doesn't workout even though I add path to both
tsconfig.json
andtsconfig.app.json
.Is it because of the ivy typescript and webpack configuration?
🔬 Minimal Reproduction
🔥 Exception or Error
🌍 Your Environment
Anything else relevant?
The text was updated successfully, but these errors were encountered: