티스토리 뷰
Argument of type partial is not assignable to parameter of type
I am trying to update partial property of one of interface in TypeScript as below interface details{ name: string, phonenumber: number, IsActive: boolean } let pDt: Partial<details> = {
stackoverflow.com
typescript 사용중 해당 type의 value를 optional하게 지정해야 될 때가 있다.
Partial<T>로 지정할수 있다.
예시
type obj = {
isSuccess: boolean,
tokenCnt: number
}
// compile 에러 발생 x
const obj = Partial<obj> = {
isSuccess: false
}
하지만, partial type을 일반 type을 가진 변수나 파라미터에 할당 해야 하는 경우도 생긴다.
이런 경우에는 간단하게 as 를 추가하면 된다.
예시
interface Details{
name: string,
phonenumber: number,
IsActive: boolean
}
let partialDetails: Partial<Details> = {IsActive: false};
let details: Details = partialDetails as Details;
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 394. decode string js
- next.js glsl
- react leva
- react 3d animation
- attempted import error: bvh_struct_definitions' is not exported from './gpu/bvhshaderglsl.js' (imported as 'bvhshaderglsl').
- rollup react.js npm
- leva
- [leetcode] 394. decode string
- [leetcode] 394. decode string js
- eslint
- typescript gsls
- vue3
- 394. decode string javascript
- rollup typescript
- react three fiber
- webpack glsl
- ts glsl
- react 3d 에니메이션
- vue
- react 3d text
- next.js import glsl
- rollup typescript react
- rollup ts react npm
- Vue.js
- react glsl
- three.js leva
- react three fiber leva
- react fiber 3d
- react 3d
- 394 decode string
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
글 보관함