我想创建一个常量并使用index.ts导出它。但是当我尝试使用索引路径而不是完整的const路径加载const时,我得到错误"找不到模块./form-validation
"。
app
└───...
└───translation
│ │ translation.service.ts
│ │
│ └───form-validation
│ │ pt-BR.ts
│ │ index.ts
PT-BR.ts
export const formValidationPtBr = {
"minlength" : "tamanho"
}
index.ts
export { formValidationPtBr } from './pt-BR';
translation.service.ts
import { formValidationPtBr } from './form-validation/pt-BR'; // here the import os OK and I can access the const `formValidationPtBr`.
@Injectable()
export class TranslationService {
constructor() {
console.log(formValidationPtBr);
}
}
translation.service.ts
import { formValidationPtBr } from './form-validation'; // here the import desn't work saying "Cannot find module `./form-validation`"
@Injectable()
export class TranslationService {
constructor() {
console.log(formValidationPtBr);
}
}