瀏覽代碼

refactor: update to TypeScript 2.6.1 and related refactorings (#177)

* chore(package): update typescript to version 2.6.1
* refactor: removed unused symbols to comply with TypeScript 2.6
Sebastian Haas 7 年之前
父節點
當前提交
e3f0ceefbc

+ 1 - 1
package.json

@@ -92,7 +92,7 @@
     "tsify": "^3.0.0",
     "tslint": "^5.8.0",
     "typedoc": "^0.9.0",
-    "typescript": "^2.5.3",
+    "typescript": "^2.6.1",
     "uglifyjs-webpack-plugin": "^1.0.1",
     "webpack": "^3.5.5",
     "webpack-dev-server": "^2.9.1"

+ 1 - 5
src/MusicalScore/Graphical/MusicSystem.ts

@@ -14,7 +14,6 @@ import {PointF2D} from "../../Common/DataObjects/PointF2D";
 import {GraphicalStaffEntry} from "./GraphicalStaffEntry";
 import {SystemLinesEnum} from "./SystemLinesEnum";
 import Dictionary from "typescript-collections/dist/lib/Dictionary";
-import {CollectionUtil} from "../../Util/CollectionUtil";
 import {GraphicalComment} from "./GraphicalComment";
 import {GraphicalMarkedArea} from "./GraphicalMarkedArea";
 import {SystemLine} from "./SystemLine";
@@ -243,15 +242,12 @@ export abstract class MusicSystem extends GraphicalObject {
             if (instrument1 === undefined || instrument2 === undefined) {
                 continue;
             }
-            let firstStaffLine: StaffLine = undefined, lastStaffLine: StaffLine = undefined;
+            let firstStaffLine: StaffLine = undefined;
             for (let idx2: number = 0, len2: number = this.staffLines.length; idx2 < len2; ++idx2) {
                 let staffLine: StaffLine = this.staffLines[idx2];
                 if (staffLine.ParentStaff === instrument1.Staves[0]) {
                     firstStaffLine = staffLine;
                 }
-                if (staffLine.ParentStaff === CollectionUtil.last(instrument2.Staves)) {
-                    lastStaffLine = staffLine;
-                }
             }
             if (firstStaffLine !== undefined && firstStaffLine !== undefined) {
                 this.createGroupBracket(firstStaffLine, firstStaffLine, recursionDepth);

+ 0 - 4
src/MusicalScore/Graphical/StaffLine.ts

@@ -103,7 +103,6 @@ export abstract class StaffLine extends GraphicalObject {
      */
     public findClosestStaffEntry(xPosition: number): GraphicalStaffEntry {
         let closestStaffentry: GraphicalStaffEntry = undefined;
-        let difference: number = Number.MAX_VALUE;
         for (let idx: number = 0, len: number = this.Measures.length; idx < len; ++idx) {
             let graphicalMeasure: StaffMeasure = this.Measures[idx];
             for (let idx2: number = 0, len2: number = graphicalMeasure.staffEntries.length; idx2 < len2; ++idx2) {
@@ -111,9 +110,6 @@ export abstract class StaffLine extends GraphicalObject {
                 if (
                     Math.abs(graphicalStaffEntry.PositionAndShape.RelativePosition.x - xPosition + graphicalMeasure.PositionAndShape.RelativePosition.x) < 5.0
                 ) {
-                    difference = Math.abs(
-                        graphicalStaffEntry.PositionAndShape.RelativePosition.x - xPosition + graphicalMeasure.PositionAndShape.RelativePosition.x
-                    );
                     closestStaffentry = graphicalStaffEntry;
                 }
             }

+ 2 - 5
src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetDrawer.ts

@@ -1,4 +1,3 @@
-import Vex = require("vexflow");
 import {MusicSheetDrawer} from "../MusicSheetDrawer";
 import {RectangleF2D} from "../../../Common/DataObjects/RectangleF2D";
 import {VexFlowMeasure} from "./VexFlowMeasure";
@@ -12,14 +11,13 @@ import {GraphicalStaffEntry} from "../GraphicalStaffEntry";
 import {VexFlowBackend} from "./VexFlowBackend";
 
 /**
- * This is a global contant which denotes the height in pixels of the space between two lines of the stave
+ * This is a global constant which denotes the height in pixels of the space between two lines of the stave
  * (when zoom = 1.0)
  * @type number
  */
 export const unitInPixels: number = 10;
 
 export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
-    private renderer: Vex.Flow.Renderer;
     private backend: VexFlowBackend;
     private zoom: number = 1.0;
 
@@ -28,7 +26,6 @@ export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
                 isPreviewImageDrawer: boolean = false) {
         super(new VexFlowTextMeasurer(), isPreviewImageDrawer);
         this.backend = backend;
-        this.renderer = this.backend.getRenderer();
     }
 
     public clear(): void {
@@ -41,7 +38,7 @@ export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
      */
     public scale(k: number): void {
         this.zoom = k;
-        this.backend.scale(k);
+        this.backend.scale(this.zoom);
     }
 
     /**

+ 6 - 6
src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -56,7 +56,7 @@ export type RepetitionInstructionReader = any;
 export class InstrumentReader {
 
   constructor(repetitionInstructionReader: RepetitionInstructionReader, xmlMeasureList: IXmlElement[], instrument: Instrument) {
-      this.repetitionInstructionReader = repetitionInstructionReader;
+      // this.repetitionInstructionReader = repetitionInstructionReader;
       this.xmlMeasureList = xmlMeasureList;
       this.musicSheet = instrument.GetMusicSheet;
       this.instrument = instrument;
@@ -69,7 +69,7 @@ export class InstrumentReader {
       // (*) this.slurReader = MusicSymbolModuleFactory.createSlurReader(this.musicSheet);
   }
 
-  private repetitionInstructionReader: RepetitionInstructionReader;
+  // private repetitionInstructionReader: RepetitionInstructionReader;
   private xmlMeasureList: IXmlElement[];
   private musicSheet: MusicSheet;
   private slurReader: any; // (*) SlurReader;
@@ -309,10 +309,10 @@ export class InstrumentReader {
         } else if (xmlNode.name === "direction") {
           // unused let directionTypeNode: IXmlElement = xmlNode.element("direction-type");
           // (*) MetronomeReader.readMetronomeInstructions(xmlNode, this.musicSheet, this.currentXmlMeasureIndex);
-          let relativePositionInMeasure: number = Math.min(1, currentFraction.RealValue);
-          if (this.activeRhythm !== undefined && this.activeRhythm.Rhythm !== undefined) {
-            relativePositionInMeasure /= this.activeRhythm.Rhythm.RealValue;
-          }
+          // let relativePositionInMeasure: number = Math.min(1, currentFraction.RealValue);
+          // if (this.activeRhythm !== undefined && this.activeRhythm.Rhythm !== undefined) {
+            // relativePositionInMeasure /= this.activeRhythm.Rhythm.RealValue;
+          // }
                     // unused:
                     // let handeled: boolean = false;
                     // if (this.repetitionInstructionReader !== undefined) {

+ 2 - 2
src/MusicalScore/ScoreIO/VoiceGenerator.ts

@@ -36,7 +36,7 @@ export type SlurReader = any;
 export class VoiceGenerator {
     constructor(instrument: Instrument, voiceId: number, slurReader: SlurReader, mainVoice: Voice = undefined) {
         this.musicSheet = instrument.GetMusicSheet;
-        this.slurReader = slurReader;
+        // this.slurReader = slurReader;
         if (mainVoice !== undefined) {
             this.voice = new LinkedVoice(instrument, voiceId, mainVoice);
         } else {
@@ -47,7 +47,7 @@ export class VoiceGenerator {
         //this.articulationReader = MusicSymbolModuleFactory.createArticulationReader();
     }
 
-    private slurReader: SlurReader;
+    // private slurReader: SlurReader;
     //private lyricsReader: LyricsReader;
     //private articulationReader: ArticulationReader;
     private musicSheet: MusicSheet;

+ 0 - 2
src/MusicalScore/VoiceData/VerticalSourceStaffEntryContainer.ts

@@ -9,13 +9,11 @@ export class VerticalSourceStaffEntryContainer {
 
     constructor(parentMeasure: SourceMeasure, timestamp: Fraction, size: number) {
         this.timestamp = timestamp;
-        this.size = size;
         this.staffEntries = new Array(size);
         this.parentMeasure = parentMeasure;
     }
 
     private timestamp: Fraction;
-    private size: number;
     private staffEntries: SourceStaffEntry[] = [];
     private comments: Comment[] = [];
     private parentMeasure: SourceMeasure;

+ 1 - 1
src/OSMD/Cursor.ts

@@ -17,7 +17,7 @@ export class Cursor {
     curs.style.position = "absolute";
     curs.style.zIndex = "-1";
     this.cursorElement = <HTMLImageElement>curs;
-    container.appendChild(curs);
+    this.container.appendChild(curs);
   }
 
   private container: HTMLElement;