반응형

typescript 6

TypeScript에서 추상 메서드를 선언하는 중

TypeScript에서 추상 메서드를 선언하는 중 TypeScript에서 추상 메서드를 올바르게 정의하는 방법을 찾고 있습니다. 원본 상속 예를 사용하여 다음을 수행합니다. class Animal { constructor(public name) { } makeSound(input : string) : string; move(meters) { alert(this.name + " moved " + meters + "m."); } } class Snake extends Animal { constructor(name) { super(name); } makeSound(input : string) : string { return "sssss"+input; } move() { alert("Slithering...")..

programing 2023.03.27

결합 유형을 교차 유형으로 변환

결합 유형을 교차 유형으로 변환 유니언 타입을 교차 타입으로 변환하는 방법이 있습니까? type FunctionUnion = (() => void) | ((p: string) => void) type FunctionIntersection = (() => void) & ((p: string) => void) 변형을 적용하려고 합니다.FunctionUnion갖기 위해FunctionIntersection조합이 교차로 진입하길 바라나?분포 조건형이나 조건형으로부터의 추론이 그렇게 할 수 있습니다.(하지만 교차점에서 결합으로 하는 것은 불가능하다고 생각합니다만, 죄송합니다) 여기 사악한 마법이 있습니다: type UnionToIntersection = (U extends any ? (k: U)=>void : ne..

programing 2023.03.22

다른 모듈의 구성 요소 사용

다른 모듈의 구성 요소 사용 angular-cli로 생성된 Angular 2.0.0 앱을 가지고 있습니다. 를 에 할 때AppModule의 선언 배열은 모두 정상입니다. 작동하죠. 했기 에 ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★TaskModule 컴포넌트 ' ' ' 'TaskCard 를 TaskCard의 중 AppModule(the)Board★★★★★★★★★★★★★★★★★★」 앱 모듈: import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'..

programing 2023.03.17

Typescript를 사용하여 Express Request 개체 확장

Typescript를 사용하여 Express Request 개체 확장 타이프 스크립트를 사용하여 미들웨어에서 요청 개체를 표현하기 위해 속성을 추가하려고 합니다.그러나 개체에 추가 속성을 추가하는 방법을 찾을 수 없습니다.가능하면 괄호 표기법은 사용하지 않았으면 합니다. 다음과 같은 내용을 쓸 수 있는 솔루션을 찾고 있습니다(가능한 경우). app.use((req, res, next) => { req.property = setProperty(); next(); }); 사용자 정의 정의를 만들고 Typescript의 Declaration Merge(선언 병합) 기능을 사용합니다.이것은, 예를 들면, 에서 자주 사용됩니다. " " " 를 만듭니다.custom.d.ts 꼭 이 을 담으세요.tsconfig.js..

programing 2023.03.17

다른 TypeScript 파일을 Import하려면 어떻게 해야 하나요?

다른 TypeScript 파일을 Import하려면 어떻게 해야 하나요? vs.net용 TypeScript 플러그인을 사용하는 경우, 다른 TypeScript 파일에서 하나의 TypeScript 파일 Import 모듈을 선언하려면 어떻게 해야 합니까? 파일 1: module moo { export class foo ..... } 파일 2: //what goes here? class bar extends moo.foo { } 1.부터는 간단한 TypeScript를 할 수 .importES6: import { ZipCodeValidator } from "./ZipCodeValidator"; let myValidator = new ZipCodeValidator(); https://www.typescriptlan..

programing 2023.02.25

TypeScript에서 Singleton을 정의하는 방법

TypeScript에서 Singleton을 정의하는 방법 TypeScript에서 클래스에 싱글톤 패턴을 구현하는 가장 편리한 방법은 무엇입니까? (느린 초기화 여부와 관계없이)TS 2.0 이후로는 컨스트럭터에서 가시성 수식자를 정의할 수 있게 되어 다른 언어에서 익숙한 것처럼 TypeScript에서도 싱글톤을 실행할 수 있게 되었습니다. 예: class MyClass { private static _instance: MyClass; private constructor() { //... } public static get Instance() { // Do you need arguments? Make it a regular static method instead. return this._instance ||..

programing 2023.02.20
반응형