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

ERROR in node_modules/api-ai-javascript/declarations.d.ts(9,5)

Open odineshrao opened this issue 7 years ago • 15 comments

I am trying to use dialogflow in my angular 6 application. but got an error:

ERROR in node_modules/api-ai-javascript/declarations.d.ts(9,5): error TS2687: All declarations of 'speechSynthesis' must have identical modifiers. node_modules/api-ai-javascript/declarations.d.ts(9,5): error TS2717: Subsequent property declarations must have the same type. Property 'speechSynthesis' must be of type 'SpeechSynthesis', but here has type 'any'. node_modules/api-ai-javascript/ts/Request/TTSRequest.ts(18,37): error TS2339: Property 'AudioContext' does not exist on type 'Window'. node_modules/api-ai-javascript/ts/Request/TTSRequest.ts(18,53): error TS2304: Cannot find name 'webkitAudioContext'. node_modules/api-ai-javascript/ts/Stream/Processors.ts(7,16): error TS2339: Property 'AudioContext' does not exist on type 'Window'. node_modules/api-ai-javascript/ts/Stream/Processors.ts(7,38): error TS2339: Property 'AudioContext' does not exist on type 'Window'. node_modules/api-ai-javascript/ts/Stream/Processors.ts(7,54): error TS2304: Cannot find name 'webkitAudioContext'. node_modules/api-ai-javascript/ts/Stream/StreamClient.ts(60,20): error TS2339: Property 'AudioContext' does not exist on type 'Window'. node_modules/api-ai-javascript/ts/Stream/StreamClient.ts(60,42): error TS2339: Property 'AudioContext' does not exist on type 'Window'. node_modules/api-ai-javascript/ts/Stream/StreamClient.ts(60,58): error TS2304: Cannot find name 'webkitAudioContext'. node_modules/api-ai-javascript/ts/Stream/StreamClient.ts(62,53): error TS2339: Property 'webkitGetUserMedia' does not exist on type 'Navigator'. node_modules/api-ai-javascript/ts/Stream/StreamClient.ts(62,85): error TS2339: Property 'mozGetUserMedia' does not exist on type 'Navigator'. node_modules/api-ai-javascript/ts/XhrRequest.ts(105,19): error TS2304: Cannot find name 'ActiveXObject'. node_modules/api-ai-javascript/ts/XhrRequest.ts(106,19): error TS2304: Cannot find name 'ActiveXObject'. node_modules/api-ai-javascript/ts/XhrRequest.ts(107,19): error TS2304: Cannot find name 'ActiveXObject'. any solution?

odineshrao avatar Sep 19 '18 10:09 odineshrao

Same error here

hashanmalawana avatar Sep 28 '18 15:09 hashanmalawana

with typescript 3.1.2 and angular 7.0.0, error:

ERROR in node_modules/api-ai-javascript/declarations.d.ts(39,5): error TS2687: All declarations of 'stream' must have identical modifiers.

xmlking avatar Oct 10 '18 20:10 xmlking

Hi,

I had a similar issue with angular v7.0.0.rc.1 and current [email protected].

I've found out its due to conflicting type definitions for MediaStreamAudioDestinationNode#stream, between the custom version in (api-ai-javascript/declarations.d.ts) and the standard in lib.dom.d.ts (from dom types in your tsconfig.json)

One workaround is to avoid importing the library via its index.ts (which has /// <reference path="declarations.d.ts"/>), but instead use the es6 version directly by bypassing the resolution of the "api-ai-javascript" module.

So in your code:

import { ApiAiClient } from 'api-ai-javascript/es6/ApiAiClient'

in your tsconfig.json (only relevant parts):

{
  "compileOnSave": false,
  "compilerOptions": {
    ...
    "baseUrl": "./",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2017", "dom"],
    "paths": {
      "api-ai-javascript/*": ["node_modules/api-ai-javascript/es6/*"] //bypass the index.ts
    }
  }
}

The proper solution i think, would be the project's tsconfig.json to add dom type directly and remove declarations of types already in lib.dom.d.ts.

I can test that and submit a PR if you agree with this solution, @dialogflow

tinesoft avatar Oct 18 '18 08:10 tinesoft

@xmlking Hey I have the same error, did you figure out a solution?

abhinavbhandari avatar Oct 29 '18 00:10 abhinavbhandari

@abhinavbhandari did you try out my solution?

tinesoft avatar Oct 29 '18 05:10 tinesoft

I patched it using "@xmlking/api-ai-javascript": "^2.0.0-beta.22", until this lib is fixed. Working sample at https://github.com/xmlking/ngx-starter-kit

xmlking avatar Oct 29 '18 07:10 xmlking

Hi, This package(api-ai-javascript) seems to be legacy V1 SDK. Anyone point me to documentaion on using V2 Library please? I couldn't find Javascript platform in https://dialogflow.com/docs/sdks I tried to follow steps mentioned in Nodejs section in my Angular 6 client but it didn't work

ravikumarbggit avatar Oct 29 '18 12:10 ravikumarbggit

btw, @tinesoft workaround worked for me. Thanks!

ravikumarbggit avatar Oct 29 '18 12:10 ravikumarbggit

@tinesoft Hey yes I did, it didn't work but I will revisit it later and possibly ask a question later!

abhinavbhandari avatar Nov 01 '18 01:11 abhinavbhandari

Hi,

I had a similar issue with angular v7.0.0.rc.1 and current [email protected].

I've found out its due to conflicting type definitions for MediaStreamAudioDestinationNode#stream, between the custom version in (api-ai-javascript/declarations.d.ts) and the standard in lib.dom.d.ts (from dom types in your tsconfig.json)

One workaround is to avoid importing the library via its index.ts (which has /// <reference path="declarations.d.ts"/>), but instead use the es6 version directly by bypassing the resolution of the "api-ai-javascript" module.

So in your code:

import { ApiAiClient } from 'api-ai-javascript/es6/ApiAiClient'

in your tsconfig.json (only relevant parts):

{
  "compileOnSave": false,
  "compilerOptions": {
    ...
    "baseUrl": "./",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2017", "dom"],
    "paths": {
      "api-ai-javascript/*": ["node_modules/api-ai-javascript/es6/*"] //bypass the index.ts
    }
  }
}

The proper solution i think, would be the project's tsconfig.json to add dom type directly and remove declarations of types already in lib.dom.d.ts.

I can test that and submit a PR if you agree with this solution, @dialogflow

I am facing the same issue still its raising the same issue.I tried it.

All declarations of 'stream' must have identical modifiers api-ai-javascript - Dialogflow

JoelKThomas avatar Nov 22 '18 14:11 JoelKThomas

I declared stream as readonly in declarations.d.ts which worked for me.

mayurijethwa31 avatar Aug 26 '19 09:08 mayurijethwa31

i used import { ApiAiClient } from 'api-ai-javascript/es6/ApiAiClient' instead of import { ApiAiClient} from 'api-ai-javascript'; and it worked ..

PoojaChoudhury avatar Sep 10 '19 12:09 PoojaChoudhury

Hi,

Anyone please help me !!!!!!

I'm getting an error Could not find a declaration file for module 'api-ai-javascript/es6/ApiAiClient'. 'e:/AngularUI/chatbot/node_modules/api-ai-javascript/es6/ApiAiClient.js' implicitly has an 'any' type. Try npm install @types/api-ai-javascript if it exists or add a new declaration (.d.ts) file containing declare module 'api-ai-javascript/es6/ApiAiClient';ts(7016)

tsconfig.json

{ "compileOnSave": false, "compilerOptions": { "baseUrl": "./", "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "downlevelIteration": true, "experimentalDecorators": true, "module": "esnext", "moduleResolution": "node", "importHelpers": true, "target": "es2015", "lib": [ "es2018", "dom" ] }, "angularCompilerOptions": { "fullTemplateTypeCheck": true, "strictInjectionParameters": true } }

chat.service.ts

import { Injectable } from '@angular/core'; import {environment} from '../../environments/environment'; import { ApiAiClient } from 'api-ai-javascript/es6/ApiAiClient'; //Here only i'm getting error

@Injectable({ providedIn: 'root' }) export class ChatService {

readonly token = environment.dialogflow.angularBot; readonly client = new ApiAiClient({accessToken:this.token});

constructor() { }

talk(){ this.client.textRequest('Who are you!').then(res=>console.log(res)); } }

NOTE: If you know how to solve this issue contact me (+91 8681841713) I'm also available in WhatsApp My email id: [email protected]

Thanks in Advance Suhabavan.

Suhabavan avatar Jul 05 '20 19:07 Suhabavan

Had same issue with Angular 11.1.1 and Typescript 4.1.3..I tried every method above ,but still error continues.

sairam111170 avatar Feb 10 '21 04:02 sairam111170

Hi,

Anyone please help me !!!!!!

I'm getting an error Could not find a declaration file for module 'api-ai-javascript/es6/ApiAiClient'. 'e:/AngularUI/chatbot/node_modules/api-ai-javascript/es6/ApiAiClient.js' implicitly has an 'any' type. Try npm install @types/api-ai-javascript if it exists or add a new declaration (.d.ts) file containing declare module 'api-ai-javascript/es6/ApiAiClient';ts(7016)

tsconfig.json

{ "compileOnSave": false, "compilerOptions": { "baseUrl": "./", "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "downlevelIteration": true, "experimentalDecorators": true, "module": "esnext", "moduleResolution": "node", "importHelpers": true, "target": "es2015", "lib": [ "es2018", "dom" ] }, "angularCompilerOptions": { "fullTemplateTypeCheck": true, "strictInjectionParameters": true } }

chat.service.ts

import { Injectable } from '@angular/core'; import {environment} from '../../environments/environment'; import { ApiAiClient } from 'api-ai-javascript/es6/ApiAiClient'; //Here only i'm getting error

@Injectable({ providedIn: 'root' }) export class ChatService {

readonly token = environment.dialogflow.angularBot; readonly client = new ApiAiClient({accessToken:this.token});

constructor() { }

talk(){ this.client.textRequest('Who are you!').then(res=>console.log(res)); } }

NOTE: If you know how to solve this issue contact me (+91 8681841713) I'm also available in WhatsApp My email id: [email protected]

Thanks in Advance Suhabavan.

Hey did you manage to get help?

SihleMbonani avatar Oct 13 '23 21:10 SihleMbonani