Angular8 firebase configuration error '#angular/fire/angularfire2' - javascript

When trying to 'ng serve' after configuring angular with firebase, I got the error. Even though I googled this error message but could not find anything. In the error message, this issue is related to the library itself.
user#user-MacBookPro post % ng serve
10% building 3/3 modules 0 activeℹ 「wds」: Project is running at http://localhost:4200/webpack-dev-server/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: 404s will fallback to //index.html
chunk {main} main.js, main.js.map (main) 2.15 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 127 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 9.78 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 340 kB [initial] [rendered]
Date: 2020-02-10T01:58:36.888Z - Hash: 259e06990402b2940abe - Time: 3542ms
ERROR in node_modules/#angular/fire/angularfire2.d.ts:37:49 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
Type 'T[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]' is not assignable to type '(...args: any) => any'.
Type 'T[T[keyof T] extends Function ? keyof T : never]' is not assignable to type '(...args: any) => any'.
Type 'T[keyof T]' is not assignable to type '(...args: any) => any'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
Type 'T[string]' is not assignable to type '(...args: any) => any'.
37 [K in FunctionPropertyNames<T>]: ReturnType<T[K]> extends Promise<any> ? K : never;
~~~~
node_modules/#angular/fire/angularfire2.d.ts:40:49 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
Type 'T[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]' is not assignable to type '(...args: any) => any'.
Type 'T[T[keyof T] extends Function ? keyof T : never]' is not assignable to type '(...args: any) => any'.
Type 'T[keyof T]' is not assignable to type '(...args: any) => any'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
Type 'T[string]' is not assignable to type '(...args: any) => any'.
40 [K in FunctionPropertyNames<T>]: ReturnType<T[K]> extends Promise<any> ? never : K;
~~~~
node_modules/#angular/fire/angularfire2.d.ts:48:78 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
Type 'T[{ [K in { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]: ReturnType<T[K]> extends Promise<any> ? never : K; }[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]]' is not assignable to type '(...args: any) => any'.
Type 'T[ReturnType<T[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]> extends Promise<any> ? never : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]' is not assignable to type '(...args: any) => any'.
Type 'T[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]' is not assignable to type '(...args: any) => any'.
Type 'T[T[keyof T] extends Function ? keyof T : never]' is not assignable to type '(...args: any) => any'.
Type 'T[keyof T]' is not assignable to type '(...args: any) => any'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
Type 'T[string]' is not assignable to type '(...args: any) => any'.
48 [K in NonPromiseReturningFunctionPropertyNames<T>]: (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>>;
~~~~
node_modules/#angular/fire/angularfire2.d.ts:48:107 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
Type 'T[{ [K in { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]: ReturnType<T[K]> extends Promise<any> ? never : K; }[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]]' is not assignable to type '(...args: any) => any'.
Type 'T[ReturnType<T[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]> extends Promise<any> ? never : { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]' is not assignable to type '(...args: any) => any'.
Type 'T[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]' is not assignable to type '(...args: any) => any'.
Type 'T[T[keyof T] extends Function ? keyof T : never]' is not assignable to type '(...args: any) => any'.
Type 'T[keyof T]' is not assignable to type '(...args: any) => any'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
Type 'T[string]' is not assignable to type '(...args: any) => any'.
48 [K in NonPromiseReturningFunctionPropertyNames<T>]: (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>>;
~~~~
node_modules/#angular/fire/angularfire2.d.ts:50:75 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
Type 'T[{ [K in { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]: ReturnType<T[K]> extends Promise<any> ? K : never; }[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]]' is not assignable to type '(...args: any) => any'.
Type 'T[ReturnType<T[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]> extends Promise<any> ? { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T] : never]' is not assignable to type '(...args: any) => any'.
Type 'T[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]' is not assignable to type '(...args: any) => any'.
50 [K in PromiseReturningFunctionPropertyNames<T>]: (...args: Parameters<T[K]>) => ReturnType<T[K]>;
~~~~
node_modules/#angular/fire/angularfire2.d.ts:50:96 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
Type 'T[{ [K in { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]: ReturnType<T[K]> extends Promise<any> ? K : never; }[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]]' is not assignable to type '(...args: any) => any'.
Type 'T[ReturnType<T[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]> extends Promise<any> ? { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T] : never]' is not assignable to type '(...args: any) => any'.
Type 'T[{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]]' is not assignable to type '(...args: any) => any'.
50 [K in PromiseReturningFunctionPropertyNames<T>]: (...args: Parameters<T[K]>) => ReturnType<T[K]>;
~~~~
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
ℹ 「wdm」: Failed to compile.
This is a package.json file. This project is based on Angular8, firebase version 6.
{
"name": "post",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "~8.2.14",
"#angular/common": "~8.2.14",
"#angular/compiler": "~8.2.14",
"#angular/core": "~8.2.14",
"#angular/fire": "^6.0.0-rc.1",
"#angular/forms": "~8.2.14",
"#angular/platform-browser": "~8.2.14",
"#angular/platform-browser-dynamic": "~8.2.14",
"#angular/router": "~8.2.14",
"firebase": "^7.8.1",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.803.24",
"#angular/cli": "~8.3.24",
"#angular/compiler-cli": "~8.2.14",
"#angular/language-service": "~8.2.14",
"#types/node": "~8.9.4",
"#types/jasmine": "~3.3.8",
"#types/jasminewd2": "~2.0.3",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3",
"#angular-devkit/architect": "^0.900.0-0 || ^0.900.0",
"firebase-tools": "^7.12.1",
"fuzzy": "^0.1.3",
"inquirer": "^6.2.2",
"inquirer-autocomplete-prompt": "^1.0.1"
}
}
import { BrowserModule } from '#angular/platform-browser';
import { NgModule } from '#angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { environment } from 'src/environments/environment';
//angular-fire
import { AngularFireModule } from "#angular/fire";
import { AngularFirestoreModule } from "#angular/fire/firestore";
// in version 6, StorageBucket changes to BUCKET
import { AngularFireStorageModule, BUCKET } from "#angular/fire/storage";
// component list
import { AddpostComponent } from "../app/addpost/addpost.component";
import { MainComponent } from "../app/main/main.component";
import { PostComponent } from "../app/post/post.component";
// forms module for AddpostComponent
import { FormsModule, ReactiveFormsModule } from "#angular/forms";
import {ServiceService } from "./service.service";
#NgModule({
declarations: [
AppComponent,
AddpostComponent,
MainComponent,
PostComponent
],
imports: [
BrowserModule,
AppRoutingModule,
AngularFireModule.initializeApp(environment.firebaseConfig),
AngularFirestoreModule,
AngularFireStorageModule,
FormsModule,
ReactiveFormsModule
],
providers: [{ provide: BUCKET, useValue: 'gs://angular-firebase-rxjs.appspot.com' }, ServiceService],
bootstrap: [AppComponent]
})
export class AppModule { }

This error is due to TypeScript type checking the definitions file of the AngularFire library.
Notice the errors are from node_modules/#angular/fire/angularfire2.d.ts:37:49.
To avoid this error you have to set some options in tsconfig.json.
tsconfig:
{
//...
compilerOptions: {
"skipLibCheck": true,
//...
}
}
skipLibCheck: Skip type checking of declaration files.
More info on the skipLibCheck option.

{
//...
compilerOptions: {
"skipLibCheck": true,
//...
}
}
this solution not advisable, its may give some build time error, i got error while build with SSR,
i can suggest you to update "rxjs": ,if your are using * version then update it to 9

Related

Define a type with only one property and the name of that property must be in a predefined set of names

Let's say I want to create an error structure that indicates if the error is on the server side or the client side. Example:
const serverErr = {
server: "Error!"
};
const clientErr = {
client: "Error!"
};
The error object must have only one property, and the name of that property must be server or client.
I tried the answer to this question question but it's not working.
According to this answer, here is the definition of IsSingleKey:
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void)
? I
: never;
type IsUnion<T> = [T] extends [UnionToIntersection<T>] ? false : true;
type ISingleKey<K extends string, T> = IsUnion<K> extends true ? "Can only contain a single key" : Record<K, T>;
One approach is to make an error type AllowedErrors which is a union of all the allowable types, each member of which has exactly one of the acceptable keys as required, and prohibits defined values for the other keys. It would look like this:
type AllowedErrors =
{ server: string; client?: never; x?: never; y?: never; z?: never; } |
{ client: string; server?: never; x?: never; y?: never; z?: never; } |
{ x: string; server?: never; client?: never; y?: never; z?: never; } |
{ y: string; server?: never; client?: never; x?: never; z?: never; } |
{ z: string; server?: never; client?: never; x?: never; y?: never; };
Note that TypeScript doesn't explicitly support prohibiting a property key, but you can make it an optional property whose value type is the impossible never type, then the only value you might find at that key would be undefined.
This should behave how you want:
const serverErr: AllowedErrors = {
server: "Error!"
};
const clientErr: AllowedErrors = {
client: "Error!"
};
const bothErr: AllowedErrors = {
server: "Error",
client: "Error"
} // error! Type '{ server: string; client: string; }'
// is not assignable to type 'AllowedErrors'
const neitherErr: AllowedErrors = {
oops: "Error"
} // Type '{ oops: string; }' is not assignable
// to type 'AllowedErrors'.
const okayErr = Math.random() < 0.5 ? { x: "" } : { y: "" };
So, that's great.
But obviously you don't want to have to write or modify your AllowedErrors type manually. You want to generate it from a union of the keys like
type AllowedErrorKeys = "server" | "client" | "x" | "y" | "z";
so that you just need to add/remove things there. Well, here's one approach:
type SingleKeyValue<K extends PropertyKey, V, KK extends PropertyKey = K> =
K extends PropertyKey ?
Record<K, V> & { [P in Exclude<KK, K>]?: never } extends infer O ?
{ [P in keyof O]: O[P] } : never : never;
The type SingleKeyValue<K, V> produces the relevant union where each member has only one allowed key from K with value type V and the remainder of the keys from K are prohibited.
First, the type is wrapped with the seemingly no-op K extends PropertyKey ? ... : never, which actually a distributive conditional type that splits K up into its individual union members, operates on each member, and then unites the results back into another union.
The inner type is essentially Record<K, V> & { [P in Exclude<KK, K>]?: never }; the first piece using the Record<K, V> utility type to represent an object with the one key from K and the value type V, which is intersected with a type prohibiting all keys from Exclude<KK, K> using the Exclude<T, U> utility type. Wait, what's KK? That's a "dummy" type parameter I declared in the outer scope which defaults to K. This is really just a trick so that K is broken into its union pieces while KK is a copy of the original union K, so that we can express "all the members of the original union except htis one".
Anyway that's the type we need except it's pretty ugly (an intersection of utility types), so I use a technique described at How can I see the full expanded contract of a Typescript type?, ... extends infer O ? { [P in keyof O]: O[P] } : never, to copy the type to another type parameter and iterate its properties with a mapped type to get a single object type.
And now we can just write
type AllowedErrors = SingleKeyValue<AllowedErrorKeys, string>;
and use IntelliSense to verify that it evaluates to
/* type AllowedErrors =
{ server: string; client?: never; x?: never; y?: never; z?: never; } |
{ client: string; server?: never; x?: never; y?: never; z?: never; } |
{ x: string; server?: never; client?: never; y?: never; z?: never; } |
{ y: string; server?: never; client?: never; x?: never; z?: never; } |
{ z: string; server?: never; client?: never; x?: never; y?: never; }*/
as desired.
Playground link to code

Dynamically import one Icon using icon-name from react-icons in nextjs/typescript

I'm trying to dynamically import an icon from react-icons following the this Nextjs instructions but I get an error.
This is my code:
import React, { Suspense } from 'react';
import dynamic from 'next/dynamic';
interface IconProps {
name: string;
}
function Icon({ name }: IconProps) {
const MyIcon = dynamic(() => import('react-icons/fi/index.js').then((mod) => mod[name]), {suspense: true});
return (
<Suspense fallback={`Loading...`}>
<MyIcon />
</Suspense>
);
}
export default Icon
This is the error:
Argument of type '() => Promise<IconType | React.ComponentClass<never, any> | React.FunctionComponent<never> | { default: React.ComponentType<never>; }>' is not assignable to parameter of type 'DynamicOptions<{}> | Loader<{}>'.
Type '() => Promise<IconType | React.ComponentClass<never, any> | React.FunctionComponent<never> | { default: React.ComponentType<never>; }>' is not assignable to type '() => LoaderComponent<{}>'.
Type 'Promise<IconType | ComponentClass<never, any> | FunctionComponent<never> | { default: ComponentType<never>; }>' is not assignable to type 'LoaderComponent<{}>'.
Type 'IconType | ComponentClass<never, any> | FunctionComponent<never> | { default: ComponentType<never>; }' is not assignable to type 'ComponentType<{}> | { default: ComponentType<{}>; }'.
Type 'ComponentClass<never, any>' is not assignable to type 'ComponentType<{}> | { default: ComponentType<{}>; }'.
Type 'ComponentClass<never, any>' is not assignable to type 'ComponentClass<{}, any>'.
Types of property 'getDerivedStateFromProps' are incompatible.
Type 'GetDerivedStateFromProps<never, any> | undefined' is not assignable to type 'GetDerivedStateFromProps<{}, any> | undefined'.
Type 'GetDerivedStateFromProps<never, any>' is not assignable to type 'GetDerivedStateFromProps<{}, any>'.
Types of parameters 'nextProps' and 'nextProps' are incompatible.
Type 'Readonly<{}>' is not assignable to type 'never'.ts(2345)
What am I doing wrong?

discord.js has error with it's own library. How do I solve this

Trying to make a new discord bot with the newest version of discord.js, but it has problems with its own library.
My other bots work fine with an older version but I'd like to use the newer one. I just don't know why it's not working
This is the only code I've written myself so far
import { Client, Intents } from "discord.js";
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS
]
});
It says it has found 4 errors. I just don't know what to do to fix them
node_modules/discord.js/typings/index.d.ts:1503:42 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MappedInteractionTypes<Cached>[T]' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is
not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel' is missing the following properties from type 'ThreadChannel': archived, archivedAt, archiveTimestamp, _createdTimestamp, and 35 more.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'VoiceChannel'.
Type 'DMChannel' is missing the following properties from type 'VoiceChannel': videoQualityMode, editable, speakable, nsfw, and 41 more.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is missing the following properties from type 'VoiceChannel': videoQualityMode, editable, speakable, setBitrate, and 8 more.
1503 } & MessageComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/discord.js/typings/index.d.ts:1511:49 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'ModalSubmitInteraction<CacheType> | MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MappedInteractionTypes<Cached>[T]' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Type 'ButtonInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'MessageComponentInteraction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is
not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'VoiceChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel,
TextBasedChannel>' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
1511 } & MessageChannelComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/discord.js/typings/index.d.ts:1518:35 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'Interaction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'GuildTextBasedChannel'. Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'VoiceChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)'
is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
1518 InteractionCollectorOptions<MappedInteractionTypes<Cached>[T]>,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/discord.js/typings/index.d.ts:1593:27 - error TS2344: Type 'MappedInteractionTypes<Cached>[T]' does not satisfy the constraint 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>> | ButtonInteraction<If<Cached, "cached", CacheType>> | SelectMenuInteraction<...> | ModalSubmitInteraction<...>' is not assignable to type 'Interaction<CacheType>'.
Type 'MessageComponentInteraction<If<Cached, "cached", CacheType>>' is not assignable to type 'Interaction<CacheType>'.
Types of property 'channel' are incompatible.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'GuildTextBasedChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'GuildTextBasedChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'GuildTextBasedChannel'. Type '[If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'DMChannel | PartialDMChannel | NewsChannel | TextChannel | ThreadChannel | VoiceChannel' is not assignable to type 'VoiceChannel'.
Type '[If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw" | "cached"] ? GuildTextBasedChannel : TextBasedChannel)'
is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
Type 'CacheTypeReducer<If<Cached, "cached", CacheType>, GuildTextBasedChannel, GuildTextBasedChannel, GuildTextBasedChannel, TextBasedChannel>' is not assignable to type 'VoiceChannel'.
Type 'GuildTextBasedChannel | ([If<Cached, "cached", CacheType>] extends ["raw"] ? GuildTextBasedChannel : [If<Cached, "cached", CacheType>] extends [...] ? GuildTextBasedChannel : TextBasedChannel)' is not assignable to type 'VoiceChannel'.
Type 'NewsChannel' is not assignable to type 'VoiceChannel'.
1593 ): InteractionCollector<MappedInteractionTypes<Cached>[T]>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 4 errors.
btw koding it in Typescript, if that makes a difference
If you got this many error but you only wrote a short amount of code, most likely the problem came from the library itself because you've modified it or something.
To fix this you need to read the first line of your error which is:
node_modules/discord.js/typings/index.d.ts, as you can see at the second folder(discord.js), the library name is discord.js, that is what you need to reinstall.
to reinstall a library, It's pretty simple, what you wanna do is to type this command in your terminal:
npm uninstall discord.js
npm install discord.js
npm uninstall <libraryName>
npm install <libraryName>
The easiest way to fix this, is by simply ignoring it. It will not affect your code in any way, it will however ignore the error. Ignore the node_modules folder
// tsconfig.json
{
// ...
"exclude": ["node_modules"] // any other ignored folders/files can be provided here
// ...
}
Just pass in an Array of the desired intents as IntentsStrings-- works just fine that way.
e.g.:
import { Client, Intents } from "discord.js";
const client = new Client({
intents: [
`GUILDS`,
`GUILD_MEMBERS`,
`GUILD_MESSAGES`,
`GUILD_MESSAGE_REACTIONS`
]
});

Getting error while setting reducers: Type 'MetaReducer<State, Action>[]' is not assignable to type 'MetaReducer<unknown, Action>[]'

I am getting the following error while attempting to set up my reducers in app.module.ts
Error: src/app/app.module.ts:72:7 - error TS2322: Type 'MetaReducer<State, Action>[]' is not assignable to type 'MetaReducer<unknown, Action>[]'.
Types of parameters 'reducer' and 'reducer' are incompatible.
Type 'unknown' is not assignable to type 'State'.
72 metaReducers,
~~~~~~~~~~~~
How do I fix it? My code is as follows:
const metaReducers: MetaReducer<State>[] = !environment.production ? [logger] : [];
interface State {
router: fromRouter.RouterReducerState<BaseRouterStoreState>;
}
const reducers: ActionReducerMap<unknown> = {};
function logger(reducer: ActionReducer<State>): ActionReducer<State> {
return (state: State | undefined, action: Action): State => {
const result = reducer(state, action);
console.groupCollapsed(action.type);
console.log('prev state', state);
console.log('action', action);
console.log('next state', result);
console.groupEnd();
return result;
};
}
#NgModule({
declarations: [AppComponent],
imports: [
StoreModule.forRoot(reducers, {
// TS2322: Type 'MetaReducer<State, Action>[]' is not assignable to type 'MetaReducer<unknown, Action>[]'. Types of parameters 'reducer' and 'reducer' are incompatible. Type 'unknown' is not assignable to type 'State'.
metaReducers,
runtimeChecks: {
strictActionImmutability: true,
strictStateImmutability: true,
},
}),
],
bootstrap: [AppComponent],
})
export class AppModule {}

TypeScript error with Symbol.species example from MDN

With this code (which is equivalent to a sample at MDN):
class MyArray<T> extends Array<T> {
static get [Symbol.species]() { return MyArray }
}
I get this error (with TypeScript 3.8.3):
Class static side 'typeof MyArray' incorrectly extends base class static side '{ isArray(arg: any): arg is any[]; readonly prototype: any[]; from<T>(arrayLike: ArrayLike<T>): T[]; from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; from<T>(iterable: Iterable<...> | ArrayLike<...>): T[]; from<T, U>(iterable: Iterable<...> | ArrayLike<...>, mapfn: (v: T, k: nu...'.
Types of property '[Symbol.species]' are incompatible.
Type 'typeof MyArray' is not assignable to type 'ArrayConstructor'.
Type 'typeof MyArray' provides no match for the signature '(arrayLength?: number | undefined): any[]'.
What could be wrong?

Categories

Resources