Поэтому я использую машинописный текст для проекта ASP NET MVC, машинописный текст управляет JS-интерфейсом, а также angularJs.
У меня есть папка viewmodels, содержащая много .ts
файлов. Поэтому я пытаюсь разделить их и разместить в частном пакете npm.
Затем я использую npm, чтобы загрузить их в папки node_modules
, но ссылки на эти машинные модели просмотра больше не работают.
Скажем, все ts находятся в одном пространстве имен. только одна часть является локальной папкой машинописного текста, а другая часть является папкой узловых модулей.
Действие, которое я предпринял с момента появления проблемы
- Проект включает /node_modules/@privatescope/viewmodels/*.ts, а также * .js
- Убедитесь, что пакеты нацелены на node_modules/@privatescope/viewmodels/*.js
- проект может отлаживаться и работать как предыдущий, но моя локальная машинопись не может получить правильную ссылку
Я тоже пытаюсь это сделать в моем локальном файле машинописи
/// <reference path="node_modules/@privatescope/viewmodels/CurrencyViewModel.ts" />
или даже это
var currencyViewModel = require("node_modules/@privatescope/viewmodels/CurrencyViewModel.ts")
// error here
export class CurrencyRepository extends Repository<currencyViewModel> implements IRepository<currencyViewModel>
и то, и другое не помогает мне решить проблему с ссылками и tslint.
// my tsconfig
{
"compileOnSave": true,
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"es5",
"scripthost",
"es6"
],
"module": "commonjs",
"noImplicitAny": true,
//"strictNullChecks": true,
"noEmitOnError": false,
"removeComments": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true,
},
"exclude": [
"node_modules",
"obj",
"bin"
]
}
// viewmodel in node_module
namespace test.data {
'use strict';
export class CurrencyViewModel extends CurrencyGenViewModel {
}
}
//base class also in mode_module
'use strict';
namespace test.data {
export interface IGenCurrencyViewModel {
CurrencyRates: CurrencyRateGenViewModel[];
Id: number;
Name: string;
CurrencyCode: string;
}
export class CurrencyGenViewModel implements IGenCurrencyViewModel, ICurrency {
public CurrencyRates: CurrencyRateGenViewModel[];
public Id: number;
public Name: string;
public CurrencyCode: string;
public static FIELD_CurrencyRates: string = 'CurrencyRates';
public static FIELD_Id: string = 'Id';
public static FIELD_Name: string = 'Name';
public static FIELD_CurrencyCode: string = 'CurrencyCode';
constructor() {
}
public CloneFromModel(inputModel : Currency) {
//CurrencyRateViewModel[]
this.Id = inputModel.Id;
this.Name = inputModel.Name;
this.CurrencyCode = inputModel.CurrencyCode;
}
public CloneFromViewModel(inputViewModel : CurrencyViewModel) {
if (inputViewModel.CurrencyRates != null) { this.CurrencyRates = inputViewModel.CurrencyRates; }
this.Id = inputViewModel.Id;
this.Name = inputViewModel.Name;
this.CurrencyCode = inputViewModel.CurrencyCode;
}
public GetCurrency() : Currency {
var model : Currency = {
//CurrencyRateViewModel[]
Id: this.Id,
Name: this.Name,
CurrencyCode: this.CurrencyCode,
};
return model;
}
}
}
Ищу совета, спасибо.