<!-- Thank you for contributing to open source! Do you need some help? ====================== The issue tracker is meant for bug reports only. This isn't the best place for support or usage questions. Questions here don't have as much visibility as they do elsewhere. Before you ask a question, here are some resources to get help first: - Read the docs: https://redux.js.org/ - Check out the troubleshooting guide: https://redux.js.org/troubleshooting - Look for/ask questions on Stack Overflow: https://stackoverflow.com/questions/tagged/redux - Ask in chat: https://www.reactiflux.com/ Think you found a bug? ====================== The best bug report is a failing test in the repository as a pull request. Otherwise, please use the template below. --> ### Prior Issues Introduced in https://github.com/reduxjs/redux/pull/3524. ### What is the current behavior? **Code** ```ts type MyEnhancerType = { enhancedStuff: number }; function createEnhancer(): StoreEnhancer<MyEnhancerType> { return (createStore) => <S, A extends Action>( reducer: Reducer<S, A>, initialState?: PreloadedState<S> ): Store<S, A, never, MyEnhancerType> & MyEnhancerType => { // This store that I just created does not have the enhancer applied to it yet // It also doesn't know what enhancers have been applied to it const nextStore = createStore(reducer, initialState); // And yet we can access a property that we have yet to add. // This should produce a type error, but it doesn't. const propertyThatsNotOnStoreYet = nextStore.enhancedStuff; // It's not until here that we have an enhanced store // And should be able to access that property const enhancedStore = enhanceStore(nextStore); const correctPropertyAccess = enhancedStore.enhancedStuff; return enhancedStore; }; } function enhanceStore<S, A extends Action>(store: Store<S, A, unknown, unknown>): Store<S, A, never, MyEnhancerType> & MyEnhancerType { return { ...store, enhancedStuff: 5, } } ``` <details><summary><b>Output</b></summary> ```ts function createEnhancer() { return (createStore) => (reducer, initialState) => { // This store that I just created does not have the enhancor applied to it yet // It also doesn't know what enhancors have been applied to it const nextStore = createStore(reducer, initialState); // And yet we can access a property that we have yet to add. const propertyThatsNotOnStoreYet = nextStore.enhancedStuff; // It's not until here that we have an enhanced store // And should be able to access that property const enhancedStore = enhanceStore(nextStore); const correctPropertyAccess = enhancedStore.enhancedStuff; return enhancedStore; }; } function enhanceStore(store) { return Object.assign(Object.assign({}, store), { enhancedStuff: 5, // Ignore this for now. See https://github.com/reduxjs/redux/issues/3767 for more discussion replaceReducer(nextReducer) { return store.replaceReducer(nextReducer); } }); } ``` </details> <details><summary><b>Compiler Options</b></summary> ```json { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true, "strictFunctionTypes": true, "strictPropertyInitialization": true, "strictBindCallApply": true, "noImplicitThis": true, "noImplicitReturns": true, "alwaysStrict": true, "esModuleInterop": true, "declaration": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "moduleResolution": 2, "target": "ES2017", "jsx": "React", "module": "ESNext" } } ``` </details> **Playground Link:** [Provided](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgQQMY2BAdgGhVgTzQ2zwBFgBnMAQxlQAs8AFKAUwBsIaATNngMow6bPACV+AV1RsoeAKpZKkgEaVUUYCrZwAvnABmUCCDgBydj0kAPMwG4AUA4D0zuIvYc2NSvzgwCMDZKBwCguABRaxg2LEFhGIAeIRE8KJilTCwAPjgAXjgAbXTYyiyAXTg2aNieSiKsNgA3WXKHODgAfjgUmPa4AC4ehJ0AMkiazOxHB2AsGKgDGhlh6DZE-oF8uBpCHH7kKsm6lHQs7eRCYiz9jt62dO3Glrl+x4KEXQdchH6eKlo9AYQwo1DojESyGyjg6AHM2DB7gAKACUQwEMLgyjUGi0bCRHCoGVkQ1R+VyTQgwB4aPcSlU6k02kx7DAHGWbAkVhkUESADk2AB3e5HDInAR4AWC67YerVMX1KFI-odRrRLnSElwDU8-lC+6SoUypTZfq0oRrRIlOL3PXCkZ4e7pbKG6VnWWOkbpNLRXLjdKY1xwZjsgiw4ySOJwHgQYJYMzwQkAax0AgIKggHAAdBA1LImjRtBxOp1+kHCmmQBns7nfFACyovOVUUMAPJ5+uFrzJaEOL6hQKpmBrCJYBi7XXvRC6T0iKfPWS5ArK1Xy9HD9ij8dYHkW9gAYXYdGgVuis5izocKPJq03Y4nsj3bEP3g3p5g54evsc1UgsH8g63g8947o+G7Pkeb5Tp8n7zs0i7bBsdzbLsBC3Cgoq1Iq7pYBcVw4d8K5wJYmpQEMOqyMkeBQuhYCeNwfDxCInRDKwnAMfwtoCKa155LkT7vrUXGwb61EiR+EwwH6kkzGEOgALIEFuD5QAAKoBHxVCBMjxJIBgGEMWCSFWsh6DMBiRjhcAaK+wHbjyLZAcpoG8opzk8upQQ-P07AwJIUC4UiNkiE+vG5FRGHylhpwkDkREdCRPLkVIuoSigLoqnAczABgNAcPcLHBvRvCcSMPZmuulppcgeALnIcBudpsieWw0mNfZzUad5HQdEGqkMFQWLgf447wAAknAABWkiUPAwUxDw0axvUWAQPA44tCNOixPZ0A7GAbLAH4w5ZfABAIplQZjfAeWUBAS1xgmcBJqtgpwIKo1abtUD1BtOjaLE+2Hcd905ZlqCyvAaqIsNBTzWwT5Iolsh4NluX5SMKIzD1cBBpci3nfAgo6Kguw7KgMiUPUNBwHREBBLABAjXQ706H9cCE-4928DwWbg5DtPGAzAT9XQlB8mtrZYE+ACaCJPPKT5ZjtD66fp2M9VdMBmCta1wJGGAcHADCyDoMCfcTxs0JtZMq6Bi2zWsl1uPjWIMBAkgcIt2g7I2ZvcxTwT1ObLN08LBD80o8B2zpT7bDHCPgUi0OhZiHQQ1H1nQOw6CsPTsgBGglP1AUCfxGsytNWrBgawlCL+bhZdPpiuiOP2Fk7rFX0PgJ1WYXE2GxdkSKO+wlXsBFNX61gL0QIKuDT7P8-ZOa4GT7V8H1e1KktW1SlNWpgG-HXfkBYgmVZpfo+iJlTd+fpQwAKz7M7cBjbCq3sCNg0GHtr1Zj0NgbMYAwDAJQAYrhYQ5QYKoLMEMQDOBItYSalBEFSGsM4KgyhgjOAAMwAHYABs+DDB7RAGsaMVBUAzTKNgTKrJ2QyAoryKUIoooDx6K6Y0cpjiKmHplVc6oUpamYXaA0cApTcNNDjVelpWEOgkUaHClAN4vDwNvFyu84DjA0R5I+AjiL1zPtfLMDCOTMOTvKZh14fBATEQoyRyjVEowavvDqh8vLaNce5TqQQ056H6F8L4QA) ### Steps to Reproduce See code above. ### What is the expected behavior? Trying to access enhanced properties right after calling `createStore` should result in a type error. ### Environment Details N/A