-
Notifications
You must be signed in to change notification settings - Fork 12k
Production build errors with type-only imports inside curlys and emitDecoratorMetadata on #23667
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
Comments
For anyone else who experiences this, there is a workaround. Leave Create a new {
"extends": "./tsconfig.app.json",
"compilerOptions": {
"emitDecoratorMetadata": false
}
} And in {
"projects": {
"app": {
"architect": {
"build": {
"configurations": {
"production": {
"tsConfig": "tsconfig.app.prod.json"
}
}
}
}
}
}
} Alternatively, you can leave {
"root": true,
"extends": [],
"parserOptions": {
"emitDecoratorMetadata": true
}
} |
…DecoratorMetadata` With this change we fix an issue where type only named imports were being emitted. As a result webpack failed to resolve such symbols as they don't exist in JavaScript. Closes angular#23667
…DecoratorMetadata` With this change we fix an issue where type only named imports were being emitted. As a result webpack failed to resolve such symbols as they don't exist in JavaScript. Closes angular#23667
We are investigating a fix for the issue. However, |
…DecoratorMetadata` With this change we fix an issue where type only named imports were being emitted. As a result webpack failed to resolve such symbols as they don't exist in JavaScript. Closes #23667
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. |
…DecoratorMetadata` With this change we fix an issue where type only named imports were being emitted. As a result webpack failed to resolve such symbols as they don't exist in JavaScript. Closes angular#23667
🐞 Bug report
Command (mark with an
x
)Is this a regression?
Yes, the previous version in which this bug was not present was: ~~12.x.x~~ (we were using tslint before, so I'm not really sure)Description
A clear and concise description of the problem...🔬 Minimal Reproduction
ng new test-app
OnChanges
andSimpleChanges
as type-only imports and addsemitDecoratorMetadata: true
to tsconfig.jsonnpx ng build
(succeeds on development build)npx ng build --configuration production
:Patch for minimum reproduction:
🔥 Exception or Error
🌍 Your Environment
Anything else relevant?
The problem only exists with:
type
keyword inside the curly bracesemitDecoratorMetadata
istrue
in tsconfig.jsonDetails:
This problem happens when you use type-only imports (using the
type
keyword) using the syntax introduced in TypeScript 4.5 where you use thetype
keyword inside the curly braces:and does not happen when you use the
type
keyword outside the curly braces:We enable
emitDecoratorMetadata
in tsconfig.json due to eslint rules which require type information (otherwise it thinks DI classes in the constructor should be type-only imports, for example, but they can't be)This problem only happens with certain imports, and only with
@angular
imports. Known failing types:import { type SimpleChanges } from '@angular/core'
import { type Route } from '@angular/router'
Known types that don't cause the error:
import { type Routes, type CanLoad } from '@angular/router'
import { type OnInit, type OnChanges } from '@angular/core';
import { type HttpHeaders, type HttpParams } from '@angular/common/http'
import { type Observable } from 'rxjs'
- this works fineimport { type MyInterface } from './interface'
- this works fineThis problem only happens on production builds. Regular development builds and
ng serve
work without issue.The text was updated successfully, but these errors were encountered: