- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: typescript-best-practices/no-unsafe-assignment
Language: TypeScript
Severity: Warning
Category: Error Prone
The any
type in TypeScript is dangerously broad, leading to unexpected behavior. Using any
should be avoided.
const x = 1 as any;
const x = 1 as any,
function foo(a = 1 as any) {}
class Foo { constructor(private a = 1 as any) {} }
class Foo { private a = 1 as any; }
const [x] = 1 as any;
const [x] = [] as any[];
// TS treats the assignment pattern weirdly in this case
[[[[x]]]] = [1 as any];
const x = [...(1 as any)];
const x = [...([] as any[])];
const x = { y: 1 as any };
const x = { y: { z: 1 as any } };
const x = { ...(1 as any) };
<Foo a={1 as any} />;
const x = 1;
const x: number = 1;
const x = 1, y = 1;
let x;
let x = 1, y;
function foo(a = 1) {}
class Foo { constructor(private a = 1) {} }
class Foo { private a = 1; }
const x: Set<string> = new Set();
const x: Set<string> = new Set<string>();
const [x] = [1];
const [x, y] = [1, 2] as number[];
const [x, ...y] = [1, 2, 3, 4, 5];
const [x, ...y] = [1];
const [{ ...x }] = [{ x: 1 }] as [{ x: any }];
function foo(x = 1) {}
function foo([x] = [1]) {}
function foo([x, ...y] = [1, 2, 3, 4, 5]) {}
function foo([x, ...y] = [1]) {}
// this is not checked, because there's no annotation to compare it with
const x = new Set<any>();
const x = { y: 1 };
const x = { y = 1 };
const x = { y(){} };
const x: { y: number } = { y: 1 };
const x = [...[1, 2, 3]];
const [{ [`x${1}`]: x }] = [{ [`x`]: 1 }] as [{ [`x`]: any }];
|
|
For more information, please read the Code Analysis documentation
Identify code vulnerabilities directly in yourVS Code editor
Identify code vulnerabilities directly inJetBrains products