Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

arturovt
Copy link
Member

In this commit, we remove constructor parameters to ensure compatibility with the useDefineForClassFields compiler option. When public class fields are enabled, such cases throw a TS2729: Property used before its initialization error. This occurs when a property (e.g., an injectee) is referenced before the constructor is executed.

Additionally, we are removing property decorators such as @Inject with this change. Property decorators are not permitted when experimental decorators are disabled. This adjustment helps make the framework compatible with these TypeScript compiler options moving forward.

In this commit, we remove constructor parameters to ensure compatibility with the
`useDefineForClassFields` compiler option. When public class fields are enabled, such cases
throw a `TS2729: Property used before its initialization` error.
This occurs when a property (e.g., an injectee) is referenced before the constructor is executed.

Additionally, we are removing property decorators such as `@Inject` with this change.
Property decorators are not permitted when experimental decorators are disabled.
This adjustment helps make the framework compatible with these TypeScript compiler
options moving forward.
@nx-cloud
Copy link

nx-cloud bot commented Nov 18, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 67204a8. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 4 targets

Sent with 💌 from NxCloud.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 18, 2024

Open in Stackblitz

@ngxs/devtools-plugin

yarn add https://pkg.pr.new/@ngxs/[email protected]

@ngxs/form-plugin

yarn add https://pkg.pr.new/@ngxs/[email protected]

@ngxs/hmr-plugin

yarn add https://pkg.pr.new/@ngxs/[email protected]

@ngxs/router-plugin

yarn add https://pkg.pr.new/@ngxs/[email protected]

@ngxs/storage-plugin

yarn add https://pkg.pr.new/@ngxs/[email protected]

@ngxs/store

yarn add https://pkg.pr.new/@ngxs/[email protected]

@ngxs/websocket-plugin

yarn add https://pkg.pr.new/@ngxs/[email protected]

commit: 67204a8

@bundlemon
Copy link

bundlemon bot commented Nov 18, 2024

BundleMon

Unchanged files (6)
Status Path Size Limits
fesm2022/ngxs-store.mjs
100.72KB 103KB / +0.5%
fesm2022/ngxs-store-internals.mjs
11.33KB 13KB / +0.5%
fesm2022/ngxs-store-internals-testing.mjs
6.83KB 7KB / +0.5%
fesm2022/ngxs-store-operators.mjs
6.22KB 7KB / +0.5%
fesm2022/ngxs-store-plugins.mjs
2.04KB 3KB / +0.5%
fesm2022/ngxs-store-experimental.mjs
1.4KB 2KB / +0.5%

No change in files bundle size

Unchanged groups (2)
Status Path Size Limits
@ngxs/store(esm2022)[gzip]
./esm2022/**/*.mjs
224.43KB +1%
@ngxs/store(fesm2022)[gzip]
./fesm2022/*.mjs
30.84KB +1%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@bundlemon
Copy link

bundlemon bot commented Nov 18, 2024

BundleMon (NGXS Plugins)

Unchanged files (9)
Status Path Size Limits
Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin.m
js
4.09KB +0.5%
Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin.mjs
3.01KB +0.5%
Plugins(fesm2022)[gzip]
hmr-plugin/fesm2022/ngxs-hmr-plugin.mjs
2.61KB +0.5%
Plugins(fesm2022)[gzip]
websocket-plugin/fesm2022/ngxs-websocket-plug
in.mjs
2.58KB +0.5%
Plugins(fesm2022)[gzip]
form-plugin/fesm2022/ngxs-form-plugin.mjs
2.52KB +0.5%
Plugins(fesm2022)[gzip]
devtools-plugin/fesm2022/ngxs-devtools-plugin
.mjs
2.17KB +0.5%
Plugins(fesm2022)[gzip]
logger-plugin/fesm2022/ngxs-logger-plugin.mjs
2.03KB +0.5%
Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin-i
nternals.mjs
875B +0.5%
Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin-int
ernals.mjs
411B +0.5%

No change in files bundle size

Unchanged groups (1)
Status Path Size Limits
All Plugins(fesm2022)[gzip]
./-plugin/fesm2022/.mjs
20.28KB +0.5%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@bundlemon
Copy link

bundlemon bot commented Nov 18, 2024

BundleMon (Integration Projects)

Unchanged files (3)
Status Path Size Limits
Main bundles(Gzip)
hello-world-ng18/dist-integration/browser/mai
n-(hash).js
71.49KB +1%
Main bundles(Gzip)
hello-world-ng17/dist-integration/main.(hash)
.js
68.38KB +1%
Main bundles(Gzip)
hello-world-ng16/dist-integration/main.(hash)
.js
67.45KB +1%

No change in files bundle size

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@arturovt arturovt marked this pull request as ready for review November 18, 2024 13:10
@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit fac2e57 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 95.3% (0.0% change).

View more on Code Climate.

@arturovt arturovt merged commit c73c22f into master Nov 18, 2024
2 of 5 checks passed
@arturovt arturovt deleted the refactor/inject-ctors branch November 18, 2024 13:11
@kewur
Copy link

kewur commented Mar 12, 2025

im on v19 and if I have useDefineForClassFields: true, I still get the "TS2729: Property store is used before its initialization." error. If I set it back to false, it worksa as intended

was this commit addressing that isuse?

this is my tsconfig for reference

/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "strict": true,
    "noImplicitOverride": true,
    "strictPropertyInitialization": false,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "sourceMap": true,
    "declaration": false,
    "experimentalDecorators": true,
    "useDefineForClassFields": true,
    "moduleResolution": "bundler",
    "importHelpers": true,
    "target": "ES2022",
    "module": "ES2022",
    "lib": ["ES2022", "dom"],
    "paths": {
      "@ng-bootstrap/ng-bootstrap": ["../dist/ng-bootstrap"]
    }
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants