Typescript: lib.es6.d.ts is missing a method for CanvasRenderingContext2D interface

Created on 16 Oct 2017  Â·  13Comments  Â·  Source: microsoft/TypeScript

lib.es6.d.ts is missing a 'fill' method for CanvasRenderingContext2D that takes a 'Path2D'

Please add the following to the CanvasRenderingContext2D interface:
fill(path: Path2D, fillRule?: CanvasFillRule): void

Bug lib.d.ts Fixed help wanted

Most helpful comment

Why is software unfinished? Why do bugs exist? What has caused our resources to be woefully finite? Is imperfection our curse, or our penance? These questions exist, but until the hour of reckoning, the answers are shrouded from our view.

All 13 comments

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

I don't understand this response? I'm NOT contributing! I'm only trying to
point out that your .d.ts files are broken, and causing many errors during
my compile. None of the Typescript .d.ts files are complete with respect
to the canvasContext2D specification specifically relating to Path2D. There
are several omissions.

On Mon, Oct 16, 2017 at 1:24 PM, Mohamed Hegazy notifications@github.com
wrote:

More docs at: https://html.spec.whatwg.org/multipage/canvas.html#dom-
context-2d-fill

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/TypeScript/issues/19195#issuecomment-336959146,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADIHw9uY_byXr-zD_xVFm6jwl5yDvKoaks5ss5FIgaJpZM4P57VV
.

@nhrones we agree the definition files are incomplete. @mhegazy was outlining the process for contributing a fix for anyone who was interested in doing so.

Is anyone taking any responsibility for the quality of this language? The
Path2D issue in all .d.ts files has been known and ignored since December
2015 ...
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjV15_8gvjWAhUBZyYKHYU_Am4QFggnMAA&url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F34109921%2Fusing-path2d-in-a-typescript-project-is-not-resolved&usg=AOvVaw3AQecd8K3O5RuFJCetHmtq

I really don't understand the offer for me to fix .d.ts files? Does this
mean anyone can modify the core .d.ts files? If so, it is no wonder that
they are full of errors and omissions?

On Tue, Oct 17, 2017 at 11:45 AM, Ryan Cavanaugh notifications@github.com
wrote:

@nhrones https://github.com/nhrones we agree the definition files are
incomplete. @mhegazy https://github.com/mhegazy was outlining the
process for contributing a fix for anyone who was interested in doing so.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/TypeScript/issues/19195#issuecomment-337270207,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADIHw752TkruKpovffcImCBO9y8_JKnKks5stMu3gaJpZM4P57VV
.

Why is software unfinished? Why do bugs exist? What has caused our resources to be woefully finite? Is imperfection our curse, or our penance? These questions exist, but until the hour of reckoning, the answers are shrouded from our view.

So ... what you're telling me is 'it is best to avoid Typescript until the
team gets more resources!'
Message received .. you can close this issue.

On Tue, Oct 17, 2017 at 1:39 PM, Ryan Cavanaugh notifications@github.com
wrote:

Why is software unfinished? Why do bugs exist? What has caused our
resources to be woefully finite? Is imperfection our curse, or our penance?
These questions exist, but until the hour of reckoning, the answers are
shrouded from our view.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/TypeScript/issues/19195#issuecomment-337300927,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADIHwxl5xV4Rtgzd3qSkaSY9Q51xto85ks5stOY2gaJpZM4P57VV
.

Okay. Looks like you came up with a fix in Typescript 2.6.
// @ts-ignore
Having compile errors due to incorrect/incomplete .d.ts? Just add an ignore comment to your code.
Great fix. Now I know why your resources are so thin.

Reopening since this does need to get fixed - thanks for raising it. We'll fix it with the next round of DOM updates or hopefully someone can contribute a fix.

Thanks, I keep updating my local declaration files, but each vs-code update replaces them. I used to know how to include an extension.d.ts, but the method to do this has changed so many times that I can't get any local files recognized. I don't use node_modules, and it looks like that is where code looks now?
If I had a tutorial on how to contribute, I would as I'm retired with lots of spare time.
By the way, there are 4 method declarations missing from interface CanvasRenderingContext2D that are related to Path2D:

clip(path: Path2D, fillRule?: CanvasFillRule): void;
fill(path: Path2D, fillRule?: CanvasFillRule): void;
isPointInPath(path: Path2D, x: number, y: number, fillRule?: CanvasFillRule): boolean;
isPointInStroke(path: Path2D, x: number, y: number): boolean;

The easiest way to prevent that is to have a local file that augments the existing definition:

interface CanvasRenderingContext2D {
    clip(path: Path2D, fillRule?: CanvasFillRule): void;
    fill(path: Path2D, fillRule?: CanvasFillRule): void;
    isPointInPath(path: Path2D, x: number, y: number, fillRule?: CanvasFillRule): boolean;
    isPointInStroke(path: Path2D, x: number, y: number): boolean;
}

Playground link

Note that this file needs to not be a module (i.e. have top-level export or import declarations). I recommend just naming it globalfixes.d.ts or similar and just keeping workaround definitions in it.

That is a method I've used in the past. Now, I can't seem to find any combination of file location/ tsconfig.json settings that work any longer. As it is, the files that I've modified in the vscode location generate many compile errors during the build task, but these errors 'clear' automatically as the cursor lands on the line with the error. Very strange behavior indeed. From what I've read, It may be related to the fact that my UI projects don't have any node_modules or package.json file. I do have several node file-server/socket-server projects that have no issues at all.

I placed the globalfixes.d.ts file in ./src and now compile errors are gone. Thanks

Was this page helpful?
0 / 5 - 0 ratings