- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: typescript-code-style/no-inferrable-types
Language: TypeScript
Severity: Notice
Category: Best Practices
When you set an initial primitive value to a TypeScript parameter, property, or variable their respective type can be inferred. Explicitly adding type annotations in some cases can make your code more verbose and prevent TypeScript from inferring a more specific literal type.
const a: bigint = 10n;
const a: bigint = -10n;
const a: bigint = BigInt(10);
const a: bigint = -BigInt(10);
const a: bigint = BigInt?.(10);
const a: bigint = -BigInt?.(10);
const a: boolean = false;
const a: boolean = true;
const a: boolean = Boolean(null);
const a: boolean = Boolean?.(null);
const a: boolean = !0;
const a: number = 10;
const a: number = +10;
const a: number = -10;
const a: number = Number("1");
const a: number = +Number("1");
const a: number = -Number("1");
const a: number = Number?.("1");
const a: number = +Number?.("1");
const a: number = -Number?.("1");
const a: number = Infinity;
const a: number = +Infinity;
const a: number = -Infinity;
const a: number = NaN;
const a: number = +NaN;
const a: number = -NaN;
const a: null = null;
const a: RegExp = /a/;
const a: RegExp = RegExp("a");
const a: RegExp = RegExp?.("a");
const a: RegExp = new RegExp("a");
const a: string = "str";
const a: string = 'str';
const a: string = `str`;
const a: string = String(1);
const a: string = String?.(1);
const a: symbol = Symbol("a");
const a: symbol = Symbol?.("a");
const a: undefined = undefined;
const a: undefined = void someValue;
const a = 10n;
const a = -10n;
const a = BigInt(10);
const a = -BigInt(10);
const a = BigInt?.(10);
const a = -BigInt?.(10);
const a = false;
const a = true;
const a = Boolean(null);
const a = Boolean?.(null);
const a = !0;
const a = 10;
const a = +10;
const a = -10;
const a = Number("1");
const a = +Number("1");
const a = -Number("1");
const a = Number?.("1");
const a = +Number?.("1");
const a = -Number?.("1");
const a = Infinity;
const a = +Infinity;
const a = -Infinity;
const a = NaN;
const a = +NaN;
const a = -NaN;
const a = null;
const a = /a/;
const a = RegExp("a");
const a = RegExp?.("a");
const a = new RegExp("a");
const a = "str";
const a = 'str';
const a = `str`;
const a = String(1);
const a = String?.(1);
const a = Symbol("a");
const a = Symbol?.("a");
const a = undefined;
const a = void someValue;