From ad0ab705b443bf2520c03fba674374d47a27be9d Mon Sep 17 00:00:00 2001 From: luhc228 Date: Tue, 13 Apr 2021 11:38:40 +0800 Subject: [PATCH 1/4] fix: render ts type --- packages/miniapp-renderer/src/miniappRenderer.ts | 2 +- .../src/generator/templates/common/render.ts.ejs | 4 ++-- packages/plugin-config/src/template/config.ts.ejs | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/miniapp-renderer/src/miniappRenderer.ts b/packages/miniapp-renderer/src/miniappRenderer.ts index ec3b48bda0..9331cc828c 100644 --- a/packages/miniapp-renderer/src/miniappRenderer.ts +++ b/packages/miniapp-renderer/src/miniappRenderer.ts @@ -50,7 +50,7 @@ function miniappRenderer( Page: PageComponent }), rootEl); - (document as any).__unmount = unmount(appInstance, rootEl); + (document as any).__unmount = unmount(appInstance); }, setDocument(value) { // eslint-disable-next-line no-global-assign diff --git a/packages/plugin-app-core/src/generator/templates/common/render.ts.ejs b/packages/plugin-app-core/src/generator/templates/common/render.ts.ejs index 9e1ce6cf4d..7cfd7a9f8a 100644 --- a/packages/plugin-app-core/src/generator/templates/common/render.ts.ejs +++ b/packages/plugin-app-core/src/generator/templates/common/render.ts.ejs @@ -8,7 +8,7 @@ }); } - export function unmount(appInstance, rootEl) { + export function unmount(appInstance) { return appInstance._internal.unmountComponent.bind(appInstance._internal); } <% } else { %> @@ -18,7 +18,7 @@ return ReactDOM.render(appInstance, rootEl); } - export function unmount(appInstance, rootEl) { + export function unmount(rootEl) { return () => ReactDOM.unmountComponentAtNode(rootEl); } <% } %> diff --git a/packages/plugin-config/src/template/config.ts.ejs b/packages/plugin-config/src/template/config.ts.ejs index 2f59e150ef..ca422e1212 100644 --- a/packages/plugin-config/src/template/config.ts.ejs +++ b/packages/plugin-config/src/template/config.ts.ejs @@ -7,8 +7,13 @@ interface Config { readonly [propName: string]: any; } +interface IUserConfig { + readonly default?: any; + readonly [key: string]: any; +} + const config: Config = { - ...(userConfig.default || {}), + ...((userConfig).default || {}), // webpack will automatically convert global to window when target is web ...(userConfig[(global as any).__app_mode__ || process.env.APP_MODE] || {}), }; From d9a871190e7342cf8808a3a587a9a856300a4296 Mon Sep 17 00:00:00 2001 From: luhc228 Date: Tue, 13 Apr 2021 11:44:22 +0800 Subject: [PATCH 2/4] fix: ts type --- packages/miniapp-renderer/CHANGELOG.md | 4 ++++ packages/plugin-app-core/CHANGELOG.md | 4 ++++ packages/plugin-config/CHANGELOG.md | 5 +++++ 3 files changed, 13 insertions(+) create mode 100644 packages/plugin-config/CHANGELOG.md diff --git a/packages/miniapp-renderer/CHANGELOG.md b/packages/miniapp-renderer/CHANGELOG.md index fdb1a1e271..91ff6a5da7 100644 --- a/packages/miniapp-renderer/CHANGELOG.md +++ b/packages/miniapp-renderer/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.9 + +- [Fix] not pass the unnecessary param `rootEl` to `unmount` function + ## 0.1.8 - [Feat] dispatch document modify when set document diff --git a/packages/plugin-app-core/CHANGELOG.md b/packages/plugin-app-core/CHANGELOG.md index c2661a7b96..e293047122 100644 --- a/packages/plugin-app-core/CHANGELOG.md +++ b/packages/plugin-app-core/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.4.3 + +- [fix] remove unused params in `unmount` function + ## 1.4.2 - [feat] support resetPageStore param diff --git a/packages/plugin-config/CHANGELOG.md b/packages/plugin-config/CHANGELOG.md new file mode 100644 index 0000000000..c3363c053d --- /dev/null +++ b/packages/plugin-config/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 1.8.1 + +- [fix] `userConfig` ts type in `config.ts.ejs` From 35c368e29b9a4e6bfc6a647b68fbab523e658281 Mon Sep 17 00:00:00 2001 From: luhc228 Date: Wed, 14 Apr 2021 12:09:21 +0800 Subject: [PATCH 3/4] chore: ignore error --- examples/basic-spa/tsconfig.json | 28 ++++++++----------- packages/miniapp-renderer/CHANGELOG.md | 4 --- .../miniapp-renderer/src/miniappRenderer.ts | 2 +- packages/plugin-app-core/CHANGELOG.md | 2 +- .../generator/templates/common/render.ts.ejs | 6 ++-- 5 files changed, 17 insertions(+), 25 deletions(-) diff --git a/examples/basic-spa/tsconfig.json b/examples/basic-spa/tsconfig.json index 504f8d8e49..4f6e7f32a0 100644 --- a/examples/basic-spa/tsconfig.json +++ b/examples/basic-spa/tsconfig.json @@ -6,13 +6,10 @@ "outDir": "build", "module": "esnext", "target": "es6", - "jsx": "react", + "jsx": "react-jsx", "moduleResolution": "node", "allowSyntheticDefaultImports": true, - "lib": [ - "es6", - "dom" - ], + "lib": ["es6", "dom"], "sourceMap": true, "allowJs": true, "rootDir": "./", @@ -22,20 +19,17 @@ "noImplicitAny": false, "importHelpers": true, "strictNullChecks": true, - "suppressImplicitAnyIndexErrors": true, + "strictFunctionTypes": true, + "strictPropertyInitialization": true, "noUnusedLocals": true, + "noUnusedParameters": true, "skipLibCheck": true, - "types": ["node", "jest"], + "types": ["node"], "paths": { - "@/*": [ - "./src/*" - ], - "ice": [ - ".ice/index.ts" - ], - "ice/*": [ - ".ice/pages/*" - ] + "@/*": ["./src/*"], + "ice": [".ice/index.ts"] } - } + }, + "include": ["src", ".ice"], + "exclude": ["node_modules", "build", "public"] } diff --git a/packages/miniapp-renderer/CHANGELOG.md b/packages/miniapp-renderer/CHANGELOG.md index 91ff6a5da7..fdb1a1e271 100644 --- a/packages/miniapp-renderer/CHANGELOG.md +++ b/packages/miniapp-renderer/CHANGELOG.md @@ -1,9 +1,5 @@ # Changelog -## 0.1.9 - -- [Fix] not pass the unnecessary param `rootEl` to `unmount` function - ## 0.1.8 - [Feat] dispatch document modify when set document diff --git a/packages/miniapp-renderer/src/miniappRenderer.ts b/packages/miniapp-renderer/src/miniappRenderer.ts index 9331cc828c..ec3b48bda0 100644 --- a/packages/miniapp-renderer/src/miniappRenderer.ts +++ b/packages/miniapp-renderer/src/miniappRenderer.ts @@ -50,7 +50,7 @@ function miniappRenderer( Page: PageComponent }), rootEl); - (document as any).__unmount = unmount(appInstance); + (document as any).__unmount = unmount(appInstance, rootEl); }, setDocument(value) { // eslint-disable-next-line no-global-assign diff --git a/packages/plugin-app-core/CHANGELOG.md b/packages/plugin-app-core/CHANGELOG.md index e293047122..5e7c8209bf 100644 --- a/packages/plugin-app-core/CHANGELOG.md +++ b/packages/plugin-app-core/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.4.3 -- [fix] remove unused params in `unmount` function +- [chore] ignore `unmount` function param never read error ## 1.4.2 diff --git a/packages/plugin-app-core/src/generator/templates/common/render.ts.ejs b/packages/plugin-app-core/src/generator/templates/common/render.ts.ejs index 7cfd7a9f8a..836a546488 100644 --- a/packages/plugin-app-core/src/generator/templates/common/render.ts.ejs +++ b/packages/plugin-app-core/src/generator/templates/common/render.ts.ejs @@ -8,7 +8,8 @@ }); } - export function unmount(appInstance) { + // @ts-ignore + export function unmount(appInstance, rootEl) { return appInstance._internal.unmountComponent.bind(appInstance._internal); } <% } else { %> @@ -18,7 +19,8 @@ return ReactDOM.render(appInstance, rootEl); } - export function unmount(rootEl) { + // @ts-ignore + export function unmount(appInstance, rootEl) { return () => ReactDOM.unmountComponentAtNode(rootEl); } <% } %> From d569e844fd7a1b8c9ac7aa75b0439c09ab8d9c19 Mon Sep 17 00:00:00 2001 From: luhc228 Date: Wed, 14 Apr 2021 12:10:19 +0800 Subject: [PATCH 4/4] chore: reset tsconfig --- examples/basic-spa/tsconfig.json | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/examples/basic-spa/tsconfig.json b/examples/basic-spa/tsconfig.json index 4f6e7f32a0..504f8d8e49 100644 --- a/examples/basic-spa/tsconfig.json +++ b/examples/basic-spa/tsconfig.json @@ -6,10 +6,13 @@ "outDir": "build", "module": "esnext", "target": "es6", - "jsx": "react-jsx", + "jsx": "react", "moduleResolution": "node", "allowSyntheticDefaultImports": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "sourceMap": true, "allowJs": true, "rootDir": "./", @@ -19,17 +22,20 @@ "noImplicitAny": false, "importHelpers": true, "strictNullChecks": true, - "strictFunctionTypes": true, - "strictPropertyInitialization": true, + "suppressImplicitAnyIndexErrors": true, "noUnusedLocals": true, - "noUnusedParameters": true, "skipLibCheck": true, - "types": ["node"], + "types": ["node", "jest"], "paths": { - "@/*": ["./src/*"], - "ice": [".ice/index.ts"] + "@/*": [ + "./src/*" + ], + "ice": [ + ".ice/index.ts" + ], + "ice/*": [ + ".ice/pages/*" + ] } - }, - "include": ["src", ".ice"], - "exclude": ["node_modules", "build", "public"] + } }