Reputation: 11
I'm trying to integrate WebNFC in my angular project, I found only package is @types/w3c-web-nfc
but when I run application it shows me the error mentioned below:
error TS2304: Cannot find name 'NDEFReader'.
49 const ndef = new NDEFReader();
I've checked few resources that says with ssl it would work but I tried it's not working.
Any help would be highly appreciated!
Upvotes: 1
Views: 140
Reputation: 83
Angular for building use tsconfig.app.json
, you can see it in angular.json
file:
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
// ...
"tsConfig": "tsconfig.app.json",
// ...
}
where change compilerOptions
, by adding "types": []
, empty array in this option meaning that automatic inclusion of all packages in node_modules/@types has been disabled.
You have too options:
tsconfig.app.json
by adding value to "types" like this:{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": ["w3c-web-nfc"] // <==== Tell to include this types in the global scope
},
"files": ["src/main.ts", "src/polyfills.ts"],
"include": ["src/**/*.d.ts"]
}
src/@types/nfc-web.d.ts
in you project and angular automatically take them. Because of "include": ["src/**/*.d.ts"]
parameter in tsconfig.app.json
Choose prefer way for you.
Upvotes: 0