How to ignore TypeScript error TS2339 - Property does not exist on type

Related searches

I'm using Angular 8 (started a project within Visual Studio 2019) and have fabric.init.ts file with next content:

import 'fabric';
import * as fabric from 'fabric/fabric-impl';

// (TS) Property 'DPI' does not exist on type 'typeof import(..@types/fabric/fabric-impl)'
fabric.DPI = 213;
....

Next is ok, because it matches the d.ts definition:

// Override fabric to meet ourrequirements
fabric.util.object.extend(fabric.Object.prototype, {
  centeredRotation: true,

How to ignore the DPI TS2339 error. It would be really great to have autocompletion, specially for learning fabric.

My package.json:

"private": true,
"dependencies": {
  "@angular/core": "8.2.14",
  ....
  "@angular/router": "8.2.14",
  "@types/fabric": "3.5.1",
  "fabric": "3.5.1",
  ...
},

EDIT

For now I solved it by adding this line:

// @ts-ignore
fabric.DPI = 213;

I know its not the best solution, I prefer @wentjun's solution.

By changing this: import * as fabric from 'fabric/fabric-impl'; to import { fabric } from 'fabric'; I now have VisualStudio intellisense enabled as well. Of course I added @types/fabricjs to package.json.

For instance like this (fabric as any).DPI = 213;

How to ignore TypeScript error TS2339, import 'fabric'; import * as fabric from 'fabric/fabric-impl'; // (TS) Property 'DPI' does not exist on type 'typeof import(..@types/fabric/fabric-impl)'� I get many The property 'x' does not exist on value of type 'y' errors which i want to ignore when using javascript functions. Answers: I know the question is already closed but I’ve found it searching for same TypeScriptException, maybe some one else hit this question searching for this problem.

Either type cast it as any then Typescript will ignore it like Vugar suggested or

import Typescript definitions

Getting error TS2339: Property does not exist on type for a valid ES6 , When compiled/transpiled through TypeScript it generates error TS2339: Property 'myclassvar' does not exist on type 'MyClass'. If the above� I agree with @mrnagydavid that this issue is not the same as #766 which proposes different methods for declaring class members within a constructor while the current one is about making a valid JavaScript code to work in a TypeScript project without generating any errors.

I am not familiar with Fabric, but the recommended way of doing so would be to extend the fabric namespace to accept DPI as a valid property.

First, you can create a typescript file and define your new fabric definition.

custom-fabric.ts:

interface ExtendedFabric {
  DPI: number;
}

// apply additional types to fabric and export it for usage
export const CustomFabric: (ExtendedFabric & typeof fabric) = fabric as any;

In your class/component that uses it,

import { CustomFabric } from './custom-fabric';

CustomFabric.DPI = 213; // no TS errors

Property 'from' does not exist on type '{}' � Issue #41674 , Can I prevent the TypeScript compiler from caring about this? Error introduced by the following change: #41580. I tried using the @types/xxxx� The recommended way to ignore “property does not exist on property does not exist on value of type ignore-typescript-errors-property-does-not-exist-on

Ask Typescript to ignore an error | by Sahil Malik, A good example is referencing a file that gets built at runtime. It is not work for me :( in Angular you have bootStrapModuleFactory — but the factory isn't there until the code is built. So how do you ask the typescript compiler to ignore an error? TypeScript: Create a condition-based subset types. There are a few issues going on here. First you have @types/node and typings\global ode, these two pretty much define the same thing.I have a PR changing this in SunShinewyf/myApp#1.

Handbook - Overview, When a line is prefixed with a // @ts-expect-error comment, TypeScript will ts- ignore or ts-expect-error ? Property 'kind' does not exist on type 'never'. There are quite a few things that people would like to be added to typescript, and things are done over time, but you can't expect it to have it all.. But since you can very easily add it yourself, maybe it's not on their top priorities – Nitzan Tomer Apr 20 '16 at 11:00

I am New to typescript. In my Durandal application I migrated to VS-2012 to VS-2015 means typescript 0.9 to typescript 1.8.4. After migrated I got so many build errors.

Comments
  • The problem is because fabric definition file does not have everything as fabric javascript file.
  • Try using fabricjs 1.5 or see this stackoverflow.com/questions/27417107/…