How do I use @types/fhir in angular cli project











up vote
0
down vote

favorite












When i npm install this library into my cli project and try to reference the types within it i get this:



 error TS2306: File 'C:/ng-ikr-lib-test/node_modules/@types/fhir/index.d.ts' is not a module.


Here is my tsconfig:



{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}


and my app tsconfig which extends the above.



{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"types": ["fhir"]
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}


How are you supposed to use the types defined in this library in an angular-cli app?



https://www.npmjs.com/package/@types/fhir










share|improve this question
























  • care to provide a reason for the downvote?
    – cobolstinks
    Aug 2 at 20:54










  • I wonder, would you need to install this, too? Usually, you need the library, and the types together. I have never used this library, so this is a guess. The docs seem a little light on the subject.
    – R. Richards
    Aug 2 at 22:19















up vote
0
down vote

favorite












When i npm install this library into my cli project and try to reference the types within it i get this:



 error TS2306: File 'C:/ng-ikr-lib-test/node_modules/@types/fhir/index.d.ts' is not a module.


Here is my tsconfig:



{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}


and my app tsconfig which extends the above.



{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"types": ["fhir"]
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}


How are you supposed to use the types defined in this library in an angular-cli app?



https://www.npmjs.com/package/@types/fhir










share|improve this question
























  • care to provide a reason for the downvote?
    – cobolstinks
    Aug 2 at 20:54










  • I wonder, would you need to install this, too? Usually, you need the library, and the types together. I have never used this library, so this is a guess. The docs seem a little light on the subject.
    – R. Richards
    Aug 2 at 22:19













up vote
0
down vote

favorite









up vote
0
down vote

favorite











When i npm install this library into my cli project and try to reference the types within it i get this:



 error TS2306: File 'C:/ng-ikr-lib-test/node_modules/@types/fhir/index.d.ts' is not a module.


Here is my tsconfig:



{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}


and my app tsconfig which extends the above.



{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"types": ["fhir"]
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}


How are you supposed to use the types defined in this library in an angular-cli app?



https://www.npmjs.com/package/@types/fhir










share|improve this question















When i npm install this library into my cli project and try to reference the types within it i get this:



 error TS2306: File 'C:/ng-ikr-lib-test/node_modules/@types/fhir/index.d.ts' is not a module.


Here is my tsconfig:



{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}


and my app tsconfig which extends the above.



{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"types": ["fhir"]
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}


How are you supposed to use the types defined in this library in an angular-cli app?



https://www.npmjs.com/package/@types/fhir







angular fhir






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 2 at 22:03

























asked Aug 2 at 20:38









cobolstinks

2,24693859




2,24693859












  • care to provide a reason for the downvote?
    – cobolstinks
    Aug 2 at 20:54










  • I wonder, would you need to install this, too? Usually, you need the library, and the types together. I have never used this library, so this is a guess. The docs seem a little light on the subject.
    – R. Richards
    Aug 2 at 22:19


















  • care to provide a reason for the downvote?
    – cobolstinks
    Aug 2 at 20:54










  • I wonder, would you need to install this, too? Usually, you need the library, and the types together. I have never used this library, so this is a guess. The docs seem a little light on the subject.
    – R. Richards
    Aug 2 at 22:19
















care to provide a reason for the downvote?
– cobolstinks
Aug 2 at 20:54




care to provide a reason for the downvote?
– cobolstinks
Aug 2 at 20:54












I wonder, would you need to install this, too? Usually, you need the library, and the types together. I have never used this library, so this is a guess. The docs seem a little light on the subject.
– R. Richards
Aug 2 at 22:19




I wonder, would you need to install this, too? Usually, you need the library, and the types together. I have never used this library, so this is a guess. The docs seem a little light on the subject.
– R. Richards
Aug 2 at 22:19












2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










The easiest way I've found is to reference the types with the following line at the top of your file:



///<referencepath="../../../node_modules/@types/fhir/index.d.ts"/>


For example, the references at the top of my fhir.service.ts file look like this:



///<reference path="../../../../node_modules/@types/fhir/index.d.ts"/>
import {Injectable} from '@angular/core';
import {Observable, throwError} from 'rxjs';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';

import Patient = fhir.Patient;
import Observation = fhir.Observation;
import Bundle = fhir.Bundle;
import Medication = fhir.Medication;


You can find out more background information at https://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html under the "Consuming Dependencies" section.






share|improve this answer





















  • Thanks, it seems like it boils down to the library author's style of packaging this library. It's packaged as a global library instead and thus needs the /// reference nasties. I ended up repackaging this library up so it doesn't run under the global scope. Thanks!
    – cobolstinks
    Aug 10 at 23:44










  • @cobolstinks Is your repackaged library available on npm?
    – Brandon
    Nov 20 at 17:21










  • @Brandon it's on an internal artifact repository.... I'll have to poke around at the license and see if I can publish the repackaged library to the public npm registry.
    – cobolstinks
    Nov 20 at 17:43












  • @cobolstinks that would be amazingly helpful if possible
    – Brandon
    Nov 20 at 18:30










  • @Brandon it's MIT so I should be ok, I'll try to publish it out tonight.
    – cobolstinks
    Nov 20 at 22:54


















up vote
1
down vote













If others stumble upon this, I published a repackaged version of this library to the public npm registry. You can find it here:



https://www.npmjs.com/package/fhir-stu3



Cheers.






share|improve this answer





















  • THANK YOU! This will be very helpful to those of us working with FHIR responses in Angular. Much appreciated!
    – Brandon
    Nov 21 at 14:18










  • You're welcome, glad I could help. I know this problem drove me nuts for awhile.
    – cobolstinks
    Nov 21 at 14:32











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51661818%2fhow-do-i-use-types-fhir-in-angular-cli-project%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










The easiest way I've found is to reference the types with the following line at the top of your file:



///<referencepath="../../../node_modules/@types/fhir/index.d.ts"/>


For example, the references at the top of my fhir.service.ts file look like this:



///<reference path="../../../../node_modules/@types/fhir/index.d.ts"/>
import {Injectable} from '@angular/core';
import {Observable, throwError} from 'rxjs';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';

import Patient = fhir.Patient;
import Observation = fhir.Observation;
import Bundle = fhir.Bundle;
import Medication = fhir.Medication;


You can find out more background information at https://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html under the "Consuming Dependencies" section.






share|improve this answer





















  • Thanks, it seems like it boils down to the library author's style of packaging this library. It's packaged as a global library instead and thus needs the /// reference nasties. I ended up repackaging this library up so it doesn't run under the global scope. Thanks!
    – cobolstinks
    Aug 10 at 23:44










  • @cobolstinks Is your repackaged library available on npm?
    – Brandon
    Nov 20 at 17:21










  • @Brandon it's on an internal artifact repository.... I'll have to poke around at the license and see if I can publish the repackaged library to the public npm registry.
    – cobolstinks
    Nov 20 at 17:43












  • @cobolstinks that would be amazingly helpful if possible
    – Brandon
    Nov 20 at 18:30










  • @Brandon it's MIT so I should be ok, I'll try to publish it out tonight.
    – cobolstinks
    Nov 20 at 22:54















up vote
1
down vote



accepted










The easiest way I've found is to reference the types with the following line at the top of your file:



///<referencepath="../../../node_modules/@types/fhir/index.d.ts"/>


For example, the references at the top of my fhir.service.ts file look like this:



///<reference path="../../../../node_modules/@types/fhir/index.d.ts"/>
import {Injectable} from '@angular/core';
import {Observable, throwError} from 'rxjs';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';

import Patient = fhir.Patient;
import Observation = fhir.Observation;
import Bundle = fhir.Bundle;
import Medication = fhir.Medication;


You can find out more background information at https://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html under the "Consuming Dependencies" section.






share|improve this answer





















  • Thanks, it seems like it boils down to the library author's style of packaging this library. It's packaged as a global library instead and thus needs the /// reference nasties. I ended up repackaging this library up so it doesn't run under the global scope. Thanks!
    – cobolstinks
    Aug 10 at 23:44










  • @cobolstinks Is your repackaged library available on npm?
    – Brandon
    Nov 20 at 17:21










  • @Brandon it's on an internal artifact repository.... I'll have to poke around at the license and see if I can publish the repackaged library to the public npm registry.
    – cobolstinks
    Nov 20 at 17:43












  • @cobolstinks that would be amazingly helpful if possible
    – Brandon
    Nov 20 at 18:30










  • @Brandon it's MIT so I should be ok, I'll try to publish it out tonight.
    – cobolstinks
    Nov 20 at 22:54













up vote
1
down vote



accepted







up vote
1
down vote



accepted






The easiest way I've found is to reference the types with the following line at the top of your file:



///<referencepath="../../../node_modules/@types/fhir/index.d.ts"/>


For example, the references at the top of my fhir.service.ts file look like this:



///<reference path="../../../../node_modules/@types/fhir/index.d.ts"/>
import {Injectable} from '@angular/core';
import {Observable, throwError} from 'rxjs';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';

import Patient = fhir.Patient;
import Observation = fhir.Observation;
import Bundle = fhir.Bundle;
import Medication = fhir.Medication;


You can find out more background information at https://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html under the "Consuming Dependencies" section.






share|improve this answer












The easiest way I've found is to reference the types with the following line at the top of your file:



///<referencepath="../../../node_modules/@types/fhir/index.d.ts"/>


For example, the references at the top of my fhir.service.ts file look like this:



///<reference path="../../../../node_modules/@types/fhir/index.d.ts"/>
import {Injectable} from '@angular/core';
import {Observable, throwError} from 'rxjs';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';

import Patient = fhir.Patient;
import Observation = fhir.Observation;
import Bundle = fhir.Bundle;
import Medication = fhir.Medication;


You can find out more background information at https://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html under the "Consuming Dependencies" section.







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 3 at 19:51









Kevin Dufendach

8814




8814












  • Thanks, it seems like it boils down to the library author's style of packaging this library. It's packaged as a global library instead and thus needs the /// reference nasties. I ended up repackaging this library up so it doesn't run under the global scope. Thanks!
    – cobolstinks
    Aug 10 at 23:44










  • @cobolstinks Is your repackaged library available on npm?
    – Brandon
    Nov 20 at 17:21










  • @Brandon it's on an internal artifact repository.... I'll have to poke around at the license and see if I can publish the repackaged library to the public npm registry.
    – cobolstinks
    Nov 20 at 17:43












  • @cobolstinks that would be amazingly helpful if possible
    – Brandon
    Nov 20 at 18:30










  • @Brandon it's MIT so I should be ok, I'll try to publish it out tonight.
    – cobolstinks
    Nov 20 at 22:54


















  • Thanks, it seems like it boils down to the library author's style of packaging this library. It's packaged as a global library instead and thus needs the /// reference nasties. I ended up repackaging this library up so it doesn't run under the global scope. Thanks!
    – cobolstinks
    Aug 10 at 23:44










  • @cobolstinks Is your repackaged library available on npm?
    – Brandon
    Nov 20 at 17:21










  • @Brandon it's on an internal artifact repository.... I'll have to poke around at the license and see if I can publish the repackaged library to the public npm registry.
    – cobolstinks
    Nov 20 at 17:43












  • @cobolstinks that would be amazingly helpful if possible
    – Brandon
    Nov 20 at 18:30










  • @Brandon it's MIT so I should be ok, I'll try to publish it out tonight.
    – cobolstinks
    Nov 20 at 22:54
















Thanks, it seems like it boils down to the library author's style of packaging this library. It's packaged as a global library instead and thus needs the /// reference nasties. I ended up repackaging this library up so it doesn't run under the global scope. Thanks!
– cobolstinks
Aug 10 at 23:44




Thanks, it seems like it boils down to the library author's style of packaging this library. It's packaged as a global library instead and thus needs the /// reference nasties. I ended up repackaging this library up so it doesn't run under the global scope. Thanks!
– cobolstinks
Aug 10 at 23:44












@cobolstinks Is your repackaged library available on npm?
– Brandon
Nov 20 at 17:21




@cobolstinks Is your repackaged library available on npm?
– Brandon
Nov 20 at 17:21












@Brandon it's on an internal artifact repository.... I'll have to poke around at the license and see if I can publish the repackaged library to the public npm registry.
– cobolstinks
Nov 20 at 17:43






@Brandon it's on an internal artifact repository.... I'll have to poke around at the license and see if I can publish the repackaged library to the public npm registry.
– cobolstinks
Nov 20 at 17:43














@cobolstinks that would be amazingly helpful if possible
– Brandon
Nov 20 at 18:30




@cobolstinks that would be amazingly helpful if possible
– Brandon
Nov 20 at 18:30












@Brandon it's MIT so I should be ok, I'll try to publish it out tonight.
– cobolstinks
Nov 20 at 22:54




@Brandon it's MIT so I should be ok, I'll try to publish it out tonight.
– cobolstinks
Nov 20 at 22:54












up vote
1
down vote













If others stumble upon this, I published a repackaged version of this library to the public npm registry. You can find it here:



https://www.npmjs.com/package/fhir-stu3



Cheers.






share|improve this answer





















  • THANK YOU! This will be very helpful to those of us working with FHIR responses in Angular. Much appreciated!
    – Brandon
    Nov 21 at 14:18










  • You're welcome, glad I could help. I know this problem drove me nuts for awhile.
    – cobolstinks
    Nov 21 at 14:32















up vote
1
down vote













If others stumble upon this, I published a repackaged version of this library to the public npm registry. You can find it here:



https://www.npmjs.com/package/fhir-stu3



Cheers.






share|improve this answer





















  • THANK YOU! This will be very helpful to those of us working with FHIR responses in Angular. Much appreciated!
    – Brandon
    Nov 21 at 14:18










  • You're welcome, glad I could help. I know this problem drove me nuts for awhile.
    – cobolstinks
    Nov 21 at 14:32













up vote
1
down vote










up vote
1
down vote









If others stumble upon this, I published a repackaged version of this library to the public npm registry. You can find it here:



https://www.npmjs.com/package/fhir-stu3



Cheers.






share|improve this answer












If others stumble upon this, I published a repackaged version of this library to the public npm registry. You can find it here:



https://www.npmjs.com/package/fhir-stu3



Cheers.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 at 3:50









cobolstinks

2,24693859




2,24693859












  • THANK YOU! This will be very helpful to those of us working with FHIR responses in Angular. Much appreciated!
    – Brandon
    Nov 21 at 14:18










  • You're welcome, glad I could help. I know this problem drove me nuts for awhile.
    – cobolstinks
    Nov 21 at 14:32


















  • THANK YOU! This will be very helpful to those of us working with FHIR responses in Angular. Much appreciated!
    – Brandon
    Nov 21 at 14:18










  • You're welcome, glad I could help. I know this problem drove me nuts for awhile.
    – cobolstinks
    Nov 21 at 14:32
















THANK YOU! This will be very helpful to those of us working with FHIR responses in Angular. Much appreciated!
– Brandon
Nov 21 at 14:18




THANK YOU! This will be very helpful to those of us working with FHIR responses in Angular. Much appreciated!
– Brandon
Nov 21 at 14:18












You're welcome, glad I could help. I know this problem drove me nuts for awhile.
– cobolstinks
Nov 21 at 14:32




You're welcome, glad I could help. I know this problem drove me nuts for awhile.
– cobolstinks
Nov 21 at 14:32


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51661818%2fhow-do-i-use-types-fhir-in-angular-cli-project%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Berounka

Sphinx de Gizeh

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...