File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ var CONTEXT_PROPERTIES = [
8686 'globalAlpha' ,
8787 'globalCompositeOperation' ,
8888 'imageSmoothingEnabled' ,
89- ] ;
89+ ] as const ;
9090
9191const traceArrMax = 100 ;
9292/**
@@ -701,6 +701,11 @@ export class Context {
701701 }
702702}
703703
704+ // supported context properties
705+ type CanvasContextProps = Pick < CanvasRenderingContext2D , typeof CONTEXT_PROPERTIES [ number ] > ;
706+
707+ export interface Context extends CanvasContextProps { } ;
708+
704709CONTEXT_PROPERTIES . forEach ( function ( prop ) {
705710 Object . defineProperty ( Context . prototype , prop , {
706711 get ( ) {
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ describe('Context', function () {
5757 'textBaseline' ,
5858 'globalAlpha' ,
5959 'globalCompositeOperation' ,
60- ] ;
60+ ] as const ;
6161
6262 it ( 'context wrapper should work like native context' , function ( ) {
6363 var stage = addStage ( ) ;
@@ -108,10 +108,10 @@ describe('Context', function () {
108108
109109 // test get
110110 nativeContext . fillStyle = '#ff0000' ;
111- assert . equal ( context [ ' fillStyle' ] , '#ff0000' ) ;
111+ assert . equal ( context . fillStyle , '#ff0000' ) ;
112112
113113 // test set
114- context [ ' globalAlpha' ] = 0.5 ;
115- assert . equal ( context [ ' globalAlpha' ] , 0.5 ) ;
114+ context . globalAlpha = 0.5 ;
115+ assert . equal ( context . globalAlpha , 0.5 ) ;
116116 } ) ;
117117} ) ;
You can’t perform that action at this time.
0 commit comments