Skip to content

lib.es6.d.ts is missing a method for CanvasRenderingContext2D interface #19195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nhrones opened this issue Oct 15, 2017 · 13 comments · Fixed by #20177
Closed

lib.es6.d.ts is missing a method for CanvasRenderingContext2D interface #19195

nhrones opened this issue Oct 15, 2017 · 13 comments · Fixed by #20177
Assignees
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@nhrones
Copy link

nhrones commented Oct 15, 2017

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

@mhegazy
Copy link
Contributor

mhegazy commented Oct 16, 2017

@mhegazy
Copy link
Contributor

mhegazy commented Oct 16, 2017

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.

@mhegazy mhegazy added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this labels Oct 16, 2017
@mhegazy mhegazy added this to the Community milestone Oct 16, 2017
@nhrones
Copy link
Author

nhrones commented Oct 17, 2017 via email

@RyanCavanaugh
Copy link
Member

@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.

@nhrones
Copy link
Author

nhrones commented Oct 17, 2017 via email

@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Oct 17, 2017

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.

@nhrones
Copy link
Author

nhrones commented Oct 17, 2017 via email

@nhrones
Copy link
Author

nhrones commented Oct 17, 2017

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.

@nhrones nhrones closed this as completed Oct 17, 2017
@RyanCavanaugh
Copy link
Member

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.

@RyanCavanaugh RyanCavanaugh reopened this Oct 17, 2017
@nhrones
Copy link
Author

nhrones commented Oct 18, 2017

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;

@RyanCavanaugh
Copy link
Member

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.

@nhrones
Copy link
Author

nhrones commented Oct 18, 2017

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 <C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib> 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.

@nhrones
Copy link
Author

nhrones commented Oct 18, 2017

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

@mhegazy mhegazy added the Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet label Nov 20, 2017
@mhegazy mhegazy self-assigned this Nov 20, 2017
@mhegazy mhegazy modified the milestones: Community, TypeScript 2.7 Nov 20, 2017
@mhegazy mhegazy reopened this Nov 20, 2017
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Nov 21, 2017
@mhegazy mhegazy removed the Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet label Nov 21, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants