NestJS fastify swagger errors while building app - node.js

I'm using fastify adapter
According to the documentation I have installed the swagger adapter for fastify
npm install --save #nestjs/swagger fastify-swagger
And when I import swagger objects
import { DocumentBuilder, SwaggerModule } from '#nestjs/swagger';
Get multiple errors in the building app stage:
node_modules/#nestjs/swagger/dist/decorators/api-body.decorator.d.ts:4:35 - error TS2304: Cannot find name 'Omit'.
4 declare type RequestBodyOptions = Omit<RequestBodyObject, 'content'>;
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-header.decorator.d.ts:3:43 - error TS2304: Cannot find name 'Omit'.
3 export interface ApiHeaderOptions extends Omit<ParameterObject, 'in'> {
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-param.decorator.d.ts:4:33 - error TS2304: Cannot find name 'Omit'.
4 declare type ParameterOptions = Omit<ParameterObject, 'in' | 'schema'>;
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-property.decorator.d.ts:2:45 - error TS2304: Cannot find name 'Omit'.
2 export interface ApiPropertyOptions extends Omit<SchemaObjectMetadata, 'name' | 'enum'> {
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-property.decorator.d.ts:8:80 - error TS2344: Type '"type" | "enum" | "example" | "format" | "deprecated"' does not satisfy the constraint '"name" | "enum"'.
Type '"type"' is not assignable to type '"name" | "enum"'.
8 export declare function ApiResponseProperty(options?: Pick<ApiPropertyOptions, 'type' | 'example' | 'format' | 'enum' | 'deprecated'>): PropertyDecorator;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/#nestjs/swagger/dist/decorators/api-query.decorator.d.ts:4:33 - error TS2304: Cannot find name 'Omit'.
4 declare type ParameterOptions = Omit<ParameterObject, 'in' | 'schema'>;
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-response.decorator.d.ts:3:46 - error TS2304: Cannot find name 'Omit'.
3 export interface ApiResponseMetadata extends Omit<ResponseObject, 'description'> {
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-response.decorator.d.ts:9:48 - error TS2304: Cannot find name 'Omit'.
9 export interface ApiResponseSchemaHost extends Omit<ResponseObject, 'description'> {
~~~~
node_modules/#nestjs/swagger/dist/document-builder.d.ts:20:14 - error TS2304: Cannot find name 'Omit'.
20 build(): Omit<OpenAPIObject, 'components' | 'paths'>;
~~~~
node_modules/#nestjs/swagger/dist/interfaces/schema-object-metadata.interface.d.ts:3:47 - error TS2304: Cannot find name 'Omit'.
~~~~
Has someone ideas what to do?

Okay, I have found the answer.
Open file tsconfig.json and add this line:
{
compilerOptions: {
"skipLibCheck": true
}
}
I'm not sure, that it is the best way because it will skip your node_modules checking while compiling. But to launch, it helps.

Related

npm run build failed

I have used microsoft-graph-client and isomorphic-fetch npm package in our project for accessing Microsoft Graph, but while running npm run build command, its throwing errors from node_modules.
node_modules/#microsoft/microsoft-graph-client/lib/src/GraphRequest.d.ts:184:55 - error TS2304: Cannot find name 'HeadersInit'.
184 headers(headers: KeyValuePairObjectStringNumber | HeadersInit): GraphRequest;
~~~~~~~~~~~
node_modules/#microsoft/microsoft-graph-client/lib/src/IContext.d.ts:19:14 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?
19 request: RequestInfo;
~~~~~~~~~~~
node_modules/#microsoft/microsoft-graph-client/lib/src/middleware/options/RetryHandlerOptions.d.ts:16:77 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?
16 export declare type ShouldRetry = (delay: number, attempt: number, request: RequestInfo, options: FetchOptions | undefined, response: Response) => boolean;
~~~~~~~~~~~
node_modules/#microsoft/microsoft-graph-client/lib/src/tasks/PageIterator.d.ts:34:15 - error TS2304: Cannot find name 'HeadersInit'.
34 headers?: HeadersInit;
~~~~~~~~~~~
Found 4 errors in 4 files.
Errors Files
1 node_modules/#microsoft/microsoft-graph-client/lib/src/GraphRequest.d.ts:184
1 node_modules/#microsoft/microsoft-graph-client/lib/src/IContext.d.ts:19
1 node_modules/#microsoft/microsoft-graph-client/lib/src/middleware/options/RetryHandlerOptions.d.ts:16
1 node_modules/#microsoft/microsoft-graph-client/lib/src/tasks/PageIterator.d.ts:34

#nestjs/swagger install errors

currently, When I install swagger on my nestjs project using yarn install I get the following error. Any ideas what may cause this?
src/ledger/dtos/addOrdersByDate.dto.ts:2:10 - error TS2724: Module
'"../../../node_modules/#nestjs/swagger"' has no exported member
'ApiModelProperty'. Did you mean 'ApiHideProperty'?
2 import { ApiModelProperty } from '#nestjs/swagger';
~~~~~~~~~~~~~~~~
node_modules/#nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25
1 export declare function ApiHideProperty(): PropertyDecorator;
~~~~~~~~~~~~~~~
'ApiHideProperty' is declared here.
src/ledger/dtos/addRebatesCharges.dto.ts:1:10 - error TS2724: Module
'"../../../node_modules/#nestjs/swagger"' has no exported member
'ApiModelProperty'. Did you mean 'ApiHideProperty'?
1 import { ApiModelProperty } from '#nestjs/swagger';
~~~~~~~~~~~~~~~~
node_modules/#nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25
1 export declare function ApiHideProperty(): PropertyDecorator;
~~~~~~~~~~~~~~~
'ApiHideProperty' is declared here.
src/ledger/dtos/addReturns.dto.ts:2:10 - error TS2724: Module
'"../../../node_modules/#nestjs/swagger"' has no exported member
'ApiModelProperty'. Did you mean 'ApiHideProperty'?
2 import { ApiModelProperty } from '#nestjs/swagger';
~~~~~~~~~~~~~~~~
node_modules/#nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25
1 export declare function ApiHideProperty(): PropertyDecorator;
~~~~~~~~~~~~~~~
'ApiHideProperty' is declared here.
src/ledger/dtos/addSellers.dto.ts:2:10 - error TS2724: Module
'"../../../node_modules/#nestjs/swagger"' has no exported member
'ApiModelProperty'. Did you mean 'ApiHideProperty'?
2 import { ApiModelProperty } from '#nestjs/swagger';
~~~~~~~~~~~~~~~~
node_modules/#nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25
1 export declare function ApiHideProperty(): PropertyDecorator;
~~~~~~~~~~~~~~~
'ApiHideProperty' is declared here.
src/ledger/dtos/block.dto.ts:2:10 - error TS2724: Module
'"../../../node_modules/#nestjs/swagger"' has no exported member
'ApiModelProperty'. Did you mean 'ApiHideProperty'?
2 import { ApiModelProperty } from '#nestjs/swagger';
~~~~~~~~~~~~~~~~
node_modules/#nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25
1 export declare function ApiHideProperty(): PropertyDecorator;
~~~~~~~~~~~~~~~
'ApiHideProperty' is declared here.
src/ledger/dtos/transaction.dto.ts:1:10 - error TS2724: Module
'"../../../node_modules/#nestjs/swagger"' has no exported member
'ApiModelProperty'. Did you mean 'ApiHideProperty'?
1 import { ApiModelProperty } from '#nestjs/swagger';
~~~~~~~~~~~~~~~~
node_modules/#nestjs/swagger/dist/decorators/api-hide-property.decorator.d.ts:1:25
1 export declare function ApiHideProperty(): PropertyDecorator;
~~~~~~~~~~~~~~~
'ApiHideProperty' is declared here.
src/queue/controllers/queue.controller.ts:2:10 - error TS2305: Module
'"../../../node_modules/#nestjs/swagger"' has no exported member
'ApiUseTags'.
2 import { ApiUseTags, ApiOperation, ApiResponse } from
'#nestjs/swagger';
~~~~~~~~~~
src/queue/controllers/queue.controller.ts:10:19 - error TS2345:
Argument of type '{ title: string; }' is not assignable to parameter
of type 'Partial'. Object literal may only specify
known properties, and 'title' does not exist in type
'Partial'.
10 #ApiOperation({ title: 'List queues with message quantity' })
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/controllers/configuration.controller.ts:2:24 - error
TS2305: Module '"../../../node_modules/#nestjs/swagger"' has no
exported member 'ApiUseTags'.
2 import { ApiOperation, ApiUseTags } from '#nestjs/swagger';
~~~~~~~~~~
src/shared/controllers/configuration.controller.ts:12:19 - error
TS2345: Argument of type '{ title: string; }' is not assignable to
parameter of type 'Partial'. Object literal may
only specify known properties, and 'title' does not exist in type
'Partial'.
12 #ApiOperation({ title: 'Get configuration variables' })
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/controllers/history.controller.ts:2:24 - error TS2305:
Module '"../../../node_modules/#nestjs/swagger"' has no exported
member 'ApiUseTags'.
2 import { ApiOperation, ApiUseTags } from '#nestjs/swagger';
~~~~~~~~~~
src/shared/controllers/history.controller.ts:10:19 - error TS2345:
Argument of type '{ title: string; }' is not assignable to parameter
of type 'Partial'. Object literal may only specify
known properties, and 'title' does not exist in type
'Partial'.
10 #ApiOperation({ title: 'Get history for entity' })
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shared/filters/http-exception.filter.ts:24:34 - error TS2339:
Property 'error' does not exist on type 'string'.
24 error: exception.message.error,
~~~~~
src/shared/filters/http-exception.filter.ts:25:36 - error TS2339:
Property 'message' does not exist on type 'string'.
25 message: exception.message.message,
~~~~~~~
src/shared/filters/http-exception.filter.ts:35:34 - error TS2339:
Property 'error' does not exist on type 'string'.
35 error: exception.message.error,
Based on the documentation from #nestjs/swagger
under "Migration from v3" part, the following decorators have been changed/renamed:
...
#ApiModelProperty is now #ApiProperty
...
There is a list of breaking changes in 4.0 version of swagger package:
https://docs.nestjs.com/openapi/migration-guide#breaking-changes
I guess at least part of the issues is coming from there.
Change ApiModelProperty to ApiProperty

Error when trying to upload G-Cloud-Function

i got a problem when uploading my Cloud-Functions to Firebase.
Using Typescript i need to do some XML-Parsing and therefore i need a package called xmldom-ts, but it shows me this abstract error:
tsc
node_modules/typescript/lib/lib.dom.d.ts:6059:11 - error TS2320: Interface 'HTMLAnchorElement' cannot simultaneously extend types 'HTMLElement' and 'HTMLHyperlinkElementUtils'.
Named property 'toString' of types 'HTMLElement' and 'HTMLHyperlinkElementUtils' are not identical.
6059 interface HTMLAnchorElement extends HTMLElement, HTMLHyperlinkElementUtils {
~~~~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:6168:11 - error TS2320: Interface 'HTMLAreaElement' cannot simultaneously extend types 'HTMLElement' and 'HTMLHyperlinkElementUtils'.
Named property 'toString' of types 'HTMLElement' and 'HTMLHyperlinkElementUtils' are not identical.
6168 interface HTMLAreaElement extends HTMLElement, HTMLHyperlinkElementUtils {
~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/document.d.ts:24:5 - error TS2416: Property 'createElement' in type 'DocumentImpl' is not assignable to the same property in base type 'DummyDocument'.
Type '(tagName: string) => ElementImpl' is not assignable to type '(_tagName: string) => HTMLElement'.
Property 'autofocus' is missing in type 'ElementImpl' but required in type 'HTMLElement'.
24 createElement(tagName: string): ElementImpl;
~~~~~~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:7989:5
7989 autofocus: boolean;
~~~~~~~~~
'autofocus' is declared here.
node_modules/xmldom-ts/dist/types/document.d.ts:25:5 - error TS2416: Property 'createDocumentFragment' in type 'DocumentImpl' is not assignable to the same property in base type 'DummyDocument'.
Type '() => DocumentFragmentImpl' is not assignable to type '() => DocumentFragment'.
Call signature return types 'DocumentFragmentImpl' and 'DocumentFragment' are incompatible.
The types of 'previousSibling' are incompatible between these types.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
25 createDocumentFragment(): DocumentFragmentImpl;
~~~~~~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/document.d.ts:26:5 - error TS2416: Property 'createTextNode' in type 'DocumentImpl' is not assignable to the same property in base type 'DummyDocument'.
Type '(data: string) => TextImpl' is not assignable to type '(_data: string) => Text'.
Call signature return types 'TextImpl' and 'Text' are incompatible.
The types of 'previousSibling' are incompatible between these types.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
26 createTextNode(data: string): TextImpl;
~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/document.d.ts:27:5 - error TS2416: Property 'createComment' in type 'DocumentImpl' is not assignable to the same property in base type 'DummyDocument'.
Type '(data: string) => CommentImpl' is not assignable to type '(_data: string) => Comment'.
Call signature return types 'CommentImpl' and 'Comment' are incompatible.
The types of 'previousSibling' are incompatible between these types.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
27 createComment(data: string): CommentImpl;
~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/document.d.ts:28:5 - error TS2416: Property 'createCDATASection' in type 'DocumentImpl' is not assignable to the same property in base type 'DummyDocument'.
Type '(data: string) => CDATASectionImpl' is not assignable to type '(_data: string) => CDATASection'.
Call signature return types 'CDATASectionImpl' and 'CDATASection' are incompatible.
The types of 'previousSibling' are incompatible between these types.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
28 createCDATASection(data: string): CDATASectionImpl;
~~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/document.d.ts:29:5 - error TS2416: Property 'createProcessingInstruction' in type 'DocumentImpl' is not assignable to the same property in base type 'DummyDocument'.
Type '(target: string, data: string) => ProcessingInstructionImpl' is not assignable to type '(_target: string, _data: string) => ProcessingInstruction'.
Property 'sheet' is missing in type 'ProcessingInstructionImpl' but required in type 'ProcessingInstruction'.
29 createProcessingInstruction(target: string, data: string): ProcessingInstructionImpl;
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:9677:14
9677 readonly sheet: CSSStyleSheet | null;
~~~~~
'sheet' is declared here.
node_modules/xmldom-ts/dist/types/document.d.ts:30:5 - error TS2416: Property 'createAttribute' in type 'DocumentImpl' is not assignable to the same property in base type 'DummyDocument'.
Type '(name: string) => AttrImpl' is not assignable to type '(_name: string) => Attr'.
Call signature return types 'AttrImpl' and 'Attr' are incompatible.
The types of 'previousSibling' are incompatible between these types.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
30 createAttribute(name: string): AttrImpl;
~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/document.d.ts:31:5 - error TS2416: Property 'createEntityReference' in type 'DocumentImpl' is not assignable to the same property in base type 'DummyDocument'.
Type '(name: string) => EntityReferenceImpl' is not assignable to type '(_name: string) => Node'.
Call signature return types 'EntityReferenceImpl' and 'Node' are incompatible.
The types of 'previousSibling' are incompatible between these types.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
31 createEntityReference(name: string): EntityReferenceImpl;
~~~~~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/document.d.ts:33:5 - error TS2416: Property 'createAttributeNS' in type 'DocumentImpl' is not assignable to the same property in base type 'DummyDocument'.
Type '(namespaceURI: string, qualifiedName: string) => AttrImpl' is not assignable to type '(_namespaceURI: string, _qualifiedName: string) => Attr'.
Type 'AttrImpl' is not assignable to type 'Attr'.
33 createAttributeNS(namespaceURI: string, qualifiedName: string): AttrImpl;
~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dom-implementation.d.ts:12:5 - error TS2416: Property 'createDocument' in type 'DOMImplementationImpl' is not assignable to the same property in base type 'DummyDOMIMplementation'.
Type '(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null) => DocumentImpl' is not assignable to type '(_namespaceURI: string | null, _qualifiedName: string | null, _doctype: DocumentType | null) => Document'.
Call signature return types 'DocumentImpl' and 'Document' are incompatible.
The types of 'defaultView' are incompatible between these types.
Type 'Window | null' is not assignable to type '(Window & typeof globalThis) | null'.
Type 'Window' is not assignable to type 'Window & typeof globalThis'.
Type 'Window' is not assignable to type 'typeof globalThis'.
12 createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null): DocumentImpl;
~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dom-implementation.d.ts:13:5 - error TS2416: Property 'createDocumentType' in type 'DOMImplementationImpl' is not assignable to the same property in base type 'DummyDOMIMplementation'.
Type '(qualifiedName: string, publicId: string, systemId: string) => DocumentTypeImpl' is not assignable to type '(_qualifiedName: string, _publicId: string, _systemId: string) => DocumentType'.
Call signature return types 'DocumentTypeImpl' and 'DocumentType' are incompatible.
The types of 'previousSibling' are incompatible between these types.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
13 createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentTypeImpl;
~~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-attr.d.ts:3:31 - error TS2420: Class 'DummyAttr' incorrectly implements interface 'Attr'.
Types of property 'previousSibling' are incompatible.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
3 export declare abstract class DummyAttr extends NodeImpl implements Attr {
~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-cdata-section.d.ts:3:22 - error TS2420: Class 'DummyCDATASection' incorrectly implements interface 'CDATASection'.
Types of property 'previousSibling' are incompatible.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
3 export declare class DummyCDATASection extends CharacterDataImpl implements CDATASection {
~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-character-data.d.ts:3:31 - error TS2420: Class 'DummyCharacterData' incorrectly implements interface 'CharacterData'.
Types of property 'previousSibling' are incompatible.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
3 export declare abstract class DummyCharacterData extends NodeImpl implements CharacterData {
~~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-comment.d.ts:3:22 - error TS2420: Class 'DummyComment' incorrectly implements interface 'Comment'.
Types of property 'previousSibling' are incompatible.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
3 export declare class DummyComment extends CharacterDataImpl implements Comment {
~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-document-fragment.d.ts:3:22 - error TS2420: Class 'DummyDocumentFragment' incorrectly implements interface 'DocumentFragment'.
Types of property 'previousSibling' are incompatible.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
3 export declare class DummyDocumentFragment extends NodeImpl implements DocumentFragment {
~~~~~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-document-type.d.ts:3:22 - error TS2420: Class 'DummyDocumentType' incorrectly implements interface 'DocumentType'.
Types of property 'previousSibling' are incompatible.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
3 export declare class DummyDocumentType extends NodeImpl implements DocumentType {
~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-document.d.ts:126:14 - error TS2416: Property 'defaultView' in type 'DummyDocument' is not assignable to the same property in base type 'Document'.
Type 'Window | null' is not assignable to type '(Window & typeof globalThis) | null'.
Type 'Window' is not assignable to type 'Window & typeof globalThis'.
Type 'Window' is missing the following properties from type 'typeof globalThis': globalThis, eval, parseInt, parseFloat, and 721 more.
126 readonly defaultView: Window | null;
~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-document.d.ts:147:14 - error TS2416: Property 'onreadystatechange' in type 'DummyDocument' is not assignable to the same property in base type 'Document'.
Type '((this: Document, ev: ProgressEvent<EventTarget>) => any) | null' is not assignable to type '((this: Document, ev: Event) => any) | null'.
Type '(this: Document, ev: ProgressEvent<EventTarget>) => any' is not assignable to type '(this: Document, ev: Event) => any'.
Types of parameters 'ev' and 'ev' are incompatible.
Type 'Event' is missing the following properties from type 'ProgressEvent<EventTarget>': lengthComputable, loaded, total
147 readonly onreadystatechange: ((this: Document, ev: ProgressEvent) => any) | null;
~~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-element.d.ts:148:5 - error TS2416: Property 'getBoundingClientRect' in type 'DummyElement' is not assignable to the same property in base type 'Element'.
Type '() => DOMRect | ClientRect' is not assignable to type '() => DOMRect'.
Type 'DOMRect | ClientRect' is not assignable to type 'DOMRect'.
Type 'ClientRect' is missing the following properties from type 'DOMRect': x, y, toJSON
148 getBoundingClientRect(): ClientRect | DOMRect;
~~~~~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-element.d.ts:148:5 - error TS2416: Property 'getBoundingClientRect' in type 'DummyElement' is not assignable to the same property in base type 'HTMLElement'.
Type '() => DOMRect | ClientRect' is not assignable to type '() => DOMRect'.
148 getBoundingClientRect(): ClientRect | DOMRect;
~~~~~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-element.d.ts:149:5 - error TS2416: Property 'getClientRects' in type 'DummyElement' is not assignable to the same property in base type 'Element'.
Type '() => ClientRectList | DOMRectList' is not assignable to type '() => DOMRectList'.
Type 'ClientRectList | DOMRectList' is not assignable to type 'DOMRectList'.
Type 'ClientRectList' is not assignable to type 'DOMRectList'.
The types returned by 'item(...)' are incompatible between these types.
Type 'ClientRect' is not assignable to type 'DOMRect'.
149 getClientRects(): ClientRectList | DOMRectList;
~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-element.d.ts:149:5 - error TS2416: Property 'getClientRects' in type 'DummyElement' is not assignable to the same property in base type 'HTMLElement'.
Type '() => ClientRectList | DOMRectList' is not assignable to type '() => DOMRectList'.
149 getClientRects(): ClientRectList | DOMRectList;
~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-entity-reference.d.ts:3:22 - error TS2420: Class 'DummyEntityReference' incorrectly implements interface 'Node'.
Types of property 'previousSibling' are incompatible.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
3 export declare class DummyEntityReference extends NodeImpl implements EntityReference {
~~~~~~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-node.d.ts:8:14 - error TS2416: Property 'previousSibling' in type 'DummyNode' is not assignable to the same property in base type 'Node'.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is missing the following properties from type 'ChildNode': after, before, remove, replaceWith
8 abstract previousSibling: Node | null;
~~~~~~~~~~~~~~~
node_modules/xmldom-ts/dist/types/dummy/dummy-processing-instruction.d.ts:3:31 - error TS2420: Class 'DummyProcessingInstruction' incorrectly implements interface 'ProcessingInstruction'.
Property 'sheet' is missing in type 'DummyProcessingInstruction' but required in type 'ProcessingInstruction'.
3 export declare abstract class DummyProcessingInstruction extends CharacterDataImpl implements ProcessingInstruction {
~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:9677:14
9677 readonly sheet: CSSStyleSheet | null;
~~~~~
'sheet' is declared here.
node_modules/xmldom-ts/dist/types/dummy/dummy-text.d.ts:3:22 - error TS2420: Class 'DummyText' incorrectly implements interface 'Text'.
Types of property 'previousSibling' are incompatible.
Type 'Node | null' is not assignable to type 'ChildNode | null'.
Type 'Node' is not assignable to type 'ChildNode'.
3 export declare class DummyText extends CharacterDataImpl implements Text {
~~~~~~~~~
Found 29 errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions# build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions# build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Any idea why i get this error? My package.json:
"dependencies": {
"es6-promise-pool": "^2.5.0",
"firebase-admin": "^8.12.1",
"firebase-functions": "^3.7.0",
"stripe": "^8.67.0",
"xmldom-ts": "^0.3.1",
"xpath-ts": "^1.3.13"
},
npm tsc and vscode show no problems / warnings & i tried npm reinstall multiple times.
Removing xmldom-ts from packages solved the Problem
npm uninstall xmldom-ts

"error TS2304: Cannot find name 'Long'" when compiling typescript with google api libraries

I just added "#google-cloud/logging-winston":"2.1.0", in my pacakge.json and when I compile I get the following errors. I have seen this with other google libraries occasionally, and its root cause is most likely deeper in the stack in automatic generated types from protobuf definitions.
../node_modules/#google-cloud/logging/build/proto/logging.d.ts:1434:32 - error TS2304: Cannot find name 'Long'.
1434 line?: (number|Long|null);
~~~~
../node_modules/#google-cloud/logging/build/proto/logging.d.ts:1453:38 - error TS2304: Cannot find name 'Long'.
1453 public line: (number|Long);
~~~~
../node_modules/#google-cloud/logging/build/proto/logging.d.ts:1543:39 - error TS2304: Cannot find name 'Long'.
1543 requestSize?: (number|Long|null);
~~~~
../node_modules/#google-cloud/logging/build/proto/logging.d.ts:1549:40 - error TS2304: Cannot find name 'Long'.
1549 responseSize?: (number|Long|null);
~~~~
../node_modules/#google-cloud/logging/build/proto/logging.d.ts:1576:42 - error TS2304: Cannot find name 'Long'.
1576 cacheFillBytes?: (number|Long|null);
Here is how I worked around this issue until it is taken care of.
In your package.json dependencies section add "long":"4.0.0",
In your package.json devDependencies section: add "#types/long":"4.0.0",
Finally, in tsconfig.json (add to tsconfig.app.js if that doesn't work) (or in the tsc command line) add:
{
"compilerOptions": {
...
"types": [
...
"long"
],
...
}
gae123 suggestion did not work for me on typescript version 4.9.4.
I added the following to tsconfig.json. Hope this helps.
"compilerOptions":{
...
"skipLibCheck": true,
}
I solved adding the long packet and #types/long, as gae123 suggested, but now the type is not to add in tsconfig.json but in tsconfig.app.json.
"compilerOptions": {
...
"types": [...,"long"]
}
Thanks gae123!

Typescript Google API compilation errors

I'm using Typescript, tslint and Google APIs but there's issues compiling in typescript to javascript and I'm not sure why and for some reason I can't find anything specific online about this problem. Google searches don't render good results. I can't find a good example of how your tsconfig should be setup with this library also. So I'm coming here.
I'm running into lots of "Cannot find type definition file" and "Cannot find module" errors when I run tsc.
My file is literally just this line:
import {google} from 'googleapis'
That's it.
When I run tsc it gives me these errors:
$ tsc
node_modules/gaxios/build/src/common.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.
1 /// <reference types="node" />
~~~~
node_modules/gaxios/build/src/common.d.ts:3:23 - error TS2307: Cannot find module 'https'.
3 import { Agent } from 'https';
~~~~~~~
node_modules/google-auth-library/build/src/auth/authclient.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/auth/authclient.d.ts:17:30 - error TS2307: Cannot find module 'events'.
17 import { EventEmitter } from 'events';
~~~~~~~~
node_modules/google-auth-library/build/src/auth/googleauth.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/auth/googleauth.d.ts:17:21 - error TS2307: Cannot find module 'fs'.
17 import * as fs from 'fs';
~~~~
node_modules/google-auth-library/build/src/auth/googleauth.d.ts:19:25 - error TS2307: Cannot find module 'stream'.
19 import * as stream from 'stream';
~~~~~~~~
node_modules/google-auth-library/build/src/auth/googleauth.d.ts:182:20 - error TS2503: Cannot find namespace 'NodeJS'.
182 _osPlatform(): NodeJS.Platform;
~~~~~~
node_modules/google-auth-library/build/src/auth/jwtaccess.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/auth/jwtaccess.d.ts:17:25 - error TS2307: Cannot find module 'stream'.
17 import * as stream from 'stream';
~~~~~~~~
node_modules/google-auth-library/build/src/auth/jwtclient.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/auth/jwtclient.d.ts:18:25 - error TS2307: Cannot find module 'stream'.
18 import * as stream from 'stream';
~~~~~~~~
node_modules/google-auth-library/build/src/auth/refreshclient.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/auth/refreshclient.d.ts:17:25 - error TS2307: Cannot find module 'stream'.
17 import * as stream from 'stream';
~~~~~~~~
node_modules/google-auth-library/build/src/crypto/crypto.d.ts:16:23 - error TS2688: Cannot find type definition file for 'node'.
16 /// <reference types="node" />
~~~~
node_modules/google-auth-library/build/src/crypto/crypto.d.ts:32:60 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i #types/node` and then add `node` to the types field in your tsconfig.
32 verify(pubkey: string | JwkCertificate, data: string | Buffer, signature: string): Promise<boolean>;
My tsconfig file is:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"esModuleInterop": true,
"noImplicitAny": false,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "app",
"baseUrl": "./app",
"paths": {
"*": [
"node_modules/*"
]
}
},
"include": [
"src/**/*"
]
}
My package dependencies are:
"dependencies": {
"googleapis": "^37.2.0",
"mysql": "^2.16.0",
"typescript": "^3.3.3333"
},
"devDependencies": {
"nodemon": "^1.18.10",
"tslint": "^5.12.1"
}
I'm not using the tsc node module (which is deprecated), I'm using typescript v3.3.3
Help would be appreciated! :)
Type errors in 3rd party libraries typings can easily be avoided by either submitting a pull request OR turning on skipLibCheck: true in your tsconfig and wait for them to be fixed.
Hope this helps.

Resources