Skip to content

Commit

Permalink
Replace dtslint with tsd
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusU committed Nov 28, 2023
1 parent a5b379b commit 9a3ec84
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 42 deletions.
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
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()
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"author": "TJ Holowaychuk <[email protected]>",
"main": "index.js",
"browser": "browser.js",
"types": "index.d.ts",
"contributors": [
"Nathan Rajlich <[email protected]>",
"Rod Vagg <[email protected]>",
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,12 @@
},
"files": [
"binding.gyp",
"index.d.ts",
"index.js",
"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 +58,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.

0 comments on commit 9a3ec84

Please sign in to comment.