admin管理员组文章数量:1183750
I'm trying to migrate the MSAL React SPA example to a TypeScript + React Vite project. While converting the DataDisplay.jsx file, I'm encountering typing issues.
Here’s the relevant code snippet from DataDisplay.tsx
:
export const IdTokenData = (props: any) => {
const tokenClaims = createClaimsTable(props.idTokenClaims);
const tableRow = Object.keys(tokenClaims).map((key, index) => {
return (
<tr key={key}>
{tokenClaims[key].map((claimItem) => (
<td key={claimItem}>{claimItem}</td>
))}
</tr>
);
});
Element implicitly has an 'any' type because index expression is not of type 'number'.
Parameter 'claimItem' implicitly has an 'any' type.
The createClaimsTable
function used above is defined in claimUtils.js. Here's what it looks like:
export const createClaimsTable = (claims) => {
let claimsObj = {};
let index = 0;
Object.keys(claims).forEach((key) => {
if (typeof claims[key] !== 'string' && typeof claims[key] !== 'number') return;
switch (key) {
...
What are the appropriate TypeScript types for:
- The
idTokenClaims
prop inIdTokenData
? - The
createClaimsTable
function's parameter and return type?
本文标签: javascriptHow to properly type the IdTokenData function component in TypeScriptStack Overflow
版权声明:本文标题:javascript - How to properly type the IdTokenData function component in TypeScript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738305449a2073808.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论