我正在尝试通过 github 操作在 github 注册和 npm 注册上发布我的 npm 包。github 上的一个成功,但另一个失败了,原因如下:
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://npm.pkg.github.com/nullndr
npm ERR! need auth You need to authorize this machine using `npm adduser`
Run Code Online (Sandbox Code Playgroud)
为什么我需要npm adduser。我使用自动化令牌,这还不够吗?
这是我的工作流程文件:
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://npm.pkg.github.com/nullndr
npm ERR! need auth You need to authorize this machine using `npm adduser`
Run Code Online (Sandbox Code Playgroud)
我缺少什么?
我想从另一个类型创建一个新类型,用于Pick包含指定的属性。我发现了这个:Typescript:以目标字符串开头时排除属性键
我需要相反的。
起源:
type Origin = {
testA: string,
testB: string,
_c: string,
_d: string,
example: string,
anotherName: string,
}
Run Code Online (Sandbox Code Playgroud)
结果我会:
type Result = {
_c: string,
_d: string
};
Run Code Online (Sandbox Code Playgroud)
我尝试过
type Result = Pick<Origin, `_${string}`>
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
Type '`_${string}`' does not satisfy the constraint 'keyof Origin'
Run Code Online (Sandbox Code Playgroud) 如何定义事件处理程序:handleStatus类型:MouseEventHandler以便我可以将类型:的附加参数传递Todo给函数?
interface TodoProps {
todos: Array<Todos>
handleStatus: MouseEventHandler,
index: number,
className: string
}
export const Todo: FunctionComponent<TodoProps> = ({ todos, handleDeleteTodo, handleStatus, index, className }): ReactElement => {
const d_todo: Todos = todos[index];
return(
<>
<div className= { className } key={ todos[index].id.toString() }>
{todos[index].describtion}
<Button lable='' disabled= { false } onClick= { () => handleStatus(todos[index]) } />
</div>
</>
);
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:
ERROR in src/components/Todo.tsx:29:84
TS2345: Argument of type 'Todos' is not assignable to …Run Code Online (Sandbox Code Playgroud)