import type syntax

This commit is contained in:
Yotam Mann 2024-05-03 14:18:52 -04:00
parent f1ba01f21e
commit 192d9b0c9c
15 changed files with 32 additions and 42 deletions

View file

@ -2,7 +2,7 @@
* Tone.js
* @author Yotam Mann
* @license http://opensource.org/licenses/MIT MIT License
* @copyright 2014-2019 Yotam Mann
* @copyright 2014-2024 Yotam Mann
*/
import { version } from "../version.js";
import { theWindow } from "./context/AudioContext.js";

View file

@ -1,7 +1,6 @@
import { Seconds, Ticks } from "../type/Units.js";
import { noOp } from "../util/Interface.js";
type Transport = import("../clock/Transport").TransportClass;
import type { TransportClass as Transport } from "./Transport.js";
export interface TransportEventOptions {
callback: (time: number) => void;

View file

@ -3,8 +3,7 @@ import { TicksClass } from "../type/Ticks.js";
import { Seconds, Ticks, Time } from "../type/Units.js";
import { TransportEvent, TransportEventOptions } from "./TransportEvent.js";
import { GT, LT } from "../util/Math.js";
type Transport = import("../clock/Transport").TransportClass;
import type { TransportClass as Transport } from "./Transport.js";
interface TransportRepeatEventOptions extends TransportEventOptions {
interval: Ticks;

View file

@ -1,11 +1,10 @@
import { Seconds } from "../type/Units.js";
import { Emitter } from "../util/Emitter.js";
import { AnyAudioContext } from "./AudioContext.js";
type Draw = import("../util/Draw").DrawClass;
type Destination = import("./Destination").DestinationClass;
type Transport = import("../clock/Transport").TransportClass;
type Listener = import("./Listener").ListenerClass;
import type { DrawClass as Draw } from "../util/Draw.js";
import type { DestinationClass as Destination } from "./Destination.js";
import type { TransportClass as Transport } from "../clock/Transport.js";
import type { ListenerClass as Listener } from "./Listener.js";
// these are either not used in Tone.js or deprecated and not implemented.
export type ExcludedFromBaseAudioContext =

View file

@ -12,11 +12,10 @@ import {
import { closeContext, initializeContext } from "./ContextInitialization.js";
import { BaseContext, ContextLatencyHint } from "./BaseContext.js";
import { assert } from "../util/Debug.js";
type Transport = import("../clock/Transport").TransportClass;
type Destination = import("./Destination").DestinationClass;
type Listener = import("./Listener").ListenerClass;
type Draw = import("../util/Draw").DrawClass;
import type { DrawClass as Draw } from "../util/Draw.js";
import type { DestinationClass as Destination } from "./Destination.js";
import type { TransportClass as Transport } from "../clock/Transport.js";
import type { ListenerClass as Listener } from "./Listener.js";
export interface ContextOptions {
clockSource: TickerClockSource;

View file

@ -1,8 +1,7 @@
//-------------------------------------
// INITIALIZING NEW CONTEXT
//-------------------------------------
type Context = import("./Context").Context;
import type { Context } from "./Context.js";
/**
* Array of callbacks to invoke when a new context is created

View file

@ -1,11 +1,10 @@
import { BaseContext } from "./BaseContext.js";
import { Seconds } from "../type/Units.js";
import { AnyAudioContext } from "./AudioContext.js";
type Draw = import("../util/Draw").DrawClass;
type Destination = import("./Destination").DestinationClass;
type Transport = import("../clock/Transport").TransportClass;
type Listener = import("./Listener").ListenerClass;
import type { DrawClass as Draw } from "../util/Draw.js";
import type { DestinationClass as Destination } from "./Destination.js";
import type { TransportClass as Transport } from "../clock/Transport.js";
import type { ListenerClass as Listener } from "./Listener.js";
export class DummyContext extends BaseContext {
//---------------------------

View file

@ -19,7 +19,7 @@ import {
isUndef,
} from "../util/TypeCheck.js";
import { BaseContext } from "./BaseContext.js";
import type { TransportClass } from "../clock/Transport";
import type { TransportClass } from "../clock/Transport.js";
/**
* A unit which process audio

View file

@ -1,4 +1,6 @@
import { isUndef } from "./TypeCheck.js";
import type { BaseContext } from "../context/BaseContext.js";
import type { Time } from "../type/Units.js";
/**
* Assert that the statement is true, otherwise invoke the error.
@ -25,9 +27,7 @@ export function assertRange(value: number, gte: number, lte = Infinity): void {
/**
* Warn if the context is not running.
*/
export function assertContextRunning(
context: import("../context/BaseContext").BaseContext
): void {
export function assertContextRunning(context: BaseContext): void {
// add a warning if the context is not started
if (!context.isOffline && context.state !== "running") {
warn(
@ -52,9 +52,7 @@ export function enterScheduledCallback(insideCallback: boolean): void {
/**
* Make sure that a time was passed into
*/
export function assertUsedScheduleTime(
time?: import("../type/Units").Time
): void {
export function assertUsedScheduleTime(time?: Time): void {
if (
isUndef(time) &&
isInsideScheduledCallback &&

View file

@ -4,8 +4,7 @@ import {
isAudioParam,
} from "./AdvancedTypeCheck.js";
import { isDefined, isObject, isUndef } from "./TypeCheck.js";
type BaseToneOptions = import("../Tone").BaseToneOptions;
import type { BaseToneOptions } from "../Tone.js";
/**
* Some objects should not be merged

View file

@ -7,10 +7,10 @@ import { ToneAudioBuffer } from "./core/context/ToneAudioBuffer.js";
export { start } from "./core/Global.js";
import { Seconds } from "./core/type/Units.js";
export { supported } from "./core/context/AudioContext.js";
import type { TransportClass } from "./core/clock/Transport";
import type { DestinationClass } from "./core/context/Destination";
import type { DrawClass } from "./core/util/Draw";
import type { ListenerClass } from "./core/context/Listener";
import type { TransportClass } from "./core/clock/Transport.js";
import type { DestinationClass } from "./core/context/Destination.js";
import type { DrawClass } from "./core/util/Draw.js";
import type { ListenerClass } from "./core/context/Listener.js";
/**
* The current audio context time of the global {@link BaseContext}.

View file

@ -11,7 +11,7 @@ import { optionsFromArguments } from "../core/util/Defaults.js";
import { TransportTimeClass } from "../core/type/TransportTime.js";
import { ToneConstantSource } from "./ToneConstantSource.js";
import { OutputNode } from "../core/context/ToneAudioNode.js";
import type { TransportClass } from "../core/clock/Transport";
import type { TransportClass } from "../core/clock/Transport.js";
/**
* Adds the ability to synchronize the signal to the {@link TransportClass}

View file

@ -1,6 +1,6 @@
import { analyze } from "./Spectrum.js";
import { TestAudioBuffer } from "./TestAudioBuffer.js";
import type { ToneAudioBuffer } from "../../../Tone/core/context/ToneAudioBuffer";
import type { ToneAudioBuffer } from "../../../Tone/core/context/ToneAudioBuffer.js";
import plotly from "plotly.js-dist";
import array2d from "array2d";

View file

@ -1,5 +1,5 @@
import toWav from "audiobuffer-to-wav";
import type { ToneAudioBuffer } from "../../../Tone/core/context/ToneAudioBuffer";
import type { ToneAudioBuffer } from "../../../Tone/core/context/ToneAudioBuffer.js";
export class TestAudioBuffer {
static async fromUrl(

View file

@ -3,23 +3,22 @@
"compilerOptions": {
"strictNullChecks": true,
"target": "ES6",
"module": "ES2015",
"module": "Node16",
"noImplicitAny": false,
"importHelpers": true,
"noUnusedLocals": false,
"removeComments": false,
"outDir": "./build/esm",
"verbatimModuleSyntax" : false,
"sourceMap": true,
"esModuleInterop": true,
"skipLibCheck": true,
"moduleResolution": "Bundler",
"moduleResolution": "Node16",
"strictPropertyInitialization": true,
"downlevelIteration": true,
"experimentalDecorators": true,
"lib": ["es6", "dom", "es2015"],
"baseUrl": "./",
"rootDir": "./",
"rootDir": "./"
},
"include": ["Tone/**/*.ts", "test/**/*.ts"],
"exclude": ["node_modules", "test/integration/**"]