dialogflow-javascript-client icon indicating copy to clipboard operation
dialogflow-javascript-client copied to clipboard

Typescript compilation error

Open ghost opened this issue 7 years ago • 7 comments

I using Angular 6 and after installing "api-ai-javascript": "^2.0.0-beta.14", I get the following errors when attempting ng serve or ng build: bug

Also I add api-ai-javascript index.ts to my tsconfig files include (tsconfig.app.json and tsconfig.spec.json ).

tsconfig.app.json {"extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/app", "baseUrl": "./", "module": "es2015", "types": [] }, "include": [ "/*.spec.ts", "/.d.ts", "../node_modules/api-ai-javascript/index.ts", "**/.ts" ], "exclude": [ "test.ts", "**/*.spec.ts",

]}

tsconfig.spec.json

{"extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/spec", "baseUrl": "./", "module": "commonjs", "types": [ "jasmine", "node" ] }, "files": [ "test.ts", "polyfills.ts" ], "include": [ "/*.spec.ts", "/.d.ts", "**/.ts", "../node_modules/api-ai-javascript/index.ts" ]} Really I don't know what's the problem.

ghost avatar Oct 19 '18 09:10 ghost

i am having some build error reguarding typescript complitation

Angular Version 7

ERROR in ./node_modules/api-ai-javascript/index.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: /Users/bhavyadoshi.yudiz/Downloads/chat-plugin-master/node_modules/api-ai-javascript/index.ts is missing from the TypeScript compilation. Pleasemake sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
    at AngularCompilerPlugin.getCompiledFile (/Users/bhavyadoshi.yudiz/Downloads/chat-plugin-master/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:767:23)
    at plugin.done.then (/Users/bhavyadoshi.yudiz/Downloads/chat-plugin-master/node_modules/@ngtools/webpack/src/loader.js:41:31)
    at process._tickCallback (internal/process/next_tick.js:68:7)

heynikhil avatar Nov 01 '18 14:11 heynikhil

I hope it is used for react js projects might not supported for angular

latheesh08 avatar Nov 08 '18 11:11 latheesh08

I hope it is used for react js projects might not be supported for angular

no it was supporting before

heynikhil avatar Nov 18 '18 06:11 heynikhil

I am also facing the same issue with angular 6. Can please let me know anyone of you guys @Devkoja10 @nikhil-1337 @lukesneeringer @latheesh08 @artemgoncharuk How to overcome this situation.

madhukosuri avatar Feb 13 '19 09:02 madhukosuri

@madhukosuri I'm sorry for so late response, I was away from the computer. I didn't find solution for 'dialogflow-javascript-client' that I had , but I found another solution without 'dialogflow-javascript-client'. I hope It will help.

private baseURL: string ='https://api.dialogflow.com/v1/query?v=20150910; private token: string = ''; // use your token from dialog flow`

getHeaders() { const headers = new Headers(); headers.append('Authorization', Bearer ${this.token}); return headers; }

converse(message: string) { const data = { query: message, lang: 'en', sessionId: '12345' }; this.http.post(${this.baseURL}, data, { headers: this.getHeaders() }).subscribe( res => { const speech = res.json(); }); } }

ghost avatar Feb 18 '19 08:02 ghost

Yes, @Devkoja10 Thanks for your time. It works for me.

madhukosuri avatar Feb 22 '19 08:02 madhukosuri

import { ApiAiClient } from "api-ai-javascript"; you should change this import like this for updated API-ai-javascript client -->import { ApiAiClient } from "api-ai-javascript/es6/ApiAiClient";

slvamegestic avatar Apr 08 '20 09:04 slvamegestic