Skip to content
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

Replace dtslint with tsd #2313

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ jobs:
- name: Lint
run: npm run lint
- name: Lint Types
run: npm run dtslint
run: npm run tsd
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This release notably changes to using N-API. 🎉
* Avoid calling virtual methods in constructors/destructors to avoid bypassing virtual dispatch. (#2229)
* Remove unused private field `backend` in the `Backend` class. (#2229)
* Add Node.js v20 to CI. (#2237)
* Replaced `dtslint` with `tsd` (#2313)
### Added
* Added string tags to support class detection
### Fixed
Expand Down
File renamed without changes.
33 changes: 20 additions & 13 deletions types/test.ts → index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as Canvas from 'canvas'
import * as path from "path";
import { expectAssignable, expectType } from 'tsd'
import * as path from 'path'
import { Readable } from 'stream'

import * as Canvas from './index'

Canvas.registerFont(path.join(__dirname, '../pfennigFont/Pfennig.ttf'), {family: 'pfennigFont'})

Expand All @@ -13,34 +16,38 @@ canv.getContext('2d', {alpha: false})

// LHS is ImageData, not Canvas.ImageData
const id = ctx.getImageData(0, 0, 10, 10)
const h: number = id.height
expectType<number>(id.height)
expectType<number>(id.width)

ctx.currentTransform = ctx.getTransform()

ctx.quality = 'best'
ctx.textDrawingMode = 'glyph'

const grad: Canvas.CanvasGradient = ctx.createLinearGradient(0, 1, 2, 3)
const grad = ctx.createLinearGradient(0, 1, 2, 3)
expectType<Canvas.CanvasGradient>(grad)
grad.addColorStop(0.1, 'red')

const dm = new Canvas.DOMMatrix([1, 2, 3, 4, 5, 6])
const a: number = dm.a
expectType<number>(dm.a)

const b1: Buffer = canv.toBuffer()
canv.toBuffer("application/pdf")
canv.toBuffer((err, data) => {}, "image/png")
canv.createJPEGStream({quality: 0.5})
canv.createPDFStream({author: "octocat"})
expectType<Buffer>(canv.toBuffer())
expectType<Buffer>(canv.toBuffer('application/pdf'))
canv.toBuffer((err, data) => {}, 'image/png')
expectAssignable<Readable>(canv.createJPEGStream({ quality: 0.5 }))
expectAssignable<Readable>(canv.createPDFStream({ author: 'octocat' }))
canv.toDataURL()

const img = new Canvas.Image()
img.src = Buffer.alloc(0)
img.dataMode = Canvas.Image.MODE_IMAGE | Canvas.Image.MODE_MIME
img.onload = () => {}
img.onload = null;
img.onload = null

const id2: Canvas.ImageData = Canvas.createImageData(new Uint16Array(4), 1)
const id2 = Canvas.createImageData(new Uint16Array(4), 1)
expectType<Canvas.ImageData>(id2)
ctx.putImageData(id2, 0, 0)

ctx.drawImage(canv, 0, 0)

Canvas.deregisterAllFonts();
Canvas.deregisterAllFonts()
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"author": "TJ Holowaychuk <tj@learnboost.com>",
"main": "index.js",
"browser": "browser.js",
"types": "index.d.ts",
"contributors": [
"Nathan Rajlich <nathan@tootallnate.net>",
"Rod Vagg <r@va.gg>",
Expand Down Expand Up @@ -32,7 +33,7 @@
"generate-wpt": "node ./test/wpt/generate.js",
"test-wpt": "mocha test/wpt/generated/*.js",
"install": "node-pre-gyp install --fallback-to-build --update-binary",
"dtslint": "dtslint types"
"tsd": "tsd"
},
"binary": {
"module_name": "canvas",
Expand All @@ -43,12 +44,13 @@
},
"files": [
"binding.gyp",
"browser.js",
"index.d.ts",
"index.js",
Comment on lines +47 to +49
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially, this aren't needed, but the files documentation only mentions main, and I think it's better to just include them all...

"lib/",
"src/",
"util/",
"types/index.d.ts"
"util/"
],
"types": "types/index.d.ts",
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.0",
"node-addon-api": "^7.0.0",
Expand All @@ -57,12 +59,12 @@
"devDependencies": {
"@types/node": "^10.12.18",
"assert-rejects": "^1.0.0",
"dtslint": "^4.0.7",
"express": "^4.16.3",
"js-yaml": "^4.1.0",
"mocha": "^5.2.0",
"pixelmatch": "^4.0.2",
"standard": "^12.0.1",
"tsd": "^0.29.0",
"typescript": "^4.2.2"
},
"engines": {
Expand Down
3 changes: 0 additions & 3 deletions types/Readme.md

This file was deleted.

13 changes: 0 additions & 13 deletions types/tsconfig.json

This file was deleted.

7 changes: 0 additions & 7 deletions types/tslint.json

This file was deleted.

Loading