diff --git a/.gitignore b/.gitignore index 740e43525b5a3..8e2c10d7b32bc 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ tests/cases/*/*/*.js.map tests/cases/*/*/*/*.js.map tests/cases/*/*/*/*/*.js.map tests/cases/rwc/* +tests/cases/test262/* tests/cases/perf/* !tests/cases/webharness/compilerToString.js test-args.txt @@ -19,6 +20,7 @@ tests/baselines/local/* tests/services/baselines/local/* tests/baselines/prototyping/local/* tests/baselines/rwc/* +tests/baselines/test262/* tests/services/baselines/prototyping/local/* tests/services/browser/typescriptServices.js scripts/processDiagnosticMessages.d.ts diff --git a/Jakefile b/Jakefile index ba82e9c3f4363..f76110bb5f2ee 100644 --- a/Jakefile +++ b/Jakefile @@ -78,6 +78,7 @@ var harnessSources = [ "projectsRunner.ts", "loggedIO.ts", "rwcRunner.ts", + "test262Runner.ts", "runner.ts" ].map(function (f) { return path.join(harnessDirectory, f); @@ -91,10 +92,12 @@ var harnessSources = [ var librarySourceMap = [ { target: "lib.core.d.ts", sources: ["core.d.ts"] }, - { target: "lib.dom.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "dom.generated.d.ts"], }, - { target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "webworker.generated.d.ts"], }, + { target: "lib.dom.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts"], }, + { target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "webworker.generated.d.ts"], }, { target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], }, - { target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], }, + { target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], }, + { target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]}, + { target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"]}, ]; var libraryTargets = librarySourceMap.map(function (f) { @@ -341,6 +344,9 @@ var refBaseline = "tests/baselines/reference/"; var localRwcBaseline = "tests/baselines/rwc/local/"; var refRwcBaseline = "tests/baselines/rwc/reference/"; +var localTest262Baseline = "tests/baselines/test262/local/"; +var refTest262Baseline = "tests/baselines/test262/reference/"; + desc("Builds the test infrastructure using the built compiler"); task("tests", ["local", run].concat(libraryTargets)); @@ -509,6 +515,12 @@ task("baseline-accept-rwc", function() { fs.renameSync(localRwcBaseline, refRwcBaseline); }); +desc("Makes the most recent test262 test results the new baseline, overwriting the old baseline"); +task("baseline-accept-test262", function() { + jake.rmRf(refTest262Baseline); + fs.renameSync(localTest262Baseline, refTest262Baseline); +}); + // Webhost var webhostPath = "tests/webhost/webtsc.ts"; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index dde4995cd991c..cea57352ae31b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5452,7 +5452,7 @@ module ts { forEach(rootNames, name => processRootFile(name, false)); if (!seenNoDefaultLib) { - processRootFile(host.getDefaultLibFilename(), true); + processRootFile(host.getDefaultLibFilename(options), true); } verifyCompilerOptions(); errors.sort(compareDiagnostics); @@ -5496,7 +5496,7 @@ module ts { } var diagnostic: DiagnosticMessage; if (hasExtension(filename)) { - if (!fileExtensionIs(filename, ".ts")) { + if (!options.allowNonTsExtensions && !fileExtensionIs(filename, ".ts")) { diagnostic = Diagnostics.File_0_must_have_extension_ts_or_d_ts; } else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 9bb2db719f120..333f80a663e97 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -193,7 +193,7 @@ module ts { return { getSourceFile, - getDefaultLibFilename: () => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), "lib.d.ts"), + getDefaultLibFilename: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts"), writeFile, getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()), useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index de90a49242ec2..e562cbc3b616d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1306,6 +1306,7 @@ module ts { version?: boolean; watch?: boolean; preserveConstEnums?: boolean; + allowNonTsExtensions?: boolean; [option: string]: string | number | boolean; } @@ -1487,7 +1488,7 @@ module ts { export interface CompilerHost { getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; - getDefaultLibFilename(): string; + getDefaultLibFilename(options: CompilerOptions): string; getCancellationToken? (): CancellationToken; writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; getCurrentDirectory(): string; diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index cc04d4813a1ae..fd49078d041bb 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -113,10 +113,7 @@ class CompilerBaselineRunner extends RunnerBase { for (var i = 0; i < tcSettings.length; ++i) { // noImplicitAny is passed to getCompiler, but target is just passed in the settings blob to setCompilerSettings if (!createNewInstance && (tcSettings[i].flag == "noimplicitany" || tcSettings[i].flag === 'target')) { - harnessCompiler = Harness.Compiler.getCompiler({ - useExistingInstance: false, - optionsForFreshInstance: { useMinimalDefaultLib: true, noImplicitAny: tcSettings[i].flag === "noimplicitany" } - }); + harnessCompiler = Harness.Compiler.getCompiler(); harnessCompiler.setCompilerSettings(tcSettings); createNewInstance = true; } @@ -125,10 +122,7 @@ class CompilerBaselineRunner extends RunnerBase { afterEach(() => { if (createNewInstance) { - harnessCompiler = Harness.Compiler.getCompiler({ - useExistingInstance: false, - optionsForFreshInstance: { useMinimalDefaultLib: true, noImplicitAny: false } - }); + harnessCompiler = Harness.Compiler.getCompiler(); createNewInstance = false; } }); @@ -323,10 +317,7 @@ class CompilerBaselineRunner extends RunnerBase { public initializeTests() { describe("Setup compiler for compiler baselines", () => { - var harnessCompiler = Harness.Compiler.getCompiler({ - useExistingInstance: false, - optionsForFreshInstance: { useMinimalDefaultLib: true, noImplicitAny: false } - }); + var harnessCompiler = Harness.Compiler.getCompiler(); this.parseOptions(); }); @@ -343,10 +334,7 @@ class CompilerBaselineRunner extends RunnerBase { } describe("Cleanup after compiler baselines", () => { - var harnessCompiler = Harness.Compiler.getCompiler({ - useExistingInstance: false, - optionsForFreshInstance: { useMinimalDefaultLib: true, noImplicitAny: false } - }); + var harnessCompiler = Harness.Compiler.getCompiler(); }); } diff --git a/src/harness/fourslashRunner.ts b/src/harness/fourslashRunner.ts index b7e5943745694..1ecb02df292ed 100644 --- a/src/harness/fourslashRunner.ts +++ b/src/harness/fourslashRunner.ts @@ -15,10 +15,6 @@ class FourslashRunner extends RunnerBase { } describe("fourslash tests", () => { - before(() => { - Harness.Compiler.getCompiler({ useExistingInstance: false }); - }); - this.tests.forEach((fn: string) => { fn = ts.normalizeSlashes(fn); var justName = fn.replace(/^.*[\\\/]/, ''); @@ -33,10 +29,6 @@ class FourslashRunner extends RunnerBase { }); } }); - - after(() => { - Harness.Compiler.getCompiler({ useExistingInstance: false }); - }); }); describe('Generate Tao XML', () => { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 1a5938d2be080..640d5f0ae5327 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1,3 +1,4 @@ + // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -538,6 +539,8 @@ module Harness { export var defaultLibFileName = 'lib.d.ts'; export var defaultLibSourceFile = ts.createSourceFile(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*version:*/ "0"); + export var defaultES6LibSourceFile = ts.createSourceFile(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*version:*/ "0"); + // Cache these between executions so we don't have to re-parse them for every test export var fourslashFilename = 'fourslash.ts'; @@ -580,15 +583,14 @@ module Harness { return fourslashSourceFile; } else { - var lib = defaultLibFileName; if (fn === defaultLibFileName) { - return defaultLibSourceFile; + return languageVersion === ts.ScriptTarget.ES6 ? defaultES6LibSourceFile : defaultLibSourceFile; } // Don't throw here -- the compiler might be looking for a test that actually doesn't exist as part of the TC return undefined; } }, - getDefaultLibFilename: () => defaultLibFileName, + getDefaultLibFilename: options => defaultLibFileName, writeFile, getCanonicalFileName, useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, @@ -1016,19 +1018,30 @@ module Harness { sys.newLine + sys.newLine + outputLines.join('\r\n'); } - /* TODO: Delete? - export function makeDefaultCompilerSettings(options?: { useMinimalDefaultLib: boolean; noImplicitAny: boolean; }) { - var useMinimalDefaultLib = options ? options.useMinimalDefaultLib : true; - var noImplicitAny = options ? options.noImplicitAny : false; - var settings = new TypeScript.CompilationSettings(); - settings.codeGenTarget = TypeScript.LanguageVersion.EcmaScript5; - settings.moduleGenTarget = TypeScript.ModuleGenTarget.Synchronous; - settings.noLib = useMinimalDefaultLib; - settings.noResolve = false; - settings.noImplicitAny = noImplicitAny; - return settings; + export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[], clean?: (s: string) => string) { + // Collect, test, and sort the filenames + function cleanName(fn: string) { + var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/'); + return fn.substr(lastSlash + 1).toLowerCase(); + } + outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName))); + + // Emit them + var result = ''; + ts.forEach(outputFiles, outputFile => { + // Some extra spacing if this isn't the first file + if (result.length) result = result + '\r\n\r\n'; + + // Filename header + content + result = result + '/*====== ' + outputFile.fileName + ' ======*/\r\n'; + if (clean) { + result = result + clean(outputFile.code); + } else { + result = result + outputFile.code; + } + }); + return result; } - */ /** The harness' compiler instance used when tests are actually run. Reseting or changing settings of this compiler instance must be done within a test case (i.e., describe/it) */ var harnessCompiler: HarnessCompiler; @@ -1036,7 +1049,7 @@ module Harness { /** Returns the singleton harness compiler instance for generating and running tests. If required a fresh compiler instance will be created, otherwise the existing singleton will be re-used. */ - export function getCompiler(opts?: { useExistingInstance: boolean; optionsForFreshInstance?: { useMinimalDefaultLib: boolean; noImplicitAny: boolean; } }) { + export function getCompiler() { return harnessCompiler = harnessCompiler || new HarnessCompiler(); } diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 4734232d2804d..f46f9ae369846 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -171,7 +171,7 @@ class ProjectRunner extends RunnerBase { function getSourceFile(filename: string, languageVersion: ts.ScriptTarget): ts.SourceFile { var sourceFile: ts.SourceFile = undefined; if (filename === Harness.Compiler.defaultLibFileName) { - sourceFile = Harness.Compiler.defaultLibSourceFile; + sourceFile = languageVersion === ts.ScriptTarget.ES6 ? Harness.Compiler.defaultES6LibSourceFile : Harness.Compiler.defaultLibSourceFile; } else { var text = getSourceFileText(filename); @@ -186,7 +186,7 @@ class ProjectRunner extends RunnerBase { function createCompilerHost(): ts.CompilerHost { return { getSourceFile, - getDefaultLibFilename: () => "lib.d.ts", + getDefaultLibFilename: options => options.target === ts.ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts", writeFile, getCurrentDirectory, getCanonicalFileName: Harness.Compiler.getCanonicalFileName, diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 38e23bb10c5e0..da37c02e2244c 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -13,9 +13,9 @@ // limitations under the License. // +/// /// -// TODO: re-enable -// /// +/// /// /// @@ -69,6 +69,9 @@ if (testConfigFile !== '') { case 'rwc': runners.push(new RWCRunner()); break; + case 'test262': + runners.push(new Test262BaselineRunner()); + break; case 'reverse': reverse = true; break; diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 606672e406fd7..b8bc2a80a529c 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -20,31 +20,6 @@ module RWC { } } - function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[], clean?: (s: string) => string) { - // Collect, test, and sort the filenames - function cleanName(fn: string) { - var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/'); - return fn.substr(lastSlash + 1).toLowerCase(); - } - outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName))); - - // Emit them - var result = ''; - ts.forEach(outputFiles, outputFile => { - // Some extra spacing if this isn't the first file - if (result.length) result = result + '\r\n\r\n'; - - // Filename header + content - result = result + '/*====== ' + outputFile.fileName + ' ======*/\r\n'; - if (clean) { - result = result + clean(outputFile.code); - } else { - result = result + outputFile.code; - } - }); - return result; - } - export function runRWCTest(jsonPath: string) { describe("Testing a RWC project: " + jsonPath, () => { var inputFiles: { unitName: string; content: string; }[] = []; @@ -136,7 +111,7 @@ module RWC { it('has the expected emitted code', () => { Harness.Baseline.runBaseline('has the expected emitted code', baseName + '.output.js', () => { - return collateOutputs(compilerResult.files, s => SyntacticCleaner.clean(s)); + return Harness.Compiler.collateOutputs(compilerResult.files, s => SyntacticCleaner.clean(s)); }, false, baselineOpts); }); @@ -145,7 +120,7 @@ module RWC { if (compilerResult.errors.length || !compilerResult.declFilesCode.length) { return null; } - return collateOutputs(compilerResult.declFilesCode); + return Harness.Compiler.collateOutputs(compilerResult.declFilesCode); }, false, baselineOpts); }); @@ -155,7 +130,7 @@ module RWC { return null; } - return collateOutputs(compilerResult.sourceMaps); + return Harness.Compiler.collateOutputs(compilerResult.sourceMaps); }, false, baselineOpts); }); diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts new file mode 100644 index 0000000000000..5527b9383d128 --- /dev/null +++ b/src/harness/test262Runner.ts @@ -0,0 +1,139 @@ +/// +/// +/// + +class Test262BaselineRunner extends RunnerBase { + private static basePath = 'tests/cases/test262'; + private static helpersFilePath = 'tests/cases/test262-harness/helpers.d.ts'; + private static helperFile = { + unitName: Test262BaselineRunner.helpersFilePath, + content: Harness.IO.readFile(Test262BaselineRunner.helpersFilePath) + }; + private static testFileExtensionRegex = /\.js$/; + private static options: ts.CompilerOptions = { + allowNonTsExtensions: true, + target: ts.ScriptTarget.Latest, + module: ts.ModuleKind.CommonJS + }; + private static baselineOptions: Harness.Baseline.BaselineOptions = { Subfolder: 'test262' }; + + private static getTestFilePath(filename: string): string { + return Test262BaselineRunner.basePath + "/" + filename; + } + + private static serializeSourceFile(file: ts.SourceFile): string { + function getKindName(k: number): string { + return (ts).SyntaxKind[k] + } + + function serializeNode(n: ts.Node): any { + var o = { kind: getKindName(n.kind) }; + ts.forEach(Object.getOwnPropertyNames(n), i => { + switch (i) { + case "parent": + case "symbol": + case "locals": + case "localSymbol": + case "kind": + case "semanticDiagnostics": + case "parseDiagnostics": + case "grammarDiagnostics": + return undefined; + case "nextContainer": + if (n.nextContainer) { + (o)[i] = { kind: getKindName(n.nextContainer.kind), pos: n.nextContainer.pos, end: n.nextContainer.end }; + return undefined; + } + case "text": + if (n.kind === ts.SyntaxKind.SourceFile) return undefined; + default: + (o)[i] = ((n)[i]); + } + return undefined; + }); + return o; + } + + return JSON.stringify(file,(k, v) => { + return (v && typeof v.pos === "number") ? serializeNode(v) : v; + }, " "); + } + + private runTest(filePath: string) { + describe('test262 test for ' + filePath, () => { + // Mocha holds onto the closure environment of the describe callback even after the test is done. + // Everything declared here should be cleared out in the "after" callback. + var testState: { + filename: string; + compilerResult: Harness.Compiler.CompilerResult; + inputFiles: { unitName: string; content: string }[]; + checker: ts.TypeChecker; + }; + + before(() => { + var content = Harness.IO.readFile(filePath); + var testFilename = ts.removeFileExtension(filePath).replace(/\//g, '_') + ".test"; + var testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, testFilename); + + var inputFiles = testCaseContent.testUnitData.map(unit => { + return { unitName: Test262BaselineRunner.getTestFilePath(unit.name), content: unit.content }; + }); + + // Emit the results + testState = { + filename: testFilename, + inputFiles: inputFiles, + compilerResult: undefined, + checker: undefined, + }; + + Harness.Compiler.getCompiler().compileFiles([Test262BaselineRunner.helperFile].concat(inputFiles), /*otherFiles*/ [], (compilerResult, checker) => { + testState.compilerResult = compilerResult; + testState.checker = checker; + }, /*settingsCallback*/ undefined, Test262BaselineRunner.options); + }); + + after(() => { + testState = undefined; + }); + + it('has the expected emitted code', () => { + Harness.Baseline.runBaseline('has the expected emitted code', testState.filename + '.output.js', () => { + var files = testState.compilerResult.files.filter(f=> f.fileName !== Test262BaselineRunner.helpersFilePath); + return Harness.Compiler.collateOutputs(files, s => SyntacticCleaner.clean(s)); + }, false, Test262BaselineRunner.baselineOptions); + }); + + it('has the expected errors', () => { + Harness.Baseline.runBaseline('has the expected errors', testState.filename + '.errors.txt', () => { + var errors = testState.compilerResult.errors; + if (errors.length === 0) { + return null; + } + + return Harness.Compiler.getErrorBaseline(testState.inputFiles, errors); + }, false, Test262BaselineRunner.baselineOptions); + }); + + it('has the expected AST',() => { + Harness.Baseline.runBaseline('has the expected AST', testState.filename + '.AST.txt',() => { + var sourceFile = testState.checker.getProgram().getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); + return Test262BaselineRunner.serializeSourceFile(sourceFile); + }, false, Test262BaselineRunner.baselineOptions); + }); + }); + } + + public initializeTests() { + // this will set up a series of describe/it blocks to run between the setup and cleanup phases + if (this.tests.length === 0) { + var testFiles = this.enumerateFiles(Test262BaselineRunner.basePath, Test262BaselineRunner.testFileExtensionRegex, { recursive: true }); + testFiles.forEach(fn => { + this.runTest(ts.normalizePath(fn)); + }); + } + else { + this.tests.forEach(test => this.runTest(test)); + } + } +} \ No newline at end of file diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 5abc7fe203747..1c87984bc2757 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -109,10 +109,7 @@ interface Object { propertyIsEnumerable(v: string): boolean; } -/** - * Provides functionality common to all JavaScript objects. - */ -declare var Object: { +interface ObjectConstructor { new (value?: any): Object; (): any; (value: any): any; @@ -206,6 +203,11 @@ declare var Object: { keys(o: any): string[]; } +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: ObjectConstructor; + /** * Creates a new function. */ @@ -240,8 +242,8 @@ interface Function { caller: Function; } -declare var Function: { - /** +interface FunctionConstructor { + /** * Creates a new function. * @param args A list of arguments the function accepts. */ @@ -250,6 +252,8 @@ declare var Function: { prototype: Function; } +declare var Function: FunctionConstructor; + interface IArguments { [index: number]: any; length: number; @@ -409,24 +413,29 @@ interface String { [index: number]: string; } -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ -declare var String: { +interface StringConstructor { new (value?: any): String; (value?: any): string; prototype: String; fromCharCode(...codes: number[]): string; } +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: StringConstructor; + interface Boolean { } -declare var Boolean: { + +interface BooleanConstructor { new (value?: any): Boolean; (value?: any): boolean; prototype: Boolean; } +declare var Boolean: BooleanConstructor; + interface Number { /** * Returns a string representation of an object. @@ -453,8 +462,7 @@ interface Number { toPrecision(precision?: number): string; } -/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: { +interface NumberConstructor { new (value?: any): Number; (value?: any): number; prototype: Number; @@ -484,6 +492,9 @@ declare var Number: { POSITIVE_INFINITY: number; } +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: NumberConstructor; + interface TemplateStringsArray extends Array { raw: string[]; } @@ -753,7 +764,7 @@ interface Date { toJSON(key?: any): string; } -declare var Date: { +interface DateConstructor { new (): Date; new (value: number): Date; new (value: string): Date; @@ -779,6 +790,8 @@ declare var Date: { now(): number; } +declare var Date: DateConstructor; + interface RegExpMatchArray extends Array { index?: number; input?: string; @@ -819,7 +832,8 @@ interface RegExp { // Non-standard extensions compile(): RegExp; } -declare var RegExp: { + +interface RegExpConstructor { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; prototype: RegExp; @@ -837,64 +851,87 @@ declare var RegExp: { lastMatch: string; } +declare var RegExp: RegExpConstructor; + interface Error { name: string; message: string; } -declare var Error: { + +interface ErrorConstructor { new (message?: string): Error; (message?: string): Error; prototype: Error; } +declare var Error: ErrorConstructor; + interface EvalError extends Error { } -declare var EvalError: { + +interface EvalErrorConstructor { new (message?: string): EvalError; (message?: string): EvalError; prototype: EvalError; } +declare var EvalError: EvalErrorConstructor; + interface RangeError extends Error { } -declare var RangeError: { + +interface RangeErrorConstructor { new (message?: string): RangeError; (message?: string): RangeError; prototype: RangeError; } +declare var RangeError: RangeErrorConstructor; + interface ReferenceError extends Error { } -declare var ReferenceError: { + +interface ReferenceErrorConstructor { new (message?: string): ReferenceError; (message?: string): ReferenceError; prototype: ReferenceError; } +declare var ReferenceError: ReferenceErrorConstructor; + interface SyntaxError extends Error { } -declare var SyntaxError: { + +interface SyntaxErrorConstructor { new (message?: string): SyntaxError; (message?: string): SyntaxError; prototype: SyntaxError; } +declare var SyntaxError: SyntaxErrorConstructor; + interface TypeError extends Error { } -declare var TypeError: { + +interface TypeErrorConstructor { new (message?: string): TypeError; (message?: string): TypeError; prototype: TypeError; } +declare var TypeError: TypeErrorConstructor; + interface URIError extends Error { } -declare var URIError: { + +interface URIErrorConstructor { new (message?: string): URIError; (message?: string): URIError; prototype: URIError; } +declare var URIError: URIErrorConstructor; + interface JSON { /** * Converts a JavaScript Object Notation (JSON) string into an object. @@ -1097,7 +1134,8 @@ interface Array { [n: number]: T; } -declare var Array: { + +interface ArrayConstructor { new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; @@ -1107,3 +1145,5 @@ declare var Array: { isArray(arg: any): boolean; prototype: Array; } + +declare var Array: ArrayConstructor; diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts new file mode 100644 index 0000000000000..0940f26cac5ba --- /dev/null +++ b/src/lib/es6.d.ts @@ -0,0 +1,3637 @@ +declare type PropertyKey = string | number | Symbol; + +interface Symbol { + /** Returns a string representation of an object. */ + toString(): string; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + // [Symbol.toStringTag]: string; +} + +interface SymbolConstructor { + /** + * A reference to the prototype. + */ + prototype: Symbol; + + /** + * Returns a new unique Symbol value. + * @param description Description of the new Symbol object. + */ + (description?: string|number): Symbol; + + /** + * Returns a Symbol object from the global symbol registry matching the given key if found. + * Otherwise, returns a new symbol with this key. + * @param key key to search for. + */ + for(key: string): Symbol; + + /** + * Returns a key from the global symbol registry matching the given Symbol if found. + * Otherwise, returns a undefined. + * @param sym Symbol to find the key for. + */ + keyFor(sym: Symbol): string; + + // Well-known Symbols + + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. + */ + hasInstance: Symbol; + + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ + isConcatSpreadable: Symbol; + + /** + * A Boolean value that if true indicates that an object may be used as a regular expression. + */ + isRegExp: Symbol; + + /** + * A method that returns the default iterator for an object.Called by the semantics of the + * for-of statement. + */ + iterator: Symbol; + + /** + * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive + * abstract operation. + */ + toPrimitive: Symbol; + + /** + * A String value that is used in the creation of the default string description of an object. + * Called by the built- in method Object.prototype.toString. + */ + toStringTag: Symbol; + + /** + * An Object whose own property names are property names that are excluded from the with + * environment bindings of the associated objects. + */ + unscopables: Symbol; +} +declare var Symbol: SymbolConstructor; + +interface Object { + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: PropertyKey): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: PropertyKey): boolean; +} + +interface ObjectConstructor { + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects to copy properties from. + */ + assign(target: any, ...sources: any[]): any; + + /** + * Returns an array of all symbol properties found directly on object o. + * @param o Object to retrieve the symbols from. + */ + getOwnPropertySymbols(o: any): Symbol[]; + + /** + * Returns true if the values are the same value, false otherwise. + * @param value1 The first value. + * @param value2 The second value. + */ + is(value1: any, value2: any): boolean; + + /** + * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * @param o The object to change its prototype. + * @param proto The value of the new prototype or null. + */ + setPrototypeOf(o: any, proto: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not + * inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript + * object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor + * property. + */ + defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; +} + +interface Function { + /** + * Returns a new function object that is identical to the argument object in all ways except + * for its identity and the value of its HomeObject internal slot. + */ + toMethod(newHome: Object): Function; + + /** + * Returns the name of the function. Function names are read-only and can not be changed. + */ + name: string; +} + +interface NumberConstructor { + /** + * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 + * that is representable as a Number value, which is approximately: + * 2.2204460492503130808472633361816 x 10‍−‍16. + */ + EPSILON: number; + + /** + * Returns true if passed value is finite. + * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * number. Only finite values of the type number, result in true. + * @param number A numeric value. + */ + isFinite(number: number): boolean; + + /** + * Returns true if the value passed is an integer, false otherwise. + * @param number A numeric value. + */ + isInteger(number: number): boolean; + + /** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a + * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter + * to a number. Only values of the type number, that are also NaN, result in true. + * @param number A numeric value. + */ + isNaN(number: number): boolean; + + /** + * Returns true if the value passed is a safe integer. + * @param number A numeric value. + */ + isSafeInteger(number: number): boolean; + + /** + * The value of the largest integer n such that n and n + 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. + */ + MAX_SAFE_INTEGER: number; + + /** + * The value of the smallest integer n such that n and n − 1 are both exactly representable as + * a Number value. + * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). + */ + MIN_SAFE_INTEGER: number; + + /** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ + parseFloat(string: string); + + /** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ + parseInt(string: string, radix?: number): number; +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + +interface Array { + /** Iterator */ + // [Symbol.iterator] (): Iterator; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, T]>; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: T) => boolean, thisArg?: any): number; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: T, start?: number, end?: number): T[]; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): T[]; +} + +interface ArrayConstructor { + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + + /** + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ + from(arrayLike: ArrayLike): Array; + + /** + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ + from(iterable: Iterable): Array; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: T[]): Array; +} + +interface String { + /** Iterator */ + // [Symbol.iterator] (): Iterator; + + /** + * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point + * value of the UTF-16 encoded code point starting at the string element at position pos in + * the String resulting from converting this object to a String. + * If there is no element at that position, the result is undefined. + * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. + */ + codePointAt(pos: number): number; + + /** + * Returns true if searchString appears as a substring of the result of converting this + * object to a String, at one or more positions that are + * greater than or equal to position; otherwise, returns false. + * @param searchString search string + * @param position If position is undefined, 0 is assumed, so as to search all of the String. + */ + contains(searchString: string, position?: number): boolean; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * endPosition – length(this). Otherwise returns false. + */ + endsWith(searchString: string, endPosition?: number): boolean; + + /** + * Returns the String value result of normalizing the string into the normalization form + * named by form as specified in Unicode Standard Annex #15, Unicode Normalization Forms. + * @param form Applicable values: "NFC", "NFD", "NFKC", or "NFKD", If not specified default + * is "NFC" + */ + normalize(form?: string): string; + + /** + * Returns a String value that is made from count copies appended together. If count is 0, + * T is the empty String is returned. + * @param count number of copies to append + */ + repeat(count: number): string; + + /** + * Returns true if the sequence of elements of searchString converted to a String is the + * same as the corresponding elements of this object (converted to a String) starting at + * position. Otherwise returns false. + */ + startsWith(searchString: string, position?: number): boolean; + + /** + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ + anchor(name: string): string; + + /** Returns a HTML element */ + big(): string; + + /** Returns a HTML element */ + blink(): string; + + /** Returns a HTML element */ + bold(): string; + + /** Returns a HTML element */ + fixed(): string + + /** Returns a HTML element and sets the color attribute value */ + fontcolor(color: string): string + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: number): string; + + /** Returns a HTML element and sets the size attribute value */ + fontsize(size: string): string; + + /** Returns an HTML element */ + italics(): string; + + /** Returns an HTML element and sets the href attribute value */ + link(url: string): string; + + /** Returns a HTML element */ + small(): string; + + /** Returns a HTML element */ + strike(): string; + + /** Returns a HTML element */ + sub(): string; + + /** Returns a HTML element */ + sup(): string; +} + +interface StringConstructor { + /** + * Return the String value whose elements are, in order, the elements in the List elements. + * If length is 0, the empty string is returned. + */ + fromCodePoint(...codePoints: number[]): string; + + /** + * String.raw is intended for use as a tag function of a Tagged Template String. When called + * as such the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. + * @param template A well-formed template string call site representation. + * @param substitutions A set of substitution values. + */ + raw(template: TemplateStringsArray, ...substitutions: any[]); +} + +interface IteratorResult { + done: boolean; + value?: T; +} + +interface Iterator { + //[Symbol.iterator](): Iterator; + next(): IteratorResult; +} + +interface Iterable { + //[Symbol.iterator](): Iterator; +} + +interface GeneratorFunction extends Function { + +} + +interface GeneratorFunctionConstructor { + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): GeneratorFunction; + (...args: string[]): GeneratorFunction; + prototype: GeneratorFunction; +} +declare var GeneratorFunction: GeneratorFunctionConstructor; + +interface Generator extends Iterator { + next(value?: any): IteratorResult; + throw (exception: any); + return (value: T); + // [Symbol.toStringTag]: string; +} + +interface Math { + /** + * Returns the number of leading zero bits in the 32-bit binary representation of a number. + * @param x A numeric expression. + */ + clz32(x: number): number; + + /** + * Returns the result of 32-bit multiplication of two numbers. + * @param x First number + * @param y Second number + */ + imul(x: number, y: number): number; + + /** + * Returns the sign of the x, indicating whether x is positive, negative or zero. + * @param x The numeric expression to test + */ + sign(x: number): number; + + /** + * Returns the base 10 logarithm of a number. + * @param x A numeric expression. + */ + log10(x: number): number; + + /** + * Returns the base 2 logarithm of a number. + * @param x A numeric expression. + */ + log2(x: number): number; + + /** + * Returns the natural logarithm of 1 + x. + * @param x A numeric expression. + */ + log1p(x: number): number; + + /** + * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of + * the natural logarithms). + * @param x A numeric expression. + */ + expm1(x: number): number; + + /** + * Returns the hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cosh(x: number): number; + + /** + * Returns the hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sinh(x: number): number; + + /** + * Returns the hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tanh(x: number): number; + + /** + * Returns the inverse hyperbolic cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + acosh(x: number): number; + + /** + * Returns the inverse hyperbolic sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + asinh(x: number): number; + + /** + * Returns the inverse hyperbolic tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + atanh(x: number): number; + + /** + * Returns the square root of the sum of squares of its arguments. + * @param values Values to compute the square root for. + * If no arguments are passed, the result is +0. + * If there is only one argument, the result is the absolute value. + * If any argument is +Infinity or -Infinity, the result is +Infinity. + * If any argument is NaN, the result is NaN. + * If all arguments are either +0 or −0, the result is +0. + */ + hypot(...values: number[] ): number; + + /** + * Returns the integral part of the a numeric expression, x, removing any fractional digits. + * If x is already an integer, the result is x. + * @param x A numeric expression. + */ + trunc(x: number): number; + + /** + * Returns the nearest single precision float representation of a number. + * @param x A numeric expression. + */ + fround(x: number): number; + + /** + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ + cbrt(x: number): number; + + // [Symbol.toStringTag]: string; +} + +interface RegExp { + // [Symbol.isRegExp]: boolean; + + /** + * Matches a string with a regular expression, and returns an array containing the results of + * that search. + * @param string A string to search within. + */ + match(string: string): string[]; + + /** + * Replaces text in a string, using a regular expression. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every + * successful match of rgExp in stringObj. + */ + replace(string: string, replaceValue: string): string; + + search(string: string): number; + + /** + * Returns an Array object into which substrings of the result of converting string to a String + * have been stored. The substrings are determined by searching from left to right for matches + * of the this value regular expression; these occurrences are not part of any substring in the + * returned array, but serve to divide up the String value. + * + * If the regular expression that contains capturing parentheses, then each time separator is + * matched the results (including any undefined results) of the capturing parentheses are spliced. + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than limit elements. + */ + split(string: string, limit?: number): string[]; + + /** + * Returns a Boolean value indicating the state of the sticky flag (y) used with a regular + * expression. Default is false. Read-only. + */ + sticky: boolean; + + /** + * Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular + * expression. Default is false. Read-only. + */ + unicode: boolean; +} + +interface Map { + clear(): void; + delete(key: K): boolean; + entries(): Iterator<[K, V]>; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + keys(): Iterator; + set(key: K, value?: V): Map; + size: number; + values(): Iterator; + // [Symbol.iterator]():Iterator<[K,V]>; + // [Symbol.toStringTag]: string; +} + +interface MapConstructor { + new (): Map; + new (iterable: Iterable<[K, V]>): Map; + prototype: Map; +} +declare var Map: MapConstructor; + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value?: V): WeakMap; + // [Symbol.toStringTag]: string; +} + +interface WeakMapConstructor { + new (): WeakMap; + new (iterable: Iterable<[K, V]>): WeakMap; + prototype: WeakMap; +} +declare var WeakMap: WeakMapConstructor; + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + entries(): Iterator<[T, T]>; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + keys(): Iterator; + size: number; + values(): Iterator; + // [Symbol.iterator]():Iterator; + // [Symbol.toStringTag]: string; +} + +interface SetConstructor { + new (): Set; + new (iterable: Iterable): Set; + prototype: Set; +} +declare var Set: SetConstructor; + +interface WeakSet { + add(value: T): WeakSet; + clear(): void; + delete(value: T): boolean; + has(value: T): boolean; + // [Symbol.toStringTag]: string; +} + +interface WeakSetConstructor { + new (): WeakSet; + new (iterable: Iterable): WeakSet; + prototype: WeakSet; +} +declare var WeakSet: WeakSetConstructor; + +interface JSON { + // [Symbol.toStringTag]: string; +} + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin: number, end?: number): ArrayBuffer; + + // [Symbol.toStringTag]: string; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian: boolean): void; + + // [Symbol.toStringTag]: string; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number); +} +declare var DataView: DataViewConstructor; + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Int8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int8Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int8Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: Int8Array): Int8Array; + new (array: number[]): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: Uint8Array): Uint8Array; + new (array: number[]): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: Uint8ClampedArray): Uint8ClampedArray; + new (array: number[]): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int16Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int16Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: Int16Array): Int16Array; + new (array: number[]): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint16Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint16Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: Uint16Array): Uint16Array; + new (array: number[]): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; +} +declare var Uint16Array: Uint16ArrayConstructor; + +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Int32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: Int32Array): Int32Array; + new (array: number[]): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Uint32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: Uint32Array): Uint32Array; + new (array: number[]): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float32Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float32Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: Float32Array): Float32Array; + new (array: number[]): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ + copyWithin(target: number, start: number, end?: number): Float64Array; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): Iterator<[number, number]>; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns an list of keys in the array + */ + keys(): Iterator; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float64Array, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If + * omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + /** + * Returns an list of values in the array + */ + values(): Iterator; + + [index: number]: number; + // [Symbol.iterator] (): Iterator; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: Float64Array): Float64Array; + new (array: number[]): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; + +interface ProxyHandler { + getPrototypeOf? (target: T): any; + setPrototypeOf? (target: T, v: any): boolean; + isExtensible? (target: T): boolean; + preventExtensions? (target: T): boolean; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor; + has? (target: T, p: PropertyKey): boolean; + get? (target: T, p: PropertyKey, receiver: any): any; + set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; + deleteProperty? (target: T, p: PropertyKey): boolean; + defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; + enumerate? (target: T): PropertyKey[]; + ownKeys? (target: T): PropertyKey[]; + apply? (target: T, thisArg: any, argArray?: any): any; + construct? (target: T, thisArg: any, argArray?: any): any; +} + +interface ProxyConstructor { + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handeler: ProxyHandler): T +} +declare var Proxy: ProxyConstructor; + +declare var Reflect: { + apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; + construct(target: Function, argumentsList: ArrayLike): any; + defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + deleteProperty(target: any, propertyKey: PropertyKey): boolean; + enumerate(target: any): Iterator; + get(target: any, propertyKey: PropertyKey, receiver?: any): any; + getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; + getPrototypeOf(target: any): any; + has(target: any, propertyKey: string): boolean; + has(target: any, propertyKey: Symbol): boolean; + isExtensible(target: any): boolean; + ownKeys(target: any): Array; + preventExtensions(target: any): boolean; + set(target: any, propertyKey: PropertyKey, value: any, receiver? :any): boolean; + setPrototypeOf(target: any, proto: any): boolean; +}; + +/** + * Represents the completion of an asynchronous operation + */ +interface Promise { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | Promise, onrejected?: (reason: any) => TResult | Promise): Promise; + + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: (reason: any) => T | Promise): Promise; +} + +interface PromiseConstructor { + /** + * A reference to the prototype. + */ + prototype: Promise; + + /** + * Creates a new Promise. + * @param init A callback used to initialize the promise. This callback is passed two arguments: + * a resolve callback used resolve the promise with a value or the result of another promise, + * and a reject callback used to reject the promise with a provided reason or error. + */ + new (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + + (init: (resolve: (value?: T | Promise) => void, reject: (reason?: any) => void) => void): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + all(values: (T | Promise)[]): Promise; + + /** + * Creates a Promise that is resolved with an array of results when all of the provided Promises + * resolve, or rejected when any Promise is rejected. + * @param values An array of values. + * @returns A new Promise. + */ + all(values: Promise[]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: (T | Promise)[]): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new rejected promise for the provided reason. + * @param reason The reason the promise was rejected. + * @returns A new rejected Promise. + */ + reject(reason: any): Promise; + + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | Promise): Promise; + + /** + * Creates a new resolved promise . + * @returns A resolved promise. + */ + resolve(): Promise; +} + +declare var Promise: PromiseConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +} \ No newline at end of file diff --git a/src/lib/extensions.d.ts b/src/lib/extensions.d.ts index f4387543c01aa..599d65bdfada8 100644 --- a/src/lib/extensions.d.ts +++ b/src/lib/extensions.d.ts @@ -658,169 +658,3 @@ declare var Set: { new (): Set; prototype: Set; } - -declare module Intl { - - interface CollatorOptions { - usage?: string; - localeMatcher?: string; - numeric?: boolean; - caseFirst?: string; - sensitivity?: string; - ignorePunctuation?: boolean; - } - - interface ResolvedCollatorOptions { - locale: string; - usage: string; - sensitivity: string; - ignorePunctuation: boolean; - collation: string; - caseFirst: string; - numeric: boolean; - } - - interface Collator { - compare(x: string, y: string): number; - resolvedOptions(): ResolvedCollatorOptions; - } - var Collator: { - new (locales?: string[], options?: CollatorOptions): Collator; - new (locale?: string, options?: CollatorOptions): Collator; - (locales?: string[], options?: CollatorOptions): Collator; - (locale?: string, options?: CollatorOptions): Collator; - supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; - supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; - } - - interface NumberFormatOptions { - localeMatcher?: string; - style?: string; - currency?: string; - currencyDisplay?: string; - useGrouping?: boolean; - } - - interface ResolvedNumberFormatOptions { - locale: string; - numberingSystem: string; - style: string; - currency?: string; - currencyDisplay?: string; - minimumintegerDigits: number; - minimumFractionDigits: number; - maximumFractionDigits: number; - minimumSignificantDigits?: number; - maximumSignificantDigits?: number; - useGrouping: boolean; - } - - interface NumberFormat { - format(value: number): string; - resolvedOptions(): ResolvedNumberFormatOptions; - } - var NumberFormat: { - new (locales?: string[], options?: NumberFormatOptions): Collator; - new (locale?: string, options?: NumberFormatOptions): Collator; - (locales?: string[], options?: NumberFormatOptions): Collator; - (locale?: string, options?: NumberFormatOptions): Collator; - supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; - } - - interface DateTimeFormatOptions { - localeMatcher?: string; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - formatMatcher?: string; - hour12: boolean; - } - - interface ResolvedDateTimeFormatOptions { - locale: string; - calendar: string; - numberingSystem: string; - timeZone: string; - hour12?: boolean; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - } - - interface DateTimeFormat { - format(date: number): string; - resolvedOptions(): ResolvedDateTimeFormatOptions; - } - var DateTimeFormat: { - new (locales?: string[], options?: DateTimeFormatOptions): Collator; - new (locale?: string, options?: DateTimeFormatOptions): Collator; - (locales?: string[], options?: DateTimeFormatOptions): Collator; - (locale?: string, options?: DateTimeFormatOptions): Collator; - supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; - } -} - -interface String { - /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. - * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. - */ - localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; - - /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. - * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. - */ - localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; -} - -interface Number { - /** - * Converts a number to a string by using the current or specified locale. - * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ - toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string; - - /** - * Converts a number to a string by using the current or specified locale. - * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ - toLocaleString(locale?: string, options?: Intl.NumberFormatOptions): string; -} - -interface Date { - /** - * Converts a date to a string by using the current or specified locale. - * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ - toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; - - /** - * Converts a date to a string by using the current or specified locale. - * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ - toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; -} - diff --git a/src/lib/intl.d.ts b/src/lib/intl.d.ts new file mode 100644 index 0000000000000..73672bd8deae4 --- /dev/null +++ b/src/lib/intl.d.ts @@ -0,0 +1,168 @@ +///////////////////////////// +/// ECMAScript Internationalization API +///////////////////////////// + +declare module Intl { + interface CollatorOptions { + usage?: string; + localeMatcher?: string; + numeric?: boolean; + caseFirst?: string; + sensitivity?: string; + ignorePunctuation?: boolean; + } + + interface ResolvedCollatorOptions { + locale: string; + usage: string; + sensitivity: string; + ignorePunctuation: boolean; + collation: string; + caseFirst: string; + numeric: boolean; + } + + interface Collator { + compare(x: string, y: string): number; + resolvedOptions(): ResolvedCollatorOptions; + } + var Collator: { + new (locales?: string[], options?: CollatorOptions): Collator; + new (locale?: string, options?: CollatorOptions): Collator; + (locales?: string[], options?: CollatorOptions): Collator; + (locale?: string, options?: CollatorOptions): Collator; + supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; + supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; + } + + interface NumberFormatOptions { + localeMatcher?: string; + style?: string; + currency?: string; + currencyDisplay?: string; + useGrouping?: boolean; + } + + interface ResolvedNumberFormatOptions { + locale: string; + numberingSystem: string; + style: string; + currency?: string; + currencyDisplay?: string; + minimumintegerDigits: number; + minimumFractionDigits: number; + maximumFractionDigits: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + useGrouping: boolean; + } + + interface NumberFormat { + format(value: number): string; + resolvedOptions(): ResolvedNumberFormatOptions; + } + var NumberFormat: { + new (locales?: string[], options?: NumberFormatOptions): Collator; + new (locale?: string, options?: NumberFormatOptions): Collator; + (locales?: string[], options?: NumberFormatOptions): Collator; + (locale?: string, options?: NumberFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; + } + + interface DateTimeFormatOptions { + localeMatcher?: string; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + formatMatcher?: string; + hour12: boolean; + } + + interface ResolvedDateTimeFormatOptions { + locale: string; + calendar: string; + numberingSystem: string; + timeZone: string; + hour12?: boolean; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + } + + interface DateTimeFormat { + format(date: number): string; + resolvedOptions(): ResolvedDateTimeFormatOptions; + } + var DateTimeFormat: { + new (locales?: string[], options?: DateTimeFormatOptions): Collator; + new (locale?: string, options?: DateTimeFormatOptions): Collator; + (locales?: string[], options?: DateTimeFormatOptions): Collator; + (locale?: string, options?: DateTimeFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; + } +} + +interface String { + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ + localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; +} + +interface Number { + /** + * Converts a number to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string; + + /** + * Converts a number to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.NumberFormatOptions): string; +} + +interface Date { + /** + * Converts a date to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; +} + diff --git a/src/services/services.ts b/src/services/services.ts index bc11d019cc5b8..37b5612c82373 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -863,7 +863,7 @@ module ts { getLocalizedDiagnosticMessages(): any; getCancellationToken(): CancellationToken; getCurrentDirectory(): string; - getDefaultLibFilename(): string; + getDefaultLibFilename(options: CompilerOptions): string; } // @@ -2098,8 +2098,8 @@ module ts { getCanonicalFileName: (filename) => useCaseSensitivefilenames ? filename : filename.toLowerCase(), useCaseSensitiveFileNames: () => useCaseSensitivefilenames, getNewLine: () => "\r\n", - getDefaultLibFilename: (): string => { - return host.getDefaultLibFilename(); + getDefaultLibFilename: (options): string => { + return host.getDefaultLibFilename(options); }, writeFile: (filename, data, writeByteOrderMark) => { writer(filename, data, writeByteOrderMark); @@ -2244,7 +2244,7 @@ module ts { filename = normalizeSlashes(filename); - return program.getDiagnostics(getSourceFile(filename).getSourceFile()); + return program.getDiagnostics(getSourceFile(filename)); } /** diff --git a/src/services/shims.ts b/src/services/shims.ts index 49603fd4a2eda..e1e95c1332c11 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -49,7 +49,7 @@ module ts { getLocalizedDiagnosticMessages(): string; getCancellationToken(): CancellationToken; getCurrentDirectory(): string; - getDefaultLibFilename(): string; + getDefaultLibFilename(options: string): string; } /// @@ -388,8 +388,8 @@ module ts { return this.shimHost.getCancellationToken(); } - public getDefaultLibFilename(): string { - return this.shimHost.getDefaultLibFilename(); + public getDefaultLibFilename(options: CompilerOptions): string { + return this.shimHost.getDefaultLibFilename(JSON.stringify(options)); } public getCurrentDirectory(): string { diff --git a/tests/baselines/reference/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.types b/tests/baselines/reference/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.types index 46084e856320c..ba24bf9344217 100644 --- a/tests/baselines/reference/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.types +++ b/tests/baselines/reference/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.types @@ -17,6 +17,6 @@ module A { export var beez2 = new Array(); >beez2 : B[] >new Array() : B[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor >B : B } diff --git a/tests/baselines/reference/arrayConcat2.types b/tests/baselines/reference/arrayConcat2.types index 4cd02d31f9d75..aa0e047803394 100644 --- a/tests/baselines/reference/arrayConcat2.types +++ b/tests/baselines/reference/arrayConcat2.types @@ -18,7 +18,7 @@ a.concat('Hello'); var b = new Array(); >b : string[] >new Array() : string[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor b.concat('hello'); >b.concat('hello') : string[] diff --git a/tests/baselines/reference/arrayConstructors1.types b/tests/baselines/reference/arrayConstructors1.types index 8b34f32205ef0..6dbdc0cd8f20b 100644 --- a/tests/baselines/reference/arrayConstructors1.types +++ b/tests/baselines/reference/arrayConstructors1.types @@ -6,19 +6,19 @@ x = new Array(1); >x = new Array(1) : any[] >x : string[] >new Array(1) : any[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor x = new Array('hi', 'bye'); >x = new Array('hi', 'bye') : string[] >x : string[] >new Array('hi', 'bye') : string[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor x = new Array('hi', 'bye'); >x = new Array('hi', 'bye') : string[] >x : string[] >new Array('hi', 'bye') : string[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor var y: number[]; >y : number[] @@ -27,17 +27,17 @@ y = new Array(1); >y = new Array(1) : any[] >y : number[] >new Array(1) : any[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor y = new Array(1,2); >y = new Array(1,2) : number[] >y : number[] >new Array(1,2) : number[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor y = new Array(1, 2); >y = new Array(1, 2) : number[] >y : number[] >new Array(1, 2) : number[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor diff --git a/tests/baselines/reference/arrayLiteral.types b/tests/baselines/reference/arrayLiteral.types index 9378a508228b6..a5ab7368937b6 100644 --- a/tests/baselines/reference/arrayLiteral.types +++ b/tests/baselines/reference/arrayLiteral.types @@ -8,7 +8,7 @@ var x = []; var x = new Array(1); >x : any[] >new Array(1) : any[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor var y = [1]; >y : number[] @@ -21,7 +21,7 @@ var y = [1, 2]; var y = new Array(); >y : number[] >new Array() : number[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor var x2: number[] = []; >x2 : number[] @@ -30,7 +30,7 @@ var x2: number[] = []; var x2: number[] = new Array(1); >x2 : number[] >new Array(1) : any[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor var y2: number[] = [1]; >y2 : number[] @@ -43,5 +43,5 @@ var y2: number[] = [1, 2]; var y2: number[] = new Array(); >y2 : number[] >new Array() : number[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor diff --git a/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt b/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt index 0dcff3de42217..0d29446159243 100644 --- a/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt +++ b/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt @@ -2,9 +2,9 @@ tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts( tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,30): error TS1109: Expression expected. tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,22): error TS1005: '=' expected. tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,32): error TS1109: Expression expected. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,5): error TS2322: Type 'number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; }'. +tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. Property 'isArray' is missing in type 'Number'. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,5): error TS2322: Type 'number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; }'. +tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. ==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts (6 errors) ==== @@ -19,7 +19,7 @@ tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts( ~ !!! error TS1109: Expression expected. ~~~ -!!! error TS2322: Type 'number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; }'. +!!! error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. !!! error TS2322: Property 'isArray' is missing in type 'Number'. var xs4: typeof Array; ~ @@ -27,4 +27,4 @@ tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts( ~ !!! error TS1109: Expression expected. ~~~ -!!! error TS2322: Type 'number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; }'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. \ No newline at end of file diff --git a/tests/baselines/reference/castNewObjectBug.types b/tests/baselines/reference/castNewObjectBug.types index c3a6cffb84fd5..b98b1576061dc 100644 --- a/tests/baselines/reference/castNewObjectBug.types +++ b/tests/baselines/reference/castNewObjectBug.types @@ -7,5 +7,5 @@ var xx = new Object(); > new Object() : Foo >Foo : Foo >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor diff --git a/tests/baselines/reference/commaOperatorWithSecondOperandObjectType.types b/tests/baselines/reference/commaOperatorWithSecondOperandObjectType.types index ebd102c0fde36..ba2663dd2714f 100644 --- a/tests/baselines/reference/commaOperatorWithSecondOperandObjectType.types +++ b/tests/baselines/reference/commaOperatorWithSecondOperandObjectType.types @@ -108,7 +108,7 @@ true, {} "string", new Date() >"string", new Date() : Date >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor STRING.toLowerCase(), new CLASS() >STRING.toLowerCase(), new CLASS() : CLASS @@ -154,7 +154,7 @@ var resultIsObject10 = ("string", new Date()); >("string", new Date()) : Date >"string", new Date() : Date >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor var resultIsObject11 = (STRING.toLowerCase(), new CLASS()); >resultIsObject11 : CLASS diff --git a/tests/baselines/reference/commaOperatorWithSecondOperandStringType.types b/tests/baselines/reference/commaOperatorWithSecondOperandStringType.types index 2fd182114bb95..d5b2f50ca33c1 100644 --- a/tests/baselines/reference/commaOperatorWithSecondOperandStringType.types +++ b/tests/baselines/reference/commaOperatorWithSecondOperandStringType.types @@ -90,7 +90,7 @@ ANY = new Date(), STRING; >ANY = new Date() : Date >ANY : any >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >STRING : string true, ""; @@ -115,7 +115,7 @@ OBJECT = new Object, STRING + "string"; >OBJECT = new Object : Object >OBJECT : Object >new Object : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor >STRING + "string" : string >STRING : string @@ -132,7 +132,7 @@ var resultIsString7 = (ANY = new Date(), STRING); >ANY = new Date() : Date >ANY : any >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >STRING : string var resultIsString8 = (true, ""); @@ -163,7 +163,7 @@ var resultIsString11 = (new Object, STRING + "string"); >(new Object, STRING + "string") : string >new Object, STRING + "string" : string >new Object : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor >STRING + "string" : string >STRING : string diff --git a/tests/baselines/reference/commaOperatorsMultipleOperators.types b/tests/baselines/reference/commaOperatorsMultipleOperators.types index 9297ea1aa47d8..12b90e8ec7786 100644 --- a/tests/baselines/reference/commaOperatorsMultipleOperators.types +++ b/tests/baselines/reference/commaOperatorsMultipleOperators.types @@ -112,7 +112,7 @@ null, true, 1; >STRING : string >charAt : (pos: number) => string >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor var resultIsNumber2 = (null, true, 1); >resultIsNumber2 : number @@ -132,5 +132,5 @@ var resultIsObject2 = (++NUMBER, STRING.charAt(0), new Object()); >STRING : string >charAt : (pos: number) => string >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor diff --git a/tests/baselines/reference/conditionalOperatorConditionIsObjectType.types b/tests/baselines/reference/conditionalOperatorConditionIsObjectType.types index 36c15d64c5432..199e93c62655a 100644 --- a/tests/baselines/reference/conditionalOperatorConditionIsObjectType.types +++ b/tests/baselines/reference/conditionalOperatorConditionIsObjectType.types @@ -133,7 +133,7 @@ foo() ? exprAny1 : exprAny2; new Date() ? exprBoolean1 : exprBoolean2; >new Date() ? exprBoolean1 : exprBoolean2 : boolean >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >exprBoolean1 : boolean >exprBoolean2 : boolean @@ -262,7 +262,7 @@ var resultIsBoolean3 = new Date() ? exprBoolean1 : exprBoolean2; >resultIsBoolean3 : boolean >new Date() ? exprBoolean1 : exprBoolean2 : boolean >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >exprBoolean1 : boolean >exprBoolean2 : boolean diff --git a/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types b/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types index 3e688cc7674a7..8241b319d846e 100644 --- a/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types +++ b/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types @@ -7,7 +7,7 @@ class Rule { >regex : RegExp >RegExp : RegExp >new RegExp('') : RegExp ->RegExp : { (pattern: string, flags?: string): RegExp; new (pattern: string, flags?: string): RegExp; prototype: RegExp; $1: string; $2: string; $3: string; $4: string; $5: string; $6: string; $7: string; $8: string; $9: string; lastMatch: string; } +>RegExp : RegExpConstructor public name: string = ''; >name : string diff --git a/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt b/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt index 04b80fb110406..bf9006a7143a1 100644 --- a/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt +++ b/tests/baselines/reference/errorMessageOnObjectLiteralType.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/errorMessageOnObjectLiteralType.ts(5,3): error TS2339: Property 'getOwnPropertyNamess' does not exist on type '{ a: string; b: number; }'. -tests/cases/compiler/errorMessageOnObjectLiteralType.ts(6,8): error TS2339: Property 'getOwnPropertyNamess' does not exist on type '{ (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; }'. +tests/cases/compiler/errorMessageOnObjectLiteralType.ts(6,8): error TS2339: Property 'getOwnPropertyNamess' does not exist on type 'ObjectConstructor'. ==== tests/cases/compiler/errorMessageOnObjectLiteralType.ts (2 errors) ==== @@ -12,4 +12,4 @@ tests/cases/compiler/errorMessageOnObjectLiteralType.ts(6,8): error TS2339: Prop !!! error TS2339: Property 'getOwnPropertyNamess' does not exist on type '{ a: string; b: number; }'. Object.getOwnPropertyNamess(null); ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2339: Property 'getOwnPropertyNamess' does not exist on type '{ (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; }'. \ No newline at end of file +!!! error TS2339: Property 'getOwnPropertyNamess' does not exist on type 'ObjectConstructor'. \ No newline at end of file diff --git a/tests/baselines/reference/everyTypeWithAnnotationAndInitializer.types b/tests/baselines/reference/everyTypeWithAnnotationAndInitializer.types index 54dcc67b78a7f..c707e69446837 100644 --- a/tests/baselines/reference/everyTypeWithAnnotationAndInitializer.types +++ b/tests/baselines/reference/everyTypeWithAnnotationAndInitializer.types @@ -67,13 +67,13 @@ var aDate: Date = new Date(12); >aDate : Date >Date : Date >new Date(12) : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor var anObject: Object = new Object(); >anObject : Object >Object : Object >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor var anAny: any = null; >anAny : any diff --git a/tests/baselines/reference/everyTypeWithInitializer.types b/tests/baselines/reference/everyTypeWithInitializer.types index 3ebe8368f352f..7a0318718e422 100644 --- a/tests/baselines/reference/everyTypeWithInitializer.types +++ b/tests/baselines/reference/everyTypeWithInitializer.types @@ -66,12 +66,12 @@ var aString = 'this is a string'; var aDate = new Date(12); >aDate : Date >new Date(12) : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor var anObject = new Object(); >anObject : Object >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor var anAny = null; >anAny : any diff --git a/tests/baselines/reference/exportAssignValueAndType.types b/tests/baselines/reference/exportAssignValueAndType.types index 7d18e3c16552d..fca84f399ece9 100644 --- a/tests/baselines/reference/exportAssignValueAndType.types +++ b/tests/baselines/reference/exportAssignValueAndType.types @@ -25,7 +25,7 @@ var x = 5; var server = new Date(); >server : Date >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor export = server; >server : server diff --git a/tests/baselines/reference/exportEqualNamespaces.types b/tests/baselines/reference/exportEqualNamespaces.types index 5d3afc2731a94..0f3091c1b8af0 100644 --- a/tests/baselines/reference/exportEqualNamespaces.types +++ b/tests/baselines/reference/exportEqualNamespaces.types @@ -25,7 +25,7 @@ var x = 5; var server = new Date(); >server : Date >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor export = server; >server : server diff --git a/tests/baselines/reference/forStatements.types b/tests/baselines/reference/forStatements.types index fad702213df78..a5563a190eca9 100644 --- a/tests/baselines/reference/forStatements.types +++ b/tests/baselines/reference/forStatements.types @@ -67,13 +67,13 @@ for(var aDate: Date = new Date(12);;){} >aDate : Date >Date : Date >new Date(12) : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor for(var anObject: Object = new Object();;){} >anObject : Object >Object : Object >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor for(var anAny: any = null;;){} >anAny : any diff --git a/tests/baselines/reference/forStatementsMultipleValidDecl.types b/tests/baselines/reference/forStatementsMultipleValidDecl.types index c2458a306c778..988a1c8a6d3a0 100644 --- a/tests/baselines/reference/forStatementsMultipleValidDecl.types +++ b/tests/baselines/reference/forStatementsMultipleValidDecl.types @@ -118,7 +118,7 @@ for (var a: string[] = []; ;) { } for (var a = new Array(); ;) { } >a : string[] >new Array() : string[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor for (var a: typeof a; ;) { } >a : string[] diff --git a/tests/baselines/reference/functionConstraintSatisfaction.types b/tests/baselines/reference/functionConstraintSatisfaction.types index 70200af6fa915..7363fa162d3fe 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction.types +++ b/tests/baselines/reference/functionConstraintSatisfaction.types @@ -41,7 +41,7 @@ var r = foo(new Function()); >foo(new Function()) : Function >foo : (x: T) => T >new Function() : Function ->Function : { (...args: string[]): Function; new (...args: string[]): Function; prototype: Function; } +>Function : FunctionConstructor var r1 = foo((x) => x); >r1 : (x: any) => any diff --git a/tests/baselines/reference/functionOnlyHasThrow.types b/tests/baselines/reference/functionOnlyHasThrow.types index 0f76f4be39da7..d37284f547c98 100644 --- a/tests/baselines/reference/functionOnlyHasThrow.types +++ b/tests/baselines/reference/functionOnlyHasThrow.types @@ -4,5 +4,5 @@ function clone():number { throw new Error("To be implemented"); >new Error("To be implemented") : Error ->Error : { (message?: string): Error; new (message?: string): Error; prototype: Error; } +>Error : ErrorConstructor } diff --git a/tests/baselines/reference/functionType.types b/tests/baselines/reference/functionType.types index 4bbce7e096a86..29a940db205b7 100644 --- a/tests/baselines/reference/functionType.types +++ b/tests/baselines/reference/functionType.types @@ -13,7 +13,7 @@ salt.apply("hello", []); >(new Function("return 5"))() : any >(new Function("return 5")) : Function >new Function("return 5") : Function ->Function : { (...args: string[]): Function; new (...args: string[]): Function; prototype: Function; } +>Function : FunctionConstructor diff --git a/tests/baselines/reference/genericFunctionsWithOptionalParameters3.types b/tests/baselines/reference/genericFunctionsWithOptionalParameters3.types index 4df903242832e..fbb4780274f34 100644 --- a/tests/baselines/reference/genericFunctionsWithOptionalParameters3.types +++ b/tests/baselines/reference/genericFunctionsWithOptionalParameters3.types @@ -68,7 +68,7 @@ var r3 = utils.mapReduce(c, (x) => { return 1 }, (y) => { return new Date() }); >(y) => { return new Date() } : (y: number) => Date >y : number >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor var r4 = utils.mapReduce(c, (x: string) => { return 1 }, (y: number) => { return new Date() }); >r4 : Collection @@ -82,7 +82,7 @@ var r4 = utils.mapReduce(c, (x: string) => { return 1 }, (y: number) => { return >(y: number) => { return new Date() } : (y: number) => Date >y : number >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor var f1 = (x: string) => { return 1 }; >f1 : (x: string) => number @@ -94,7 +94,7 @@ var f2 = (y: number) => { return new Date() }; >(y: number) => { return new Date() } : (y: number) => Date >y : number >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor var r5 = utils.mapReduce(c, f1, f2); >r5 : Collection diff --git a/tests/baselines/reference/getterSetterNonAccessor.types b/tests/baselines/reference/getterSetterNonAccessor.types index d0b925f99e07f..f3e5d549cff81 100644 --- a/tests/baselines/reference/getterSetterNonAccessor.types +++ b/tests/baselines/reference/getterSetterNonAccessor.types @@ -9,7 +9,7 @@ function setFunc(v){} Object.defineProperty({}, "0", ({ >Object.defineProperty({}, "0", ({ get: getFunc, set: setFunc, configurable: true })) : any >Object.defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor >defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any >{} : {} >({ get: getFunc, set: setFunc, configurable: true }) : PropertyDescriptor diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.types b/tests/baselines/reference/heterogeneousArrayLiterals.types index 7ea7d4196a651..dc4e21d85eeac 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.types +++ b/tests/baselines/reference/heterogeneousArrayLiterals.types @@ -22,7 +22,7 @@ var e = [{}, Object]; // {}[] >e : {}[] >[{}, Object] : {}[] >{} : {} ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor var f = [[], [1]]; // number[][] >f : number[][] diff --git a/tests/baselines/reference/implementArrayInterface.js b/tests/baselines/reference/implementArrayInterface.js index 18ababcc5c60b..b75de77ea979f 100644 --- a/tests/baselines/reference/implementArrayInterface.js +++ b/tests/baselines/reference/implementArrayInterface.js @@ -1,5 +1,5 @@ //// [implementArrayInterface.ts] -declare class ArrayConstructor implements Array { +declare class MyArray implements Array { toString(): string; toLocaleString(): string; concat(...items: U[]): T[]; diff --git a/tests/baselines/reference/implementArrayInterface.types b/tests/baselines/reference/implementArrayInterface.types index 68d192cee6f9d..347fcf37693e6 100644 --- a/tests/baselines/reference/implementArrayInterface.types +++ b/tests/baselines/reference/implementArrayInterface.types @@ -1,6 +1,6 @@ === tests/cases/compiler/implementArrayInterface.ts === -declare class ArrayConstructor implements Array { ->ArrayConstructor : ArrayConstructor +declare class MyArray implements Array { +>MyArray : MyArray >T : T >Array : T[] >T : T diff --git a/tests/baselines/reference/library_ArraySlice.types b/tests/baselines/reference/library_ArraySlice.types index f1309844913cd..378724c74e456 100644 --- a/tests/baselines/reference/library_ArraySlice.types +++ b/tests/baselines/reference/library_ArraySlice.types @@ -4,7 +4,7 @@ Array.prototype.slice(); >Array.prototype.slice() : any[] >Array.prototype.slice : (start?: number, end?: number) => any[] >Array.prototype : any[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor >prototype : any[] >slice : (start?: number, end?: number) => any[] @@ -12,7 +12,7 @@ Array.prototype.slice(0); >Array.prototype.slice(0) : any[] >Array.prototype.slice : (start?: number, end?: number) => any[] >Array.prototype : any[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor >prototype : any[] >slice : (start?: number, end?: number) => any[] @@ -20,7 +20,7 @@ Array.prototype.slice(0, 1); >Array.prototype.slice(0, 1) : any[] >Array.prototype.slice : (start?: number, end?: number) => any[] >Array.prototype : any[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor >prototype : any[] >slice : (start?: number, end?: number) => any[] diff --git a/tests/baselines/reference/library_DatePrototypeProperties.types b/tests/baselines/reference/library_DatePrototypeProperties.types index 15f4c860fa599..35dcea318be95 100644 --- a/tests/baselines/reference/library_DatePrototypeProperties.types +++ b/tests/baselines/reference/library_DatePrototypeProperties.types @@ -4,7 +4,7 @@ Date.prototype.constructor; >Date.prototype.constructor : Function >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >constructor : Function @@ -12,7 +12,7 @@ Date.prototype.toString(); >Date.prototype.toString() : string >Date.prototype.toString : () => string >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >toString : () => string @@ -20,7 +20,7 @@ Date.prototype.toDateString(); >Date.prototype.toDateString() : string >Date.prototype.toDateString : () => string >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >toDateString : () => string @@ -28,7 +28,7 @@ Date.prototype.toTimeString(); >Date.prototype.toTimeString() : string >Date.prototype.toTimeString : () => string >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >toTimeString : () => string @@ -36,7 +36,7 @@ Date.prototype.toLocaleString(); >Date.prototype.toLocaleString() : string >Date.prototype.toLocaleString : () => string >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >toLocaleString : () => string @@ -44,7 +44,7 @@ Date.prototype.toLocaleDateString(); >Date.prototype.toLocaleDateString() : string >Date.prototype.toLocaleDateString : () => string >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >toLocaleDateString : () => string @@ -52,7 +52,7 @@ Date.prototype.toLocaleTimeString(); >Date.prototype.toLocaleTimeString() : string >Date.prototype.toLocaleTimeString : () => string >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >toLocaleTimeString : () => string @@ -60,7 +60,7 @@ Date.prototype.valueOf(); >Date.prototype.valueOf() : number >Date.prototype.valueOf : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >valueOf : () => number @@ -68,7 +68,7 @@ Date.prototype.getTime(); >Date.prototype.getTime() : number >Date.prototype.getTime : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getTime : () => number @@ -76,7 +76,7 @@ Date.prototype.getFullYear(); >Date.prototype.getFullYear() : number >Date.prototype.getFullYear : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getFullYear : () => number @@ -84,7 +84,7 @@ Date.prototype.getUTCFullYear(); >Date.prototype.getUTCFullYear() : number >Date.prototype.getUTCFullYear : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getUTCFullYear : () => number @@ -92,7 +92,7 @@ Date.prototype.getMonth(); >Date.prototype.getMonth() : number >Date.prototype.getMonth : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getMonth : () => number @@ -100,7 +100,7 @@ Date.prototype.getUTCMonth(); >Date.prototype.getUTCMonth() : number >Date.prototype.getUTCMonth : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getUTCMonth : () => number @@ -108,7 +108,7 @@ Date.prototype.getDate(); >Date.prototype.getDate() : number >Date.prototype.getDate : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getDate : () => number @@ -116,7 +116,7 @@ Date.prototype.getUTCDate(); >Date.prototype.getUTCDate() : number >Date.prototype.getUTCDate : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getUTCDate : () => number @@ -124,7 +124,7 @@ Date.prototype.getDay(); >Date.prototype.getDay() : number >Date.prototype.getDay : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getDay : () => number @@ -132,7 +132,7 @@ Date.prototype.getUTCDay(); >Date.prototype.getUTCDay() : number >Date.prototype.getUTCDay : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getUTCDay : () => number @@ -140,7 +140,7 @@ Date.prototype.getHours(); >Date.prototype.getHours() : number >Date.prototype.getHours : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getHours : () => number @@ -148,7 +148,7 @@ Date.prototype.getUTCHours(); >Date.prototype.getUTCHours() : number >Date.prototype.getUTCHours : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getUTCHours : () => number @@ -156,7 +156,7 @@ Date.prototype.getMinutes(); >Date.prototype.getMinutes() : number >Date.prototype.getMinutes : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getMinutes : () => number @@ -164,7 +164,7 @@ Date.prototype.getUTCMinutes(); >Date.prototype.getUTCMinutes() : number >Date.prototype.getUTCMinutes : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getUTCMinutes : () => number @@ -172,7 +172,7 @@ Date.prototype.getSeconds(); >Date.prototype.getSeconds() : number >Date.prototype.getSeconds : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getSeconds : () => number @@ -180,7 +180,7 @@ Date.prototype.getUTCSeconds(); >Date.prototype.getUTCSeconds() : number >Date.prototype.getUTCSeconds : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getUTCSeconds : () => number @@ -188,7 +188,7 @@ Date.prototype.getMilliseconds(); >Date.prototype.getMilliseconds() : number >Date.prototype.getMilliseconds : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getMilliseconds : () => number @@ -196,7 +196,7 @@ Date.prototype.getUTCMilliseconds(); >Date.prototype.getUTCMilliseconds() : number >Date.prototype.getUTCMilliseconds : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getUTCMilliseconds : () => number @@ -204,7 +204,7 @@ Date.prototype.getTimezoneOffset(); >Date.prototype.getTimezoneOffset() : number >Date.prototype.getTimezoneOffset : () => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >getTimezoneOffset : () => number @@ -212,7 +212,7 @@ Date.prototype.setTime(0); >Date.prototype.setTime(0) : number >Date.prototype.setTime : (time: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setTime : (time: number) => number @@ -220,7 +220,7 @@ Date.prototype.setMilliseconds(0); >Date.prototype.setMilliseconds(0) : number >Date.prototype.setMilliseconds : (ms: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setMilliseconds : (ms: number) => number @@ -228,7 +228,7 @@ Date.prototype.setUTCMilliseconds(0); >Date.prototype.setUTCMilliseconds(0) : number >Date.prototype.setUTCMilliseconds : (ms: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setUTCMilliseconds : (ms: number) => number @@ -236,7 +236,7 @@ Date.prototype.setSeconds(0); >Date.prototype.setSeconds(0) : number >Date.prototype.setSeconds : (sec: number, ms?: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setSeconds : (sec: number, ms?: number) => number @@ -244,7 +244,7 @@ Date.prototype.setUTCSeconds(0); >Date.prototype.setUTCSeconds(0) : number >Date.prototype.setUTCSeconds : (sec: number, ms?: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setUTCSeconds : (sec: number, ms?: number) => number @@ -252,7 +252,7 @@ Date.prototype.setMinutes(0); >Date.prototype.setMinutes(0) : number >Date.prototype.setMinutes : (min: number, sec?: number, ms?: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setMinutes : (min: number, sec?: number, ms?: number) => number @@ -260,7 +260,7 @@ Date.prototype.setUTCMinutes(0); >Date.prototype.setUTCMinutes(0) : number >Date.prototype.setUTCMinutes : (min: number, sec?: number, ms?: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setUTCMinutes : (min: number, sec?: number, ms?: number) => number @@ -268,7 +268,7 @@ Date.prototype.setHours(0); >Date.prototype.setHours(0) : number >Date.prototype.setHours : (hours: number, min?: number, sec?: number, ms?: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setHours : (hours: number, min?: number, sec?: number, ms?: number) => number @@ -276,7 +276,7 @@ Date.prototype.setUTCHours(0); >Date.prototype.setUTCHours(0) : number >Date.prototype.setUTCHours : (hours: number, min?: number, sec?: number, ms?: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setUTCHours : (hours: number, min?: number, sec?: number, ms?: number) => number @@ -284,7 +284,7 @@ Date.prototype.setDate(0); >Date.prototype.setDate(0) : number >Date.prototype.setDate : (date: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setDate : (date: number) => number @@ -292,7 +292,7 @@ Date.prototype.setUTCDate(0); >Date.prototype.setUTCDate(0) : number >Date.prototype.setUTCDate : (date: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setUTCDate : (date: number) => number @@ -300,7 +300,7 @@ Date.prototype.setMonth(0); >Date.prototype.setMonth(0) : number >Date.prototype.setMonth : (month: number, date?: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setMonth : (month: number, date?: number) => number @@ -308,7 +308,7 @@ Date.prototype.setUTCMonth(0); >Date.prototype.setUTCMonth(0) : number >Date.prototype.setUTCMonth : (month: number, date?: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setUTCMonth : (month: number, date?: number) => number @@ -316,7 +316,7 @@ Date.prototype.setFullYear(0); >Date.prototype.setFullYear(0) : number >Date.prototype.setFullYear : (year: number, month?: number, date?: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setFullYear : (year: number, month?: number, date?: number) => number @@ -324,7 +324,7 @@ Date.prototype.setUTCFullYear(0); >Date.prototype.setUTCFullYear(0) : number >Date.prototype.setUTCFullYear : (year: number, month?: number, date?: number) => number >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >setUTCFullYear : (year: number, month?: number, date?: number) => number @@ -332,7 +332,7 @@ Date.prototype.toUTCString(); >Date.prototype.toUTCString() : string >Date.prototype.toUTCString : () => string >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >toUTCString : () => string @@ -340,7 +340,7 @@ Date.prototype.toISOString(); >Date.prototype.toISOString() : string >Date.prototype.toISOString : () => string >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >toISOString : () => string @@ -348,7 +348,7 @@ Date.prototype.toJSON(null); >Date.prototype.toJSON(null) : string >Date.prototype.toJSON : (key?: any) => string >Date.prototype : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor >prototype : Date >toJSON : (key?: any) => string diff --git a/tests/baselines/reference/library_ObjectPrototypeProperties.types b/tests/baselines/reference/library_ObjectPrototypeProperties.types index 447d855778fb3..c848ccbe512ce 100644 --- a/tests/baselines/reference/library_ObjectPrototypeProperties.types +++ b/tests/baselines/reference/library_ObjectPrototypeProperties.types @@ -4,7 +4,7 @@ Object.prototype.constructor; >Object.prototype.constructor : Function >Object.prototype : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor >prototype : Object >constructor : Function @@ -12,7 +12,7 @@ Object.prototype.toString(); >Object.prototype.toString() : string >Object.prototype.toString : () => string >Object.prototype : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor >prototype : Object >toString : () => string @@ -20,7 +20,7 @@ Object.prototype.toLocaleString(); >Object.prototype.toLocaleString() : string >Object.prototype.toLocaleString : () => string >Object.prototype : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor >prototype : Object >toLocaleString : () => string @@ -28,7 +28,7 @@ Object.prototype.valueOf(); >Object.prototype.valueOf() : Object >Object.prototype.valueOf : () => Object >Object.prototype : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor >prototype : Object >valueOf : () => Object @@ -36,7 +36,7 @@ Object.prototype.hasOwnProperty("string"); >Object.prototype.hasOwnProperty("string") : boolean >Object.prototype.hasOwnProperty : (v: string) => boolean >Object.prototype : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor >prototype : Object >hasOwnProperty : (v: string) => boolean @@ -44,16 +44,16 @@ Object.prototype.isPrototypeOf(Object); >Object.prototype.isPrototypeOf(Object) : boolean >Object.prototype.isPrototypeOf : (v: Object) => boolean >Object.prototype : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor >prototype : Object >isPrototypeOf : (v: Object) => boolean ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor Object.prototype.propertyIsEnumerable("string"); >Object.prototype.propertyIsEnumerable("string") : boolean >Object.prototype.propertyIsEnumerable : (v: string) => boolean >Object.prototype : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor >prototype : Object >propertyIsEnumerable : (v: string) => boolean diff --git a/tests/baselines/reference/library_StringSlice.types b/tests/baselines/reference/library_StringSlice.types index 4733ab39908d0..c40c4d744e0cd 100644 --- a/tests/baselines/reference/library_StringSlice.types +++ b/tests/baselines/reference/library_StringSlice.types @@ -4,7 +4,7 @@ String.prototype.slice(); >String.prototype.slice() : string >String.prototype.slice : (start?: number, end?: number) => string >String.prototype : String ->String : { (value?: any): string; new (value?: any): String; prototype: String; fromCharCode(...codes: number[]): string; } +>String : StringConstructor >prototype : String >slice : (start?: number, end?: number) => string @@ -12,7 +12,7 @@ String.prototype.slice(0); >String.prototype.slice(0) : string >String.prototype.slice : (start?: number, end?: number) => string >String.prototype : String ->String : { (value?: any): string; new (value?: any): String; prototype: String; fromCharCode(...codes: number[]): string; } +>String : StringConstructor >prototype : String >slice : (start?: number, end?: number) => string @@ -20,7 +20,7 @@ String.prototype.slice(0,1); >String.prototype.slice(0,1) : string >String.prototype.slice : (start?: number, end?: number) => string >String.prototype : String ->String : { (value?: any): string; new (value?: any): String; prototype: String; fromCharCode(...codes: number[]): string; } +>String : StringConstructor >prototype : String >slice : (start?: number, end?: number) => string diff --git a/tests/baselines/reference/newArrays.types b/tests/baselines/reference/newArrays.types index ab2d7165980d7..463525cb04c85 100644 --- a/tests/baselines/reference/newArrays.types +++ b/tests/baselines/reference/newArrays.types @@ -27,7 +27,7 @@ module M { >this : Gar >fa : Foo[] >new Array(this.x * this.y) : Foo[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor >Foo : Foo >this.x * this.y : number >this.x : number diff --git a/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types b/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types index aa81f87bed6bf..066f5eadef468 100644 --- a/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types +++ b/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types @@ -51,13 +51,13 @@ var r4 = true ? new Date() : null; >r4 : Date >true ? new Date() : null : Date >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor var r4 = true ? null : new Date(); >r4 : Date >true ? null : new Date() : Date >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor var r5 = true ? /1/ : null; >r5 : RegExp @@ -281,13 +281,13 @@ var r19 = true ? new Object() : null; >r19 : Object >true ? new Object() : null : Object >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor var r19 = true ? null : new Object(); >r19 : Object >true ? null : new Object() : Object >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor var r20 = true ? {} : null; >r20 : {} diff --git a/tests/baselines/reference/objectLitGetterSetter.types b/tests/baselines/reference/objectLitGetterSetter.types index 2215f60d88914..92decfd4068d1 100644 --- a/tests/baselines/reference/objectLitGetterSetter.types +++ b/tests/baselines/reference/objectLitGetterSetter.types @@ -6,7 +6,7 @@ Object.defineProperty(obj, "accProperty", ({ >Object.defineProperty(obj, "accProperty", ({ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } })) : any >Object.defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor >defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any >obj : {} >({ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } }) : PropertyDescriptor diff --git a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types index febc7524e6db0..74b5550fecb63 100644 --- a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types +++ b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types @@ -343,43 +343,43 @@ var r13 = i[-01] >-01 : number var b = { ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }; } ->{ "0.1": null, ".1": new Object(), "1": 1, "1.": "", "1..": true, "1.0": new Date(), "-1.0": /123/, "-1": Date} : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }; } +>b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>{ "0.1": null, ".1": new Object(), "1": 1, "1.": "", "1..": true, "1.0": new Date(), "-1.0": /123/, "-1": Date} : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } "0.1": null, >null : void ".1": new Object(), >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor "1": 1, "1.": "", "1..": true, "1.0": new Date(), >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor "-1.0": /123/, "-1": Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor }; var r1 = b['0.1']; >r1 : void >b['0.1'] : void ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }; } +>b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } var r2 = b['.1']; >r2 : Object >b['.1'] : Object ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }; } +>b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } var r3 = b['1']; >r3 : number >b['1'] : number ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }; } +>b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } var r3 = c[1]; >r3 : number @@ -389,7 +389,7 @@ var r3 = c[1]; var r4 = b['1.']; >r4 : string >b['1.'] : string ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }; } +>b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } var r3 = c[1.]; // same as indexing by 1 when done numerically >r3 : number @@ -399,12 +399,12 @@ var r3 = c[1.]; // same as indexing by 1 when done numerically var r5 = b['1..']; >r5 : boolean >b['1..'] : boolean ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }; } +>b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } var r6 = b['1.0']; >r6 : Date >b['1.0'] : Date ->b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }; } +>b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } var r3 = c[1.0]; // same as indexing by 1 when done numerically >r3 : number diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints.types b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints.types index b467740332b09..9d74985b9a514 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints.types +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints.types @@ -130,5 +130,5 @@ var r4 = b.foo(new Date()); >b : { foo: (x: T) => number; } >foo : (x: T) => number >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor diff --git a/tests/baselines/reference/redefineArray.errors.txt b/tests/baselines/reference/redefineArray.errors.txt index ad47f15c5217a..b0062abff88bf 100644 --- a/tests/baselines/reference/redefineArray.errors.txt +++ b/tests/baselines/reference/redefineArray.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/redefineArray.ts(1,1): error TS2322: Type '(n: number, s: string) => number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; }'. +tests/cases/compiler/redefineArray.ts(1,1): error TS2322: Type '(n: number, s: string) => number' is not assignable to type 'ArrayConstructor'. Property 'isArray' is missing in type '(n: number, s: string) => number'. ==== tests/cases/compiler/redefineArray.ts (1 errors) ==== Array = function (n:number, s:string) {return n;}; ~~~~~ -!!! error TS2322: Type '(n: number, s: string) => number' is not assignable to type '{ (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; }'. +!!! error TS2322: Type '(n: number, s: string) => number' is not assignable to type 'ArrayConstructor'. !!! error TS2322: Property 'isArray' is missing in type '(n: number, s: string) => number'. \ No newline at end of file diff --git a/tests/baselines/reference/returnStatements.types b/tests/baselines/reference/returnStatements.types index 58d2a251b0ece..5437c835784c2 100644 --- a/tests/baselines/reference/returnStatements.types +++ b/tests/baselines/reference/returnStatements.types @@ -20,7 +20,7 @@ function fn6(): Date { return new Date(12); } >fn6 : () => Date >Date : Date >new Date(12) : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor function fn7(): any { return null; } >fn7 : () => any diff --git a/tests/baselines/reference/returnTypeParameterWithModules.types b/tests/baselines/reference/returnTypeParameterWithModules.types index 4be0efcd2a5f1..be09b8f46b0d7 100644 --- a/tests/baselines/reference/returnTypeParameterWithModules.types +++ b/tests/baselines/reference/returnTypeParameterWithModules.types @@ -16,7 +16,7 @@ module M1 { >Array.prototype.reduce.apply : (thisArg: any, argArray?: any) => any >Array.prototype.reduce : { (callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any; (callbackfn: (previousValue: U, currentValue: any, currentIndex: number, array: any[]) => U, initialValue: U): U; } >Array.prototype : any[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor >prototype : any[] >reduce : { (callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any; (callbackfn: (previousValue: U, currentValue: any, currentIndex: number, array: any[]) => U, initialValue: U): U; } >apply : (thisArg: any, argArray?: any) => any diff --git a/tests/baselines/reference/sourceMapValidationTryCatchFinally.types b/tests/baselines/reference/sourceMapValidationTryCatchFinally.types index 2bd6effcb1ca0..66039a966421a 100644 --- a/tests/baselines/reference/sourceMapValidationTryCatchFinally.types +++ b/tests/baselines/reference/sourceMapValidationTryCatchFinally.types @@ -35,7 +35,7 @@ try throw new Error(); >new Error() : Error ->Error : { (message?: string): Error; new (message?: string): Error; prototype: Error; } +>Error : ErrorConstructor } catch (e) >e : any diff --git a/tests/baselines/reference/subtypingWithOptionalProperties.types b/tests/baselines/reference/subtypingWithOptionalProperties.types index 67eeb274c6b19..707c4b007e787 100644 --- a/tests/baselines/reference/subtypingWithOptionalProperties.types +++ b/tests/baselines/reference/subtypingWithOptionalProperties.types @@ -24,7 +24,7 @@ var r = f({ s: new Object() }); // ok >{ s: new Object() } : { s: Object; } >s : Object >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor r.s && r.s.toFixed(); // would blow up at runtime >r.s && r.s.toFixed() : string diff --git a/tests/baselines/reference/switchStatements.types b/tests/baselines/reference/switchStatements.types index 1c951c5e098ec..4dd7b9904d6c7 100644 --- a/tests/baselines/reference/switchStatements.types +++ b/tests/baselines/reference/switchStatements.types @@ -25,11 +25,11 @@ switch (x) { case new Date(12): >new Date(12) : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor case new Object(): >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor case /[a-z]/: case[]: @@ -111,11 +111,11 @@ switch (undefined) { } switch (new Date(12)) { } >new Date(12) : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor switch (new Object()) { } >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor switch (/[a-z]/) { } switch ([]) { } diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperator.types b/tests/baselines/reference/templateStringWithEmbeddedNewOperator.types index 00bf35330037c..d5b038d344505 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperator.types +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperator.types @@ -2,5 +2,5 @@ var x = `abc${ new String("Hi") }def`; >x : string >new String("Hi") : String ->String : { (value?: any): string; new (value?: any): String; prototype: String; fromCharCode(...codes: number[]): string; } +>String : StringConstructor diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.types b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.types index 36c28473d56bd..d6899f3eb5399 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.types @@ -2,5 +2,5 @@ var x = `abc${ new String("Hi") }def`; >x : string >new String("Hi") : String ->String : { (value?: any): string; new (value?: any): String; prototype: String; fromCharCode(...codes: number[]): string; } +>String : StringConstructor diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt index 572ddfbd6837f..b15a867a79e2a 100644 --- a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(10,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. -lib.d.ts(502,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. +lib.d.ts(513,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'. tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{ [x: number]: undefined; }'. diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt index 8d5f554b42d04..248ea95e3480b 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.errors.txt @@ -1,4 +1,4 @@ -lib.d.ts(502,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. +lib.d.ts(513,11): error TS2300: Duplicate identifier 'TemplateStringsArray'. tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'. tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'. Property 'raw' is missing in type '{ [x: number]: undefined; }'. diff --git a/tests/baselines/reference/throwStatements.types b/tests/baselines/reference/throwStatements.types index eeef863f6eb89..08271fd0ac2ee 100644 --- a/tests/baselines/reference/throwStatements.types +++ b/tests/baselines/reference/throwStatements.types @@ -74,7 +74,7 @@ throw aString; var aDate = new Date(12); >aDate : Date >new Date(12) : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor throw aDate; >aDate : Date @@ -82,7 +82,7 @@ throw aDate; var anObject = new Object(); >anObject : Object >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor throw anObject; >anObject : Object @@ -225,7 +225,7 @@ throw ['a', ['b']]; throw /[a-z]/; throw new Date(); >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor throw new C(); >new C() : C @@ -233,7 +233,7 @@ throw new C(); throw new Object(); >new Object() : Object ->Object : { (): any; (value: any): any; new (value?: any): Object; prototype: Object; getPrototypeOf(o: any): any; getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; getOwnPropertyNames(o: any): string[]; create(o: any, properties?: PropertyDescriptorMap): any; defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; defineProperties(o: any, properties: PropertyDescriptorMap): any; seal(o: any): any; freeze(o: any): any; preventExtensions(o: any): any; isSealed(o: any): boolean; isFrozen(o: any): boolean; isExtensible(o: any): boolean; keys(o: any): string[]; } +>Object : ObjectConstructor throw new D(); >new D() : D diff --git a/tests/baselines/reference/typedArrays.js b/tests/baselines/reference/typedArrays.js new file mode 100644 index 0000000000000..89e6f43ecae19 --- /dev/null +++ b/tests/baselines/reference/typedArrays.js @@ -0,0 +1,260 @@ +//// [typedArrays.ts] + +function CreateTypedArrayTypes() { + var typedArrays = []; + typedArrays[0] = Int8Array; + typedArrays[1] = Uint8Array; + typedArrays[2] = Int16Array; + typedArrays[3] = Uint16Array; + typedArrays[4] = Int32Array; + typedArrays[5] = Uint32Array; + typedArrays[6] = Float32Array; + typedArrays[7] = Float64Array; + typedArrays[8] = Uint8ClampedArray; + + return typedArrays; +} + +function CreateTypedArrayInstancesFromLength(obj: number) { + var typedArrays = []; + typedArrays[0] = new Int8Array(obj); + typedArrays[1] = new Uint8Array(obj); + typedArrays[2] = new Int16Array(obj); + typedArrays[3] = new Uint16Array(obj); + typedArrays[4] = new Int32Array(obj); + typedArrays[5] = new Uint32Array(obj); + typedArrays[6] = new Float32Array(obj); + typedArrays[7] = new Float64Array(obj); + typedArrays[8] = new Uint8ClampedArray(obj); + + return typedArrays; +} + +function CreateTypedArrayInstancesFromArray(obj: number[]) { + var typedArrays = []; + typedArrays[0] = new Int8Array(obj); + typedArrays[1] = new Uint8Array(obj); + typedArrays[2] = new Int16Array(obj); + typedArrays[3] = new Uint16Array(obj); + typedArrays[4] = new Int32Array(obj); + typedArrays[5] = new Uint32Array(obj); + typedArrays[6] = new Float32Array(obj); + typedArrays[7] = new Float64Array(obj); + typedArrays[8] = new Uint8ClampedArray(obj); + + return typedArrays; +} + +function CreateIntegerTypedArraysFromArray2(obj:number[]) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj); + typedArrays[1] = Uint8Array.from(obj); + typedArrays[2] = Int16Array.from(obj); + typedArrays[3] = Uint16Array.from(obj); + typedArrays[4] = Int32Array.from(obj); + typedArrays[5] = Uint32Array.from(obj); + typedArrays[6] = Float32Array.from(obj); + typedArrays[7] = Float64Array.from(obj); + typedArrays[8] = Uint8ClampedArray.from(obj); + + return typedArrays; +} + +function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj); + typedArrays[1] = Uint8Array.from(obj); + typedArrays[2] = Int16Array.from(obj); + typedArrays[3] = Uint16Array.from(obj); + typedArrays[4] = Int32Array.from(obj); + typedArrays[5] = Uint32Array.from(obj); + typedArrays[6] = Float32Array.from(obj); + typedArrays[7] = Float64Array.from(obj); + typedArrays[8] = Uint8ClampedArray.from(obj); + + return typedArrays; +} + +/* +function CreateTypedArraysOf(obj) { + var typedArrays = []; + typedArrays[0] = Int8Array.of(...obj); + typedArrays[1] = Uint8Array.of(...obj); + typedArrays[2] = Int16Array.of(...obj); + typedArrays[3] = Uint16Array.of(...obj); + typedArrays[4] = Int32Array.of(...obj); + typedArrays[5] = Uint32Array.of(...obj); + typedArrays[6] = Float32Array.of(...obj); + typedArrays[7] = Float64Array.of(...obj); + typedArrays[8] = Uint8ClampedArray.of(...obj); + + return typedArrays; +} +*/ + +function CreateTypedArraysOf2() { + var typedArrays = []; + typedArrays[0] = Int8Array.of(1,2,3,4); + typedArrays[1] = Uint8Array.of(1,2,3,4); + typedArrays[2] = Int16Array.of(1,2,3,4); + typedArrays[3] = Uint16Array.of(1,2,3,4); + typedArrays[4] = Int32Array.of(1,2,3,4); + typedArrays[5] = Uint32Array.of(1,2,3,4); + typedArrays[6] = Float32Array.of(1,2,3,4); + typedArrays[7] = Float64Array.of(1,2,3,4); + typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); + + return typedArrays; +} + +function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn); + typedArrays[1] = Uint8Array.from(obj, mapFn); + typedArrays[2] = Int16Array.from(obj, mapFn); + typedArrays[3] = Uint16Array.from(obj, mapFn); + typedArrays[4] = Int32Array.from(obj, mapFn); + typedArrays[5] = Uint32Array.from(obj, mapFn); + typedArrays[6] = Float32Array.from(obj, mapFn); + typedArrays[7] = Float64Array.from(obj, mapFn); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); + + return typedArrays; +} + +function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); + typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); + typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); + typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); + typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); + typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); + typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); + typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); + + return typedArrays; +} + +//// [typedArrays.js] +function CreateTypedArrayTypes() { + var typedArrays = []; + typedArrays[0] = Int8Array; + typedArrays[1] = Uint8Array; + typedArrays[2] = Int16Array; + typedArrays[3] = Uint16Array; + typedArrays[4] = Int32Array; + typedArrays[5] = Uint32Array; + typedArrays[6] = Float32Array; + typedArrays[7] = Float64Array; + typedArrays[8] = Uint8ClampedArray; + return typedArrays; +} +function CreateTypedArrayInstancesFromLength(obj) { + var typedArrays = []; + typedArrays[0] = new Int8Array(obj); + typedArrays[1] = new Uint8Array(obj); + typedArrays[2] = new Int16Array(obj); + typedArrays[3] = new Uint16Array(obj); + typedArrays[4] = new Int32Array(obj); + typedArrays[5] = new Uint32Array(obj); + typedArrays[6] = new Float32Array(obj); + typedArrays[7] = new Float64Array(obj); + typedArrays[8] = new Uint8ClampedArray(obj); + return typedArrays; +} +function CreateTypedArrayInstancesFromArray(obj) { + var typedArrays = []; + typedArrays[0] = new Int8Array(obj); + typedArrays[1] = new Uint8Array(obj); + typedArrays[2] = new Int16Array(obj); + typedArrays[3] = new Uint16Array(obj); + typedArrays[4] = new Int32Array(obj); + typedArrays[5] = new Uint32Array(obj); + typedArrays[6] = new Float32Array(obj); + typedArrays[7] = new Float64Array(obj); + typedArrays[8] = new Uint8ClampedArray(obj); + return typedArrays; +} +function CreateIntegerTypedArraysFromArray2(obj) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj); + typedArrays[1] = Uint8Array.from(obj); + typedArrays[2] = Int16Array.from(obj); + typedArrays[3] = Uint16Array.from(obj); + typedArrays[4] = Int32Array.from(obj); + typedArrays[5] = Uint32Array.from(obj); + typedArrays[6] = Float32Array.from(obj); + typedArrays[7] = Float64Array.from(obj); + typedArrays[8] = Uint8ClampedArray.from(obj); + return typedArrays; +} +function CreateIntegerTypedArraysFromArrayLike(obj) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj); + typedArrays[1] = Uint8Array.from(obj); + typedArrays[2] = Int16Array.from(obj); + typedArrays[3] = Uint16Array.from(obj); + typedArrays[4] = Int32Array.from(obj); + typedArrays[5] = Uint32Array.from(obj); + typedArrays[6] = Float32Array.from(obj); + typedArrays[7] = Float64Array.from(obj); + typedArrays[8] = Uint8ClampedArray.from(obj); + return typedArrays; +} +/* +function CreateTypedArraysOf(obj) { + var typedArrays = []; + typedArrays[0] = Int8Array.of(...obj); + typedArrays[1] = Uint8Array.of(...obj); + typedArrays[2] = Int16Array.of(...obj); + typedArrays[3] = Uint16Array.of(...obj); + typedArrays[4] = Int32Array.of(...obj); + typedArrays[5] = Uint32Array.of(...obj); + typedArrays[6] = Float32Array.of(...obj); + typedArrays[7] = Float64Array.of(...obj); + typedArrays[8] = Uint8ClampedArray.of(...obj); + + return typedArrays; +} +*/ +function CreateTypedArraysOf2() { + var typedArrays = []; + typedArrays[0] = Int8Array.of(1, 2, 3, 4); + typedArrays[1] = Uint8Array.of(1, 2, 3, 4); + typedArrays[2] = Int16Array.of(1, 2, 3, 4); + typedArrays[3] = Uint16Array.of(1, 2, 3, 4); + typedArrays[4] = Int32Array.of(1, 2, 3, 4); + typedArrays[5] = Uint32Array.of(1, 2, 3, 4); + typedArrays[6] = Float32Array.of(1, 2, 3, 4); + typedArrays[7] = Float64Array.of(1, 2, 3, 4); + typedArrays[8] = Uint8ClampedArray.of(1, 2, 3, 4); + return typedArrays; +} +function CreateTypedArraysFromMapFn(obj, mapFn) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn); + typedArrays[1] = Uint8Array.from(obj, mapFn); + typedArrays[2] = Int16Array.from(obj, mapFn); + typedArrays[3] = Uint16Array.from(obj, mapFn); + typedArrays[4] = Int32Array.from(obj, mapFn); + typedArrays[5] = Uint32Array.from(obj, mapFn); + typedArrays[6] = Float32Array.from(obj, mapFn); + typedArrays[7] = Float64Array.from(obj, mapFn); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); + return typedArrays; +} +function CreateTypedArraysFromThisObj(obj, mapFn, thisArg) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); + typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); + typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); + typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); + typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); + typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); + typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); + typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); + return typedArrays; +} diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types new file mode 100644 index 0000000000000..5553aedf51b39 --- /dev/null +++ b/tests/baselines/reference/typedArrays.types @@ -0,0 +1,788 @@ +=== tests/cases/compiler/typedArrays.ts === + +function CreateTypedArrayTypes() { +>CreateTypedArrayTypes : () => any[] + + var typedArrays = []; +>typedArrays : any[] +>[] : undefined[] + + typedArrays[0] = Int8Array; +>typedArrays[0] = Int8Array : Int8ArrayConstructor +>typedArrays[0] : any +>typedArrays : any[] +>Int8Array : Int8ArrayConstructor + + typedArrays[1] = Uint8Array; +>typedArrays[1] = Uint8Array : Uint8ArrayConstructor +>typedArrays[1] : any +>typedArrays : any[] +>Uint8Array : Uint8ArrayConstructor + + typedArrays[2] = Int16Array; +>typedArrays[2] = Int16Array : Int16ArrayConstructor +>typedArrays[2] : any +>typedArrays : any[] +>Int16Array : Int16ArrayConstructor + + typedArrays[3] = Uint16Array; +>typedArrays[3] = Uint16Array : Uint16ArrayConstructor +>typedArrays[3] : any +>typedArrays : any[] +>Uint16Array : Uint16ArrayConstructor + + typedArrays[4] = Int32Array; +>typedArrays[4] = Int32Array : Int32ArrayConstructor +>typedArrays[4] : any +>typedArrays : any[] +>Int32Array : Int32ArrayConstructor + + typedArrays[5] = Uint32Array; +>typedArrays[5] = Uint32Array : Uint32ArrayConstructor +>typedArrays[5] : any +>typedArrays : any[] +>Uint32Array : Uint32ArrayConstructor + + typedArrays[6] = Float32Array; +>typedArrays[6] = Float32Array : Float32ArrayConstructor +>typedArrays[6] : any +>typedArrays : any[] +>Float32Array : Float32ArrayConstructor + + typedArrays[7] = Float64Array; +>typedArrays[7] = Float64Array : Float64ArrayConstructor +>typedArrays[7] : any +>typedArrays : any[] +>Float64Array : Float64ArrayConstructor + + typedArrays[8] = Uint8ClampedArray; +>typedArrays[8] = Uint8ClampedArray : Uint8ClampedArrayConstructor +>typedArrays[8] : any +>typedArrays : any[] +>Uint8ClampedArray : Uint8ClampedArrayConstructor + + return typedArrays; +>typedArrays : any[] +} + +function CreateTypedArrayInstancesFromLength(obj: number) { +>CreateTypedArrayInstancesFromLength : (obj: number) => any[] +>obj : number + + var typedArrays = []; +>typedArrays : any[] +>[] : undefined[] + + typedArrays[0] = new Int8Array(obj); +>typedArrays[0] = new Int8Array(obj) : Int8Array +>typedArrays[0] : any +>typedArrays : any[] +>new Int8Array(obj) : Int8Array +>Int8Array : Int8ArrayConstructor +>obj : number + + typedArrays[1] = new Uint8Array(obj); +>typedArrays[1] = new Uint8Array(obj) : Uint8Array +>typedArrays[1] : any +>typedArrays : any[] +>new Uint8Array(obj) : Uint8Array +>Uint8Array : Uint8ArrayConstructor +>obj : number + + typedArrays[2] = new Int16Array(obj); +>typedArrays[2] = new Int16Array(obj) : Int16Array +>typedArrays[2] : any +>typedArrays : any[] +>new Int16Array(obj) : Int16Array +>Int16Array : Int16ArrayConstructor +>obj : number + + typedArrays[3] = new Uint16Array(obj); +>typedArrays[3] = new Uint16Array(obj) : Uint16Array +>typedArrays[3] : any +>typedArrays : any[] +>new Uint16Array(obj) : Uint16Array +>Uint16Array : Uint16ArrayConstructor +>obj : number + + typedArrays[4] = new Int32Array(obj); +>typedArrays[4] = new Int32Array(obj) : Int32Array +>typedArrays[4] : any +>typedArrays : any[] +>new Int32Array(obj) : Int32Array +>Int32Array : Int32ArrayConstructor +>obj : number + + typedArrays[5] = new Uint32Array(obj); +>typedArrays[5] = new Uint32Array(obj) : Uint32Array +>typedArrays[5] : any +>typedArrays : any[] +>new Uint32Array(obj) : Uint32Array +>Uint32Array : Uint32ArrayConstructor +>obj : number + + typedArrays[6] = new Float32Array(obj); +>typedArrays[6] = new Float32Array(obj) : Float32Array +>typedArrays[6] : any +>typedArrays : any[] +>new Float32Array(obj) : Float32Array +>Float32Array : Float32ArrayConstructor +>obj : number + + typedArrays[7] = new Float64Array(obj); +>typedArrays[7] = new Float64Array(obj) : Float64Array +>typedArrays[7] : any +>typedArrays : any[] +>new Float64Array(obj) : Float64Array +>Float64Array : Float64ArrayConstructor +>obj : number + + typedArrays[8] = new Uint8ClampedArray(obj); +>typedArrays[8] = new Uint8ClampedArray(obj) : Uint8ClampedArray +>typedArrays[8] : any +>typedArrays : any[] +>new Uint8ClampedArray(obj) : Uint8ClampedArray +>Uint8ClampedArray : Uint8ClampedArrayConstructor +>obj : number + + return typedArrays; +>typedArrays : any[] +} + +function CreateTypedArrayInstancesFromArray(obj: number[]) { +>CreateTypedArrayInstancesFromArray : (obj: number[]) => any[] +>obj : number[] + + var typedArrays = []; +>typedArrays : any[] +>[] : undefined[] + + typedArrays[0] = new Int8Array(obj); +>typedArrays[0] = new Int8Array(obj) : Int8Array +>typedArrays[0] : any +>typedArrays : any[] +>new Int8Array(obj) : Int8Array +>Int8Array : Int8ArrayConstructor +>obj : number[] + + typedArrays[1] = new Uint8Array(obj); +>typedArrays[1] = new Uint8Array(obj) : Uint8Array +>typedArrays[1] : any +>typedArrays : any[] +>new Uint8Array(obj) : Uint8Array +>Uint8Array : Uint8ArrayConstructor +>obj : number[] + + typedArrays[2] = new Int16Array(obj); +>typedArrays[2] = new Int16Array(obj) : Int16Array +>typedArrays[2] : any +>typedArrays : any[] +>new Int16Array(obj) : Int16Array +>Int16Array : Int16ArrayConstructor +>obj : number[] + + typedArrays[3] = new Uint16Array(obj); +>typedArrays[3] = new Uint16Array(obj) : Uint16Array +>typedArrays[3] : any +>typedArrays : any[] +>new Uint16Array(obj) : Uint16Array +>Uint16Array : Uint16ArrayConstructor +>obj : number[] + + typedArrays[4] = new Int32Array(obj); +>typedArrays[4] = new Int32Array(obj) : Int32Array +>typedArrays[4] : any +>typedArrays : any[] +>new Int32Array(obj) : Int32Array +>Int32Array : Int32ArrayConstructor +>obj : number[] + + typedArrays[5] = new Uint32Array(obj); +>typedArrays[5] = new Uint32Array(obj) : Uint32Array +>typedArrays[5] : any +>typedArrays : any[] +>new Uint32Array(obj) : Uint32Array +>Uint32Array : Uint32ArrayConstructor +>obj : number[] + + typedArrays[6] = new Float32Array(obj); +>typedArrays[6] = new Float32Array(obj) : Float32Array +>typedArrays[6] : any +>typedArrays : any[] +>new Float32Array(obj) : Float32Array +>Float32Array : Float32ArrayConstructor +>obj : number[] + + typedArrays[7] = new Float64Array(obj); +>typedArrays[7] = new Float64Array(obj) : Float64Array +>typedArrays[7] : any +>typedArrays : any[] +>new Float64Array(obj) : Float64Array +>Float64Array : Float64ArrayConstructor +>obj : number[] + + typedArrays[8] = new Uint8ClampedArray(obj); +>typedArrays[8] = new Uint8ClampedArray(obj) : Uint8ClampedArray +>typedArrays[8] : any +>typedArrays : any[] +>new Uint8ClampedArray(obj) : Uint8ClampedArray +>Uint8ClampedArray : Uint8ClampedArrayConstructor +>obj : number[] + + return typedArrays; +>typedArrays : any[] +} + +function CreateIntegerTypedArraysFromArray2(obj:number[]) { +>CreateIntegerTypedArraysFromArray2 : (obj: number[]) => any[] +>obj : number[] + + var typedArrays = []; +>typedArrays : any[] +>[] : undefined[] + + typedArrays[0] = Int8Array.from(obj); +>typedArrays[0] = Int8Array.from(obj) : Int8Array +>typedArrays[0] : any +>typedArrays : any[] +>Int8Array.from(obj) : Int8Array +>Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array : Int8ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>obj : number[] + + typedArrays[1] = Uint8Array.from(obj); +>typedArrays[1] = Uint8Array.from(obj) : Uint8Array +>typedArrays[1] : any +>typedArrays : any[] +>Uint8Array.from(obj) : Uint8Array +>Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array : Uint8ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>obj : number[] + + typedArrays[2] = Int16Array.from(obj); +>typedArrays[2] = Int16Array.from(obj) : Int16Array +>typedArrays[2] : any +>typedArrays : any[] +>Int16Array.from(obj) : Int16Array +>Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array : Int16ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>obj : number[] + + typedArrays[3] = Uint16Array.from(obj); +>typedArrays[3] = Uint16Array.from(obj) : Uint16Array +>typedArrays[3] : any +>typedArrays : any[] +>Uint16Array.from(obj) : Uint16Array +>Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array : Uint16ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>obj : number[] + + typedArrays[4] = Int32Array.from(obj); +>typedArrays[4] = Int32Array.from(obj) : Int32Array +>typedArrays[4] : any +>typedArrays : any[] +>Int32Array.from(obj) : Int32Array +>Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array : Int32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>obj : number[] + + typedArrays[5] = Uint32Array.from(obj); +>typedArrays[5] = Uint32Array.from(obj) : Uint32Array +>typedArrays[5] : any +>typedArrays : any[] +>Uint32Array.from(obj) : Uint32Array +>Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array : Uint32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>obj : number[] + + typedArrays[6] = Float32Array.from(obj); +>typedArrays[6] = Float32Array.from(obj) : Float32Array +>typedArrays[6] : any +>typedArrays : any[] +>Float32Array.from(obj) : Float32Array +>Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array : Float32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>obj : number[] + + typedArrays[7] = Float64Array.from(obj); +>typedArrays[7] = Float64Array.from(obj) : Float64Array +>typedArrays[7] : any +>typedArrays : any[] +>Float64Array.from(obj) : Float64Array +>Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array : Float64ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>obj : number[] + + typedArrays[8] = Uint8ClampedArray.from(obj); +>typedArrays[8] = Uint8ClampedArray.from(obj) : Uint8ClampedArray +>typedArrays[8] : any +>typedArrays : any[] +>Uint8ClampedArray.from(obj) : Uint8ClampedArray +>Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray : Uint8ClampedArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>obj : number[] + + return typedArrays; +>typedArrays : any[] +} + +function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { +>CreateIntegerTypedArraysFromArrayLike : (obj: ArrayLike) => any[] +>obj : ArrayLike +>ArrayLike : ArrayLike + + var typedArrays = []; +>typedArrays : any[] +>[] : undefined[] + + typedArrays[0] = Int8Array.from(obj); +>typedArrays[0] = Int8Array.from(obj) : Int8Array +>typedArrays[0] : any +>typedArrays : any[] +>Int8Array.from(obj) : Int8Array +>Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array : Int8ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>obj : ArrayLike + + typedArrays[1] = Uint8Array.from(obj); +>typedArrays[1] = Uint8Array.from(obj) : Uint8Array +>typedArrays[1] : any +>typedArrays : any[] +>Uint8Array.from(obj) : Uint8Array +>Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array : Uint8ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>obj : ArrayLike + + typedArrays[2] = Int16Array.from(obj); +>typedArrays[2] = Int16Array.from(obj) : Int16Array +>typedArrays[2] : any +>typedArrays : any[] +>Int16Array.from(obj) : Int16Array +>Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array : Int16ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>obj : ArrayLike + + typedArrays[3] = Uint16Array.from(obj); +>typedArrays[3] = Uint16Array.from(obj) : Uint16Array +>typedArrays[3] : any +>typedArrays : any[] +>Uint16Array.from(obj) : Uint16Array +>Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array : Uint16ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>obj : ArrayLike + + typedArrays[4] = Int32Array.from(obj); +>typedArrays[4] = Int32Array.from(obj) : Int32Array +>typedArrays[4] : any +>typedArrays : any[] +>Int32Array.from(obj) : Int32Array +>Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array : Int32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>obj : ArrayLike + + typedArrays[5] = Uint32Array.from(obj); +>typedArrays[5] = Uint32Array.from(obj) : Uint32Array +>typedArrays[5] : any +>typedArrays : any[] +>Uint32Array.from(obj) : Uint32Array +>Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array : Uint32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>obj : ArrayLike + + typedArrays[6] = Float32Array.from(obj); +>typedArrays[6] = Float32Array.from(obj) : Float32Array +>typedArrays[6] : any +>typedArrays : any[] +>Float32Array.from(obj) : Float32Array +>Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array : Float32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>obj : ArrayLike + + typedArrays[7] = Float64Array.from(obj); +>typedArrays[7] = Float64Array.from(obj) : Float64Array +>typedArrays[7] : any +>typedArrays : any[] +>Float64Array.from(obj) : Float64Array +>Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array : Float64ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>obj : ArrayLike + + typedArrays[8] = Uint8ClampedArray.from(obj); +>typedArrays[8] = Uint8ClampedArray.from(obj) : Uint8ClampedArray +>typedArrays[8] : any +>typedArrays : any[] +>Uint8ClampedArray.from(obj) : Uint8ClampedArray +>Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray : Uint8ClampedArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>obj : ArrayLike + + return typedArrays; +>typedArrays : any[] +} + +/* +function CreateTypedArraysOf(obj) { + var typedArrays = []; + typedArrays[0] = Int8Array.of(...obj); + typedArrays[1] = Uint8Array.of(...obj); + typedArrays[2] = Int16Array.of(...obj); + typedArrays[3] = Uint16Array.of(...obj); + typedArrays[4] = Int32Array.of(...obj); + typedArrays[5] = Uint32Array.of(...obj); + typedArrays[6] = Float32Array.of(...obj); + typedArrays[7] = Float64Array.of(...obj); + typedArrays[8] = Uint8ClampedArray.of(...obj); + + return typedArrays; +} +*/ + +function CreateTypedArraysOf2() { +>CreateTypedArraysOf2 : () => any[] + + var typedArrays = []; +>typedArrays : any[] +>[] : undefined[] + + typedArrays[0] = Int8Array.of(1,2,3,4); +>typedArrays[0] = Int8Array.of(1,2,3,4) : Int8Array +>typedArrays[0] : any +>typedArrays : any[] +>Int8Array.of(1,2,3,4) : Int8Array +>Int8Array.of : (...items: number[]) => Int8Array +>Int8Array : Int8ArrayConstructor +>of : (...items: number[]) => Int8Array + + typedArrays[1] = Uint8Array.of(1,2,3,4); +>typedArrays[1] = Uint8Array.of(1,2,3,4) : Uint8Array +>typedArrays[1] : any +>typedArrays : any[] +>Uint8Array.of(1,2,3,4) : Uint8Array +>Uint8Array.of : (...items: number[]) => Uint8Array +>Uint8Array : Uint8ArrayConstructor +>of : (...items: number[]) => Uint8Array + + typedArrays[2] = Int16Array.of(1,2,3,4); +>typedArrays[2] = Int16Array.of(1,2,3,4) : Int16Array +>typedArrays[2] : any +>typedArrays : any[] +>Int16Array.of(1,2,3,4) : Int16Array +>Int16Array.of : (...items: number[]) => Int16Array +>Int16Array : Int16ArrayConstructor +>of : (...items: number[]) => Int16Array + + typedArrays[3] = Uint16Array.of(1,2,3,4); +>typedArrays[3] = Uint16Array.of(1,2,3,4) : Uint16Array +>typedArrays[3] : any +>typedArrays : any[] +>Uint16Array.of(1,2,3,4) : Uint16Array +>Uint16Array.of : (...items: number[]) => Uint16Array +>Uint16Array : Uint16ArrayConstructor +>of : (...items: number[]) => Uint16Array + + typedArrays[4] = Int32Array.of(1,2,3,4); +>typedArrays[4] = Int32Array.of(1,2,3,4) : Int32Array +>typedArrays[4] : any +>typedArrays : any[] +>Int32Array.of(1,2,3,4) : Int32Array +>Int32Array.of : (...items: number[]) => Int32Array +>Int32Array : Int32ArrayConstructor +>of : (...items: number[]) => Int32Array + + typedArrays[5] = Uint32Array.of(1,2,3,4); +>typedArrays[5] = Uint32Array.of(1,2,3,4) : Uint32Array +>typedArrays[5] : any +>typedArrays : any[] +>Uint32Array.of(1,2,3,4) : Uint32Array +>Uint32Array.of : (...items: number[]) => Uint32Array +>Uint32Array : Uint32ArrayConstructor +>of : (...items: number[]) => Uint32Array + + typedArrays[6] = Float32Array.of(1,2,3,4); +>typedArrays[6] = Float32Array.of(1,2,3,4) : Float32Array +>typedArrays[6] : any +>typedArrays : any[] +>Float32Array.of(1,2,3,4) : Float32Array +>Float32Array.of : (...items: number[]) => Float32Array +>Float32Array : Float32ArrayConstructor +>of : (...items: number[]) => Float32Array + + typedArrays[7] = Float64Array.of(1,2,3,4); +>typedArrays[7] = Float64Array.of(1,2,3,4) : Float64Array +>typedArrays[7] : any +>typedArrays : any[] +>Float64Array.of(1,2,3,4) : Float64Array +>Float64Array.of : (...items: number[]) => Float64Array +>Float64Array : Float64ArrayConstructor +>of : (...items: number[]) => Float64Array + + typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); +>typedArrays[8] = Uint8ClampedArray.of(1,2,3,4) : Uint8ClampedArray +>typedArrays[8] : any +>typedArrays : any[] +>Uint8ClampedArray.of(1,2,3,4) : Uint8ClampedArray +>Uint8ClampedArray.of : (...items: number[]) => Uint8ClampedArray +>Uint8ClampedArray : Uint8ClampedArrayConstructor +>of : (...items: number[]) => Uint8ClampedArray + + return typedArrays; +>typedArrays : any[] +} + +function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { +>CreateTypedArraysFromMapFn : (obj: ArrayLike, mapFn: (n: number, v: number) => number) => any[] +>obj : ArrayLike +>ArrayLike : ArrayLike +>mapFn : (n: number, v: number) => number +>n : number +>v : number + + var typedArrays = []; +>typedArrays : any[] +>[] : undefined[] + + typedArrays[0] = Int8Array.from(obj, mapFn); +>typedArrays[0] = Int8Array.from(obj, mapFn) : Int8Array +>typedArrays[0] : any +>typedArrays : any[] +>Int8Array.from(obj, mapFn) : Int8Array +>Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array : Int8ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number + + typedArrays[1] = Uint8Array.from(obj, mapFn); +>typedArrays[1] = Uint8Array.from(obj, mapFn) : Uint8Array +>typedArrays[1] : any +>typedArrays : any[] +>Uint8Array.from(obj, mapFn) : Uint8Array +>Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array : Uint8ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number + + typedArrays[2] = Int16Array.from(obj, mapFn); +>typedArrays[2] = Int16Array.from(obj, mapFn) : Int16Array +>typedArrays[2] : any +>typedArrays : any[] +>Int16Array.from(obj, mapFn) : Int16Array +>Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array : Int16ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number + + typedArrays[3] = Uint16Array.from(obj, mapFn); +>typedArrays[3] = Uint16Array.from(obj, mapFn) : Uint16Array +>typedArrays[3] : any +>typedArrays : any[] +>Uint16Array.from(obj, mapFn) : Uint16Array +>Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array : Uint16ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number + + typedArrays[4] = Int32Array.from(obj, mapFn); +>typedArrays[4] = Int32Array.from(obj, mapFn) : Int32Array +>typedArrays[4] : any +>typedArrays : any[] +>Int32Array.from(obj, mapFn) : Int32Array +>Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array : Int32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number + + typedArrays[5] = Uint32Array.from(obj, mapFn); +>typedArrays[5] = Uint32Array.from(obj, mapFn) : Uint32Array +>typedArrays[5] : any +>typedArrays : any[] +>Uint32Array.from(obj, mapFn) : Uint32Array +>Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array : Uint32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number + + typedArrays[6] = Float32Array.from(obj, mapFn); +>typedArrays[6] = Float32Array.from(obj, mapFn) : Float32Array +>typedArrays[6] : any +>typedArrays : any[] +>Float32Array.from(obj, mapFn) : Float32Array +>Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array : Float32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number + + typedArrays[7] = Float64Array.from(obj, mapFn); +>typedArrays[7] = Float64Array.from(obj, mapFn) : Float64Array +>typedArrays[7] : any +>typedArrays : any[] +>Float64Array.from(obj, mapFn) : Float64Array +>Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array : Float64ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number + + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); +>typedArrays[8] = Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray +>typedArrays[8] : any +>typedArrays : any[] +>Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray +>Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray : Uint8ClampedArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>obj : ArrayLike +>mapFn : (n: number, v: number) => number + + return typedArrays; +>typedArrays : any[] +} + +function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { +>CreateTypedArraysFromThisObj : (obj: ArrayLike, mapFn: (n: number, v: number) => number, thisArg: {}) => any[] +>obj : ArrayLike +>ArrayLike : ArrayLike +>mapFn : (n: number, v: number) => number +>n : number +>v : number +>thisArg : {} + + var typedArrays = []; +>typedArrays : any[] +>[] : undefined[] + + typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); +>typedArrays[0] = Int8Array.from(obj, mapFn, thisArg) : Int8Array +>typedArrays[0] : any +>typedArrays : any[] +>Int8Array.from(obj, mapFn, thisArg) : Int8Array +>Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array : Int8ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number +>thisArg : {} + + typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); +>typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg) : Uint8Array +>typedArrays[1] : any +>typedArrays : any[] +>Uint8Array.from(obj, mapFn, thisArg) : Uint8Array +>Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array : Uint8ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number +>thisArg : {} + + typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); +>typedArrays[2] = Int16Array.from(obj, mapFn, thisArg) : Int16Array +>typedArrays[2] : any +>typedArrays : any[] +>Int16Array.from(obj, mapFn, thisArg) : Int16Array +>Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array : Int16ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number +>thisArg : {} + + typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); +>typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg) : Uint16Array +>typedArrays[3] : any +>typedArrays : any[] +>Uint16Array.from(obj, mapFn, thisArg) : Uint16Array +>Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array : Uint16ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number +>thisArg : {} + + typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); +>typedArrays[4] = Int32Array.from(obj, mapFn, thisArg) : Int32Array +>typedArrays[4] : any +>typedArrays : any[] +>Int32Array.from(obj, mapFn, thisArg) : Int32Array +>Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array : Int32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number +>thisArg : {} + + typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); +>typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg) : Uint32Array +>typedArrays[5] : any +>typedArrays : any[] +>Uint32Array.from(obj, mapFn, thisArg) : Uint32Array +>Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array : Uint32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number +>thisArg : {} + + typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); +>typedArrays[6] = Float32Array.from(obj, mapFn, thisArg) : Float32Array +>typedArrays[6] : any +>typedArrays : any[] +>Float32Array.from(obj, mapFn, thisArg) : Float32Array +>Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array : Float32ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number +>thisArg : {} + + typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); +>typedArrays[7] = Float64Array.from(obj, mapFn, thisArg) : Float64Array +>typedArrays[7] : any +>typedArrays : any[] +>Float64Array.from(obj, mapFn, thisArg) : Float64Array +>Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array : Float64ArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>obj : ArrayLike +>mapFn : (n: number, v: number) => number +>thisArg : {} + + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); +>typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray +>typedArrays[8] : any +>typedArrays : any[] +>Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray +>Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray : Uint8ClampedArrayConstructor +>from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>obj : ArrayLike +>mapFn : (n: number, v: number) => number +>thisArg : {} + + return typedArrays; +>typedArrays : any[] +} diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 752c39b5e5198..a3347457b8aee 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -635,7 +635,7 @@ var log = _.bind((message?: string, ...rest: string[]) => { }, Date); >(message?: string, ...rest: string[]) => { } : (message?: string, ...rest: string[]) => void >message : string >rest : string[] ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor _.delay(log, 1000, 'logged later'); >_.delay(log, 1000, 'logged later') : number @@ -1097,7 +1097,7 @@ _.isDate(new Date()); >_ : Underscore.Static >isDate : (object: any) => boolean >new Date() : Date ->Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } +>Date : DateConstructor _.isRegExp(/moe/); >_.isRegExp(/moe/) : boolean diff --git a/tests/baselines/reference/validMultipleVariableDeclarations.types b/tests/baselines/reference/validMultipleVariableDeclarations.types index 4bbd46bab2bb4..414f7cc7b841d 100644 --- a/tests/baselines/reference/validMultipleVariableDeclarations.types +++ b/tests/baselines/reference/validMultipleVariableDeclarations.types @@ -126,7 +126,7 @@ var a: string[] = []; var a = new Array(); >a : string[] >new Array() : string[] ->Array : { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; new (arrayLength?: number): any[]; new (arrayLength: number): T[]; new (...items: T[]): T[]; isArray(arg: any): boolean; prototype: any[]; } +>Array : ArrayConstructor var a: typeof a; >a : string[] diff --git a/tests/cases/compiler/implementArrayInterface.ts b/tests/cases/compiler/implementArrayInterface.ts index d08de40be2d59..1ba8b8f25240d 100644 --- a/tests/cases/compiler/implementArrayInterface.ts +++ b/tests/cases/compiler/implementArrayInterface.ts @@ -1,4 +1,4 @@ -declare class ArrayConstructor implements Array { +declare class MyArray implements Array { toString(): string; toLocaleString(): string; concat(...items: U[]): T[]; diff --git a/tests/cases/compiler/typedArrays.ts b/tests/cases/compiler/typedArrays.ts new file mode 100644 index 0000000000000..4508632f6d6c1 --- /dev/null +++ b/tests/cases/compiler/typedArrays.ts @@ -0,0 +1,138 @@ +// @target: ES6 + +function CreateTypedArrayTypes() { + var typedArrays = []; + typedArrays[0] = Int8Array; + typedArrays[1] = Uint8Array; + typedArrays[2] = Int16Array; + typedArrays[3] = Uint16Array; + typedArrays[4] = Int32Array; + typedArrays[5] = Uint32Array; + typedArrays[6] = Float32Array; + typedArrays[7] = Float64Array; + typedArrays[8] = Uint8ClampedArray; + + return typedArrays; +} + +function CreateTypedArrayInstancesFromLength(obj: number) { + var typedArrays = []; + typedArrays[0] = new Int8Array(obj); + typedArrays[1] = new Uint8Array(obj); + typedArrays[2] = new Int16Array(obj); + typedArrays[3] = new Uint16Array(obj); + typedArrays[4] = new Int32Array(obj); + typedArrays[5] = new Uint32Array(obj); + typedArrays[6] = new Float32Array(obj); + typedArrays[7] = new Float64Array(obj); + typedArrays[8] = new Uint8ClampedArray(obj); + + return typedArrays; +} + +function CreateTypedArrayInstancesFromArray(obj: number[]) { + var typedArrays = []; + typedArrays[0] = new Int8Array(obj); + typedArrays[1] = new Uint8Array(obj); + typedArrays[2] = new Int16Array(obj); + typedArrays[3] = new Uint16Array(obj); + typedArrays[4] = new Int32Array(obj); + typedArrays[5] = new Uint32Array(obj); + typedArrays[6] = new Float32Array(obj); + typedArrays[7] = new Float64Array(obj); + typedArrays[8] = new Uint8ClampedArray(obj); + + return typedArrays; +} + +function CreateIntegerTypedArraysFromArray2(obj:number[]) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj); + typedArrays[1] = Uint8Array.from(obj); + typedArrays[2] = Int16Array.from(obj); + typedArrays[3] = Uint16Array.from(obj); + typedArrays[4] = Int32Array.from(obj); + typedArrays[5] = Uint32Array.from(obj); + typedArrays[6] = Float32Array.from(obj); + typedArrays[7] = Float64Array.from(obj); + typedArrays[8] = Uint8ClampedArray.from(obj); + + return typedArrays; +} + +function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj); + typedArrays[1] = Uint8Array.from(obj); + typedArrays[2] = Int16Array.from(obj); + typedArrays[3] = Uint16Array.from(obj); + typedArrays[4] = Int32Array.from(obj); + typedArrays[5] = Uint32Array.from(obj); + typedArrays[6] = Float32Array.from(obj); + typedArrays[7] = Float64Array.from(obj); + typedArrays[8] = Uint8ClampedArray.from(obj); + + return typedArrays; +} + +/* +function CreateTypedArraysOf(obj) { + var typedArrays = []; + typedArrays[0] = Int8Array.of(...obj); + typedArrays[1] = Uint8Array.of(...obj); + typedArrays[2] = Int16Array.of(...obj); + typedArrays[3] = Uint16Array.of(...obj); + typedArrays[4] = Int32Array.of(...obj); + typedArrays[5] = Uint32Array.of(...obj); + typedArrays[6] = Float32Array.of(...obj); + typedArrays[7] = Float64Array.of(...obj); + typedArrays[8] = Uint8ClampedArray.of(...obj); + + return typedArrays; +} +*/ + +function CreateTypedArraysOf2() { + var typedArrays = []; + typedArrays[0] = Int8Array.of(1,2,3,4); + typedArrays[1] = Uint8Array.of(1,2,3,4); + typedArrays[2] = Int16Array.of(1,2,3,4); + typedArrays[3] = Uint16Array.of(1,2,3,4); + typedArrays[4] = Int32Array.of(1,2,3,4); + typedArrays[5] = Uint32Array.of(1,2,3,4); + typedArrays[6] = Float32Array.of(1,2,3,4); + typedArrays[7] = Float64Array.of(1,2,3,4); + typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); + + return typedArrays; +} + +function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn); + typedArrays[1] = Uint8Array.from(obj, mapFn); + typedArrays[2] = Int16Array.from(obj, mapFn); + typedArrays[3] = Uint16Array.from(obj, mapFn); + typedArrays[4] = Int32Array.from(obj, mapFn); + typedArrays[5] = Uint32Array.from(obj, mapFn); + typedArrays[6] = Float32Array.from(obj, mapFn); + typedArrays[7] = Float64Array.from(obj, mapFn); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); + + return typedArrays; +} + +function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { + var typedArrays = []; + typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); + typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); + typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); + typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); + typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); + typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); + typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); + typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); + typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); + + return typedArrays; +} \ No newline at end of file diff --git a/tests/cases/test262-harness/helpers.d.ts b/tests/cases/test262-harness/helpers.d.ts new file mode 100644 index 0000000000000..3e281f41b011c --- /dev/null +++ b/tests/cases/test262-harness/helpers.d.ts @@ -0,0 +1,367 @@ +declare function $FAIL(message: any): void; +declare function $PRINT(message: any): void; +declare function accessorPropertyAttributesAreCorrect(obj: any, name: any, get: any, set: any, setVerifyHelpProp: any, enumerable: any, configurable: any): boolean; +declare function arrayContains(arr: any, expected: any): boolean; +declare function compareArray(aExpected: any, aActual: any): boolean; +declare function testRun(id: any, path: any, description: any, codeString: any, result: any, error: any): void; +declare var print: any; +declare function dataPropertyAttributesAreCorrect(obj: any, name: any, value: any, writable: any, enumerable: any, configurable: any): boolean; +declare var HoursPerDay: number; +declare var MinutesPerHour: number; +declare var SecondsPerMinute: number; +declare var msPerDay: number; +declare var msPerSecond: number; +declare var msPerMinute: number; +declare var msPerHour: number; +declare var date_1899_end: number; +declare var date_1900_start: number; +declare var date_1969_end: number; +declare var date_1970_start: number; +declare var date_1999_end: number; +declare var date_2000_start: number; +declare var date_2099_end: number; +declare var date_2100_start: number; +declare var $LocalTZ: any, $DST_start_month: any, $DST_start_sunday: any, $DST_start_hour: any, $DST_start_minutes: any, $DST_end_month: any, $DST_end_sunday: any, $DST_end_hour: any, $DST_end_minutes: any; +declare function Day(t: any): number; +declare function TimeWithinDay(t: any): number; +declare function DaysInYear(y: any): number; +declare function DayFromYear(y: any): number; +declare function TimeFromYear(y: any): number; +declare function YearFromTime(t: any): number; +declare function InLeapYear(t: any): number; +declare function DayWithinYear(t: any): number; +declare function MonthFromTime(t: any): number; +declare function DateFromTime(t: any): number; +declare function WeekDay(t: any): number; +declare var LocalTZA: number; +declare function DaysInMonth(m: any, leap: any): any; +declare function GetSundayInMonth(t: any, m: any, count: any): any; +declare function DaylightSavingTA(t: any): number; +declare function LocalTime(t: any): any; +declare function UTC(t: any): number; +declare function HourFromTime(t: any): number; +declare function MinFromTime(t: any): number; +declare function SecFromTime(t: any): number; +declare function msFromTime(t: any): number; +declare function MakeTime(hour: any, min: any, sec: any, ms: any): any; +declare function MakeDay(year: any, month: any, date: any): number; +declare function MakeDate(day: any, time: any): any; +declare function TimeClip(time: any): any; +declare function ConstructDate(year: any, month: any, date: any, hours: any, minutes: any, seconds: any, ms: any): any; +declare function __consolePrintHandle__(msg: any): void; +declare function fnExists(): boolean; +declare var __globalObject: any; +declare function fnGlobalObject(): any; +declare function testPrint(message: any): void; +/** + * It is not yet clear that runTestCase should pass the global object + * as the 'this' binding in the call to testcase. + */ +declare var runTestCase: (testcase: any) => void; +declare function assertTruthy(value: any): void; +/** + * falsy means we expect no error. + * truthy means we expect some error. + * A non-empty string means we expect an error whose .name is that string. + */ +declare var expectedErrorName: boolean; +/** + * What was thrown, or the string 'Falsy' if something falsy was thrown. + * null if test completed normally. + */ +declare var actualError: any; +declare function testStarted(expectedErrName: any): void; +declare function testFinished(): void; +declare function Presenter(): void; +declare var presenter: any; +declare var prec: any; +declare function isEqual(num1: any, num2: any): boolean; +declare function getPrecision(num: any): number; +declare function ToInteger(p: any): any; +declare function checkSequence(arr: Promise, message: string): void; +declare var objectStore: { + object: Object; +}; +declare var functionStore: { + fun: () => string; +}; +declare function createEmulatedProxy(target: T, emulatedProps: any, success?: any): T; +declare function Section(parentSection: any, id: any, name: any): void; +declare var NotEarlyErrorString: string; +declare var EarlyErrorRePat: string; +declare var NotEarlyError: Error; +declare var $ERROR: any; +declare function BrowserRunner(): void; +declare function TestLoader(): void; +declare function Controller(): void; +declare var controller: any; +declare function isSiteDebugMode(): boolean; +/** + * @description Helper handler method for tagged string templates + */ +declare function testHandler(literals: any): string; +/** + * @description Tests that obj meets the requirements for built-in objects + * defined by the introduction of chapter 15 of the ECMAScript Language Specification. + * @param {Object} obj the object to be tested. + * @param {boolean} isFunction whether the specification describes obj as a function. + * @param {boolean} isConstructor whether the specification describes obj as a constructor. + * @param {String[]} properties an array with the names of the built-in properties of obj, + * excluding length, prototype, or properties with non-default attributes. + * @param {number} length for functions only: the length specified for the function + * or derived from the argument list. + * @author Norbert Lindenberg + */ +declare function testBuiltInObject(obj: any, isFunction: any, isConstructor: any, properties: any, length: any): boolean; +/** + * @description This is a helper file for testing detached typed arrays + * @author Andrei Borodin (anborod) + */ +declare var lib: { + init: () => void; + dispose: () => void; + detachItem: (item: any) => any; + createDetachCallback: (arr: any, detachAfterNumIterations: any, valueToReturn: any) => (item: any) => any; + createDetachValueOfObject: (arr: any, detachAfterNumIterations: any, value: any) => { + valueOf: () => any; + }; + createDetachToStringObject: (arr: any, detachAfterNumIterations: any, value: any) => { + toString: () => string; + }; + runTestCaseWrapper: (func: any) => void; + expectTypeError: (func: any, reason: any) => void; + expectRangeError: (func: any, reason: any) => void; + expectError: (errorType: any, name: any, func: any, reason: any) => void; + isDetached: (obj: any) => boolean; +}; +declare function testIntlOptions(givenOptions: any, expectedOptions: any): void; +/** + * This file contains shared functions for the tests in the conformance test + * suite for the ECMAScript Internationalization API. + * @author Norbert Lindenberg + */ +/** + * @description Calls the provided function for every service constructor in + * the Intl object, until f returns a falsy value. It returns the result of the + * last call to f, mapped to a boolean. + * @param {Function} f the function to call for each service constructor in + * the Intl object. + * @param {Function} Constructor the constructor object to test with. + * @result {Boolean} whether the test succeeded. + */ +declare function testWithIntlConstructors(f: any): boolean; +/** + * Returns the name of the given constructor object, which must be one of + * Intl.Collator, Intl.NumberFormat, or Intl.DateTimeFormat. + * @param {object} Constructor a constructor + * @return {string} the name of the constructor + */ +declare function getConstructorName(Constructor: any): string; +/** + * Taints a named data property of the given object by installing + * a setter that throws an exception. + * @param {object} obj the object whose data property to taint + * @param {string} property the property to taint + */ +declare function taintDataProperty(obj: any, property: any): void; +/** + * Taints a named method of the given object by replacing it with a function + * that throws an exception. + * @param {object} obj the object whose method to taint + * @param {string} property the name of the method to taint + */ +declare function taintMethod(obj: any, property: any): void; +/** + * Taints the given properties (and similarly named properties) by installing + * setters on Object.prototype that throw exceptions. + * @param {Array} properties an array of property names to taint + */ +declare function taintProperties(properties: any): void; +/** + * Taints the Array object by creating a setter for the property "0" and + * replacing some key methods with functions that throw exceptions. + */ +declare function taintArray(): void; +declare var languages: string[]; +declare var scripts: string[]; +declare var countries: string[]; +declare var localeSupportInfo: {}; +/** + * Gets locale support info for the given constructor object, which must be one + * of Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat. + * @param {object} Constructor the constructor for which to get locale support info + * @return {object} locale support info with the following properties: + * supported: array of fully supported language tags + * byFallback: array of language tags that are supported through fallbacks + * unsupported: array of unsupported language tags + */ +declare function getLocaleSupportInfo(Constructor: any): any; +/** + * @description Tests whether locale is a String value representing a + * structurally valid and canonicalized BCP 47 language tag, as defined in + * sections 6.2.2 and 6.2.3 of the ECMAScript Internationalization API + * Specification. + * @param {String} locale the string to be tested. + * @result {Boolean} whether the test succeeded. + */ +declare function isCanonicalizedStructurallyValidLanguageTag(locale: any): boolean; +/** + * Tests whether the named options property is correctly handled by the given constructor. + * @param {object} Constructor the constructor to test. + * @param {string} property the name of the options property to test. + * @param {string} type the type that values of the property are expected to have + * @param {Array} [values] an array of allowed values for the property. Not needed for boolean. + * @param {any} fallback the fallback value that the property assumes if not provided. + * @param {object} testOptions additional options: + * @param {boolean} isOptional whether support for this property is optional for implementations. + * @param {boolean} noReturn whether the resulting value of the property is not returned. + * @param {boolean} isILD whether the resulting value of the property is implementation and locale dependent. + * @param {object} extra additional option to pass along, properties are value -> {option: value}. + * @return {boolean} whether the test succeeded. + */ +declare function testOption(Constructor: any, property: any, type: any, values: any, fallback: any, testOptions: any): boolean; +/** + * Tests whether the named property of the given object has a valid value + * and the default attributes of the properties of an object literal. + * @param {Object} obj the object to be tested. + * @param {string} property the name of the property + * @param {Function|Array} valid either a function that tests value for validity and returns a boolean, + * an array of valid values. + * @exception if the property has an invalid value. + */ +declare function testProperty(obj: any, property: any, valid: any): void; +/** + * Tests whether the named property of the given object, if present at all, has a valid value + * and the default attributes of the properties of an object literal. + * @param {Object} obj the object to be tested. + * @param {string} property the name of the property + * @param {Function|Array} valid either a function that tests value for validity and returns a boolean, + * an array of valid values. + * @exception if the property is present and has an invalid value. + */ +declare function mayHaveProperty(obj: any, property: any, valid: any): void; +/** + * Tests whether the given object has the named property with a valid value + * and the default attributes of the properties of an object literal. + * @param {Object} obj the object to be tested. + * @param {string} property the name of the property + * @param {Function|Array} valid either a function that tests value for validity and returns a boolean, + * an array of valid values. + * @exception if the property is missing or has an invalid value. + */ +declare function mustHaveProperty(obj: any, property: any, valid: any): void; +/** + * Tests whether the given object does not have the named property. + * @param {Object} obj the object to be tested. + * @param {string} property the name of the property + * @exception if the property is present. + */ +declare function mustNotHaveProperty(obj: any, property: any): void; +/** + * Properties of the RegExp constructor that may be affected by use of regular + * expressions, and the default values of these properties. Properties are from + * https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Properties + */ +declare var regExpProperties: string[]; +declare var regExpPropertiesDefaultValues: any; +/** + * Tests that executing the provided function (which may use regular expressions + * in its implementation) does not create or modify unwanted properties on the + * RegExp constructor. + */ +declare function testForUnwantedRegExpChanges(testFunc: any): void; +/** + * Tests whether name is a valid BCP 47 numbering system name + * and not excluded from use in the ECMAScript Internationalization API. + * @param {string} name the name to be tested. + * @return {boolean} whether name is a valid BCP 47 numbering system name and + * allowed for use in the ECMAScript Internationalization API. + */ +declare function isValidNumberingSystem(name: any): boolean; +/** + * Provides the digits of numbering systems with simple digit mappings, + * as specified in 11.3.2. + */ +declare var numberingSystemDigits: { + arab: string; + arabext: string; + beng: string; + deva: string; + fullwide: string; + gujr: string; + guru: string; + hanidec: string; + khmr: string; + knda: string; + laoo: string; + latn: string; + mlym: string; + mong: string; + mymr: string; + orya: string; + tamldec: string; + telu: string; + thai: string; + tibt: string; +}; +/** + * Tests that number formatting is handled correctly. The function checks that the + * digit sequences in formatted output are as specified, converted to the + * selected numbering system, and embedded in consistent localized patterns. + * @param {Array} locales the locales to be tested. + * @param {Array} numberingSystems the numbering systems to be tested. + * @param {Object} options the options to pass to Intl.NumberFormat. Options + * must include {useGrouping: false}, and must cause 1.1 to be formatted + * pre- and post-decimal digits. + * @param {Object} testData maps input data (in ES5 9.3.1 format) to expected output strings + * in unlocalized format with Western digits. + */ +declare function testNumberFormat(locales: any, numberingSystems: any, options: any, testData: any): void; +/** + * Return the components of date-time formats. + * @return {Array} an array with all date-time components. + */ +declare function getDateTimeComponents(): string[]; +/** + * Return the valid values for the given date-time component, as specified + * by the table in section 12.1.1. + * @param {string} component a date-time component. + * @return {Array} an array with the valid values for the component. + */ +declare function getDateTimeComponentValues(component: any): any; +/** + * Tests that the given value is valid for the given date-time component. + * @param {string} component a date-time component. + * @param {string} value the value to be tested. + * @return {boolean} true if the test succeeds. + * @exception if the test fails. + */ +declare function testValidDateTimeComponentValue(component: any, value: any): boolean; +/** + * Verifies that the actual array matches the expected one in length, elements, + * and element order. + * @param {Array} expected the expected array. + * @param {Array} actual the actual array. + * @return {boolean} true if the test succeeds. + * @exception if the test fails. + */ +declare function testArraysAreSame(expected: any, actual: any): boolean; +/** + * @description Helper methods for TypedArrays + */ +declare function CreateTypedArrayTypes(): [typeof Int8Array, typeof Uint8Array, typeof Int16Array, typeof Uint16Array, typeof Int32Array, typeof Uint32Array, typeof Float32Array, typeof Float64Array, typeof Uint8ClampedArray]; +declare function CreateTypedArrayInstances(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray]; +declare function CreateIntegerTypedArrayTypes(): [typeof Int8Array, typeof Uint8Array, typeof Int16Array, typeof Uint16Array, typeof Int32Array, typeof Uint32Array, typeof Uint8ClampedArray]; +declare function CreateIntegerTypedArrays(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Uint8ClampedArray]; +declare function CreateTypedRedcuedSetOfArrayTypes(): [typeof Float64Array]; +declare function CreateTypedRedcuedSetOfArrays(obj: any): [Float64Array]; +declare function CreateTypedArraysFrom(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray]; +declare function CreateTypedArraysOf(obj: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray]; +declare function CreateTypedArraysFromMapFn(obj: any, mapFn: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray]; +declare function CreateTypedArraysFromThisObj(obj: any, mapFn: any, thisArg: any): [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, Uint8ClampedArray]; +declare function CreatestringsOf(obj: any): string[]; +declare function CreateSignedTypedArrayInstances(obj: any): [Int8Array, Int16Array, Int32Array, Float32Array, Float64Array]; +declare function CreateUnSignedTypedArrayInstances(obj: any): [Uint8Array, Uint16Array, Uint32Array, Uint8ClampedArray]; +declare var $LOG: any; +declare var WScript: any; +declare var $DONE: any; \ No newline at end of file