У меня возникли проблемы с выяснением того, как включить пользовательский файл описания машинописи в создаваемую мной библиотеку.Позвольте мне дать вам небольшой контекст.
Я пишу библиотеку для обработки ресурсов из спецификации платформы здравоохранения FHIR (http://hl7.org/fhir/).
С этой целью я создал файл d.tsуказав все ресурсы, которые я использую в своей библиотеке для обеспечения безопасности типов.
В моих ts-файлах я ссылаюсь на файл d.ts, в котором я объявил ресурсы fhir, но как только библиотека включена в пакет,и импортированный в другой проект файл объявления, содержащий мои ресурсы fhir, не найден.
Вот некоторые фрагменты кода, которые могут помочь:
fhir.d.ts
/** Module containing interfaces for all used FHIR resources in accordance with FHIR version 3.5.0 */
declare module 'fhir' {
/**
* Any combination of upper or lower case ASCII letters ('A'..'Z', and 'a'..'z', numerals ('0'..'9'), '-' and '.', with a length limit of 64 characters. (This might be an integer, an un-prefixed OID, UUID or any other identifier pattern that meets these constraints.)
*/
type id = string
/**
* A Uniform Resource Identifier Reference (RFC 3986 ). Note: URIs are case sensitive.
*/
type uri = string
/**
* A URI that refers to a canonical URI.
*/
type canonical = uri
/**
* A stream of bytes, base64 encoded (RFC 4648).
*/
type base64Binary = string
/**
* A string which has at least one character and no leading or trailing whitespace and where there is no whitespace other than single spaces in the contents
*/
type code = string
/**
* A date, or partial date (e.g. just year or year + month) as used in human communication. The format is YYYY, YYYY-MM, or YYYY-MM-DD, e.g. 2018, 1973-06, or 1905-08-23. There SHALL be no time zone.
*/
...
[shortened for brevity]
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"declaration": true,
"declarationDir": "typings",
"removeComments": false,
"module": "commonjs",
"noImplicitAny": true,
"outDir": "dist",
"target": "es5",
"lib": ["es6", "dom"],
"sourceMap": true,
"types": ["jasmine"],
"resolveJsonModule": true,
"esModuleInterop": true
},
"exclude": ["node_modules"]
}
package.json
{
"name": "<project-name>",
"version": "1.1.1",
"description": "<project-description>",
"main": "./dist/main.js",
"typings": "./typings/src/main.d.ts",
"scripts": {
"build": "npm run clean && webpack --mode production",
"clean": "rimraf dist build coverage",
"lint": "tslint --project tsconfig.json 'src/**/*.{ts,tsx}'",
"test": "karma start"
},
"devDependencies": {
"@types/es6-promise": "^3.3.0",
"@types/jasmine": "^2.5.35",
"jasmine-core": "^2.4.1",
"karma": "^2.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-typescript": "^3.0.13",
"prettier": "^1.14.3",
"ts-loader": "^5.1.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"tslint-config-standard": "^8.0.1",
"typescript": "^3.0.3",
"webpack": "^4.19.0",
"webpack-cli": "^3.1.0"
}
}
Вы можете мне помочь?