-
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
browser-esbuild target set to ES2022 and useDefineForClassFields false not working #24435
Comments
@wesselvdv can you please share your TypeScript configuration files? Can you verify that you are not explicitly setting |
@alan-agius4 I am not explicitly setting
{
"compilerOptions": {
"downlevelIteration": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"declaration": true,
"skipLibCheck": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"preserveSymlinks": true,
"moduleResolution": "node16",
"noEmit": false,
"lib": ["es2022"],
"sourceMap": true,
"declarationMap": true,
"strict": true,
"noImplicitReturns": false,
"noUnusedLocals": true,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true,
"noEmitOnError": false,
"noErrorTruncation": false,
"incremental": true,
"allowJs": false,
"checkJs": false,
"forceConsistentCasingInFileNames": true,
"suppressImplicitAnyIndexErrors": true,
"stripInternal": true,
"isolatedModules": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noUncheckedIndexedAccess": true,
"strictNullChecks": true,
"target": "ES2022",
"module": "Node16",
"typeRoots": ["./node_modules/@types"]
},
"exclude": ["node_modules", "build", "lib", "dist", ".vscode", ".direnv", ".cache"]
}
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": false,
"declarationMap": false,
"importHelpers": true,
"lib": [
"es2018",
"dom",
"dom.iterable"
],
"emitDecoratorMetadata": false,
"sourceMap": true,
"plugins": [
{
"transform": "@effect-ts/tracing-plugin"
}
]
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts",
"src/**/*.ts"
],
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"disableTypeScriptVersionCheck": true,
"strictTemplates": true
},
"references": [
{
"path": "../../packages/effect"
},
{
"path": "../../packages/graphql"
}
]
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app"
},
"exclude": ["test.ts", "**/*.spec.ts"]
}
|
I am not able to replicate this using the configuration provided. Here is the output: import {
__commonJS
} from "./chunk-RSJERJUL.js";
// src/main.ts
var require_main = __commonJS({
"src/main.ts"(exports) {
Object.defineProperty(exports, "__esModule", { value: true });
var XYZ = class extends W {
query;
whatever = this.query.watch({}, {
fetchPolicy: "network-only"
});
constructor(query) {
super();
this.query = query;
}
};
}
});
export default require_main();
//# sourceMappingURL=main.js.map Note: I noticed you are using 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 |
I think I found the culprit, I added the following overrides: "target": "ES2015",
"module": "ES2020" It now seems to give me correct output. |
closing as per above. |
The root cause of the incorrect input is that when the We only set See: https://www.typescriptlang.org/tsconfig#useDefineForClassFields |
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. |
Command
build
Is this a regression?
The previous version in which this bug was not present was
non esbuild builder
Description
I get the warning
[WARNING] [plugin angular-compiler] TypeScript compiler options "target" and "useDefineForClassFields" are set to "ES2022" and "false" respectively by the Angular CLI.
when building using browser-esbuild. But when looking at the output, it seems as if the useDefineForClassFields is set to true.This setting causes the following example to be compiled/transpiled incorrectly, causing undefined errors:
As can be seen in the above example the constructor assignment is done last. I initially thought it was due to esbuild, so I had already opened an issue there which pointed me to the typescript config. (evanw/esbuild#2738 (comment))
I am not sure if this is correct behaviour from typescript (the wrong order of assignment), or if this just isn't supported anymore?
Minimal Reproduction
Here's a typescript example with target: ES2021:
https://www.typescriptlang.org/play?useDefineForClassFields=true&target=8#code/MYGwhgzhAEAaCaAtaBTAHgFxQOwCYwHVoBvAKAAcAnASwDcwtpKUxcB7bEAT2gHcALBilopK0ALzQM-ahAB0ARwCuornN4Ng-ABSlo+kgF8ANHoNkDBgGYoMWgApsQ1YFwBc0AOTZbvNpQBrAFoObk9TSxMzAEoAblIzYA4IDEolYAx-XUsqOiEmFnZOHmVVDwBxWwBlNgBbWxlsAHMYkjN9CCVyUW04s0NSAYwubuhKjBr66WpmiWgwbC5SXBRQMGZoejECDwWloA
And here's one with ES2022 as target
https://www.typescriptlang.org/play?useDefineForClassFields=true&target=99#code/MYGwhgzhAEAaCaAtaBTAHgFxQOwCYwHVoBvAKAAcAnASwDcwtpKUxcB7bEAT2gHcALBilopK0ALzQM-ahAB0ARwCuornN4Ng-ABSlo+kgF8ANHoNkDBgGYoMWgApsQ1YFwBc0AOTZbvNpQBrAFoObk9TSxMzAEoAblIzYA4IDEolYAx-XUsqOiEmFnZOHmVVDwBxWwBlNgBbWxlsAHMYkjN9CCVyUW04s0NSAYwubuhKjBr66WpmiWgwbC5SXBRQMGZoejECDwWloA
Exception or Error
No response
Your Environment
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: