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 * Tone.js
* @author Yotam Mann * @author Yotam Mann
* @license http://opensource.org/licenses/MIT MIT License * @license http://opensource.org/licenses/MIT MIT License
* @copyright 2014-2019 Yotam Mann * @copyright 2014-2024 Yotam Mann
*/ */
import { version } from "../version.js"; import { version } from "../version.js";
import { theWindow } from "./context/AudioContext.js"; import { theWindow } from "./context/AudioContext.js";

View file

@ -1,7 +1,6 @@
import { Seconds, Ticks } from "../type/Units.js"; import { Seconds, Ticks } from "../type/Units.js";
import { noOp } from "../util/Interface.js"; import { noOp } from "../util/Interface.js";
import type { TransportClass as Transport } from "./Transport.js";
type Transport = import("../clock/Transport").TransportClass;
export interface TransportEventOptions { export interface TransportEventOptions {
callback: (time: number) => void; 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 { Seconds, Ticks, Time } from "../type/Units.js";
import { TransportEvent, TransportEventOptions } from "./TransportEvent.js"; import { TransportEvent, TransportEventOptions } from "./TransportEvent.js";
import { GT, LT } from "../util/Math.js"; import { GT, LT } from "../util/Math.js";
import type { TransportClass as Transport } from "./Transport.js";
type Transport = import("../clock/Transport").TransportClass;
interface TransportRepeatEventOptions extends TransportEventOptions { interface TransportRepeatEventOptions extends TransportEventOptions {
interval: Ticks; interval: Ticks;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,6 @@
import { isUndef } from "./TypeCheck.js"; 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. * 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. * Warn if the context is not running.
*/ */
export function assertContextRunning( export function assertContextRunning(context: BaseContext): void {
context: import("../context/BaseContext").BaseContext
): void {
// add a warning if the context is not started // add a warning if the context is not started
if (!context.isOffline && context.state !== "running") { if (!context.isOffline && context.state !== "running") {
warn( warn(
@ -52,9 +52,7 @@ export function enterScheduledCallback(insideCallback: boolean): void {
/** /**
* Make sure that a time was passed into * Make sure that a time was passed into
*/ */
export function assertUsedScheduleTime( export function assertUsedScheduleTime(time?: Time): void {
time?: import("../type/Units").Time
): void {
if ( if (
isUndef(time) && isUndef(time) &&
isInsideScheduledCallback && isInsideScheduledCallback &&

View file

@ -4,8 +4,7 @@ import {
isAudioParam, isAudioParam,
} from "./AdvancedTypeCheck.js"; } from "./AdvancedTypeCheck.js";
import { isDefined, isObject, isUndef } from "./TypeCheck.js"; import { isDefined, isObject, isUndef } from "./TypeCheck.js";
import type { BaseToneOptions } from "../Tone.js";
type BaseToneOptions = import("../Tone").BaseToneOptions;
/** /**
* Some objects should not be merged * 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"; export { start } from "./core/Global.js";
import { Seconds } from "./core/type/Units.js"; import { Seconds } from "./core/type/Units.js";
export { supported } from "./core/context/AudioContext.js"; export { supported } from "./core/context/AudioContext.js";
import type { TransportClass } from "./core/clock/Transport"; import type { TransportClass } from "./core/clock/Transport.js";
import type { DestinationClass } from "./core/context/Destination"; import type { DestinationClass } from "./core/context/Destination.js";
import type { DrawClass } from "./core/util/Draw"; import type { DrawClass } from "./core/util/Draw.js";
import type { ListenerClass } from "./core/context/Listener"; import type { ListenerClass } from "./core/context/Listener.js";
/** /**
* The current audio context time of the global {@link BaseContext}. * 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 { TransportTimeClass } from "../core/type/TransportTime.js";
import { ToneConstantSource } from "./ToneConstantSource.js"; import { ToneConstantSource } from "./ToneConstantSource.js";
import { OutputNode } from "../core/context/ToneAudioNode.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} * Adds the ability to synchronize the signal to the {@link TransportClass}

View file

@ -1,6 +1,6 @@
import { analyze } from "./Spectrum.js"; import { analyze } from "./Spectrum.js";
import { TestAudioBuffer } from "./TestAudioBuffer.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 plotly from "plotly.js-dist";
import array2d from "array2d"; import array2d from "array2d";

View file

@ -1,5 +1,5 @@
import toWav from "audiobuffer-to-wav"; 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 { export class TestAudioBuffer {
static async fromUrl( static async fromUrl(

View file

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