SAP Spartacus避免不能向下兼容的breaking changes
文檔地址
以下這些都是引入了無法向下兼容的breaking changes,需要盡量避免:
- Changing the selector of a component, directive, or pipe. 更改了Component,directive或者pipe的selector
- Removing or changing the name of exported classes, functions, constants, interfaces or types in public_api.ts.
修改了定義在public_api.ts中導出的類,函數,常量,接口和類型的名稱
Note that index.ts barrels can also bubble up exports to public_api.ts.
index.ts中的類型也要特別小心。原因參考這篇文章:SAP Spartacus的API暴露邏輯和index.ts的設計原理 - 什么是所謂的PUBLIC API
-
Changing or removing interface properties. 修改或者刪除接口屬性
-
Adding new, required properties to interfaces and types. However, you can add optional properties with ?.
給接口增添了新的必需屬性。注意使用?.增添的接口屬性,不算是breaking changes. -
Changing or removing public or protected class members. 更改或者刪除public或者proected類成員。
-
Changing or removing existing public or protected function parameters. Note that changing the order also introduces a breaking change.
更改或刪除已有的public或者protected函數參數。注意修改參數的相對順序,也算breaking changes. -
Adding new, required parameters to public functions. However, you can add optional parameters to public functions.
給公有函數增添必須的參數算breaking changes. 增添optional參數不算。 -
Changing access levels on classes, functions or interfaces to a more restrictive access level. In other words, changing public to protected or private, or changing protected to private introduces a breaking change.
將類,函數和接口的restrictive access level修改成更嚴格的更改算是breaking changes, 例如從public改成protected或是private,從protected改成private.
-
Changing function’s return type form T to T | S
函數的返回類型從T改成T | S. -
Changing function behavior where the function returns different results. In other words, when changing function behavior, the function should return the same results for the same provided input as it did before the change.
對于相同的函數輸入,必須返回相同的函數輸出。 -
Changing assertions in unit tests or end-to-end tests.
單元測試或者端到端測試里的assertions發生了更改。
-
Removing anything from Angular modules, such as imports, providers, declarations, entryComponents, or exports. 刪除了Angular modules里的imports, providers, declarations, entryComponents或者exports等聲明。
-
Removing or updating existing values, or changing the order for exported enums. However, you can add new values.
刪除或修改枚舉變量值??梢孕略雒杜e變量值。 -
Changing the default value for function parameters. The default value should match the function behavior from before the change.
修改了函數參數的默認值。 -
Making any changes to the class constructor signature. Note that super calls need to be updated in classes extending ours.
修改了類構造函數的參數類型。 -
Changing the initial values of an exported class’s public or protected fields, or changing them to read-only.
修改了導出類的public和protected字段的默認值,或者將其修改成了read-only. -
Changing or removing translation keys or values.
修改或者刪除了translation keys / values. -
Changing default configurations.
-
Changing any CSS or SCSS attributes, classes or selectors.
-
Changing anything that affects the rendering of the existing DOM.
總結
以上是生活随笔為你收集整理的SAP Spartacus避免不能向下兼容的breaking changes的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎样彻底卸载(删除)SQL server
- 下一篇: 机器学习:逻辑回归(决策边界)