I have this .ts file:
let animalTypes: string[] = ["MOOSE","COW","HORSE"];
function getNoise(animalTypes) {
if (animalTypes === "MOOSE") {console.log("NEIIIIIIIGH whatever noise Moose make");}
else if (animalTypes === "COW") {console.log("MOOOOOOOOOOO");}
else if (animalTypes === "HORSE") {console.log("WHINNNNY");}
}
export {getNoise}
Which transpiles into this .js file:
"use strict";
exports.__esModule = true;
var animalTypes = ["MOOSE", "COW", "HORSE"];
exports.animalTypes = animalTypes;
function getNoise(animalTypes) {
if (animalTypes === "MOOSE") {
console.log("NEIIIIIIIGH whatever noise Moose make");
}
else if (animalTypes === "COW") {
console.log("MOOOOOOOOOOO");
}
else if (animalTypes === "HORSE") {
console.log("WHINNNNY");
}
}
exports.getNoise = getNoise;
However, I'm receiving this error message when trying to load the .js file and import the functions directly into a block on my website:
Uncaught SyntaxError: The requested module './animals.js' does not provide an export named 'getNoise'
I'm copying an example from class so it's bewildering that it isn't working but there we have it.
Does anyone know what might be causing this SyntaxError?
Here is the relevant html, too:
import {getNoise, animalTypes} from "./animals.js";
document.getElementById("target").onclick = function() {
getNoise(animalTypes[1]);
}
export getNoise