#how to use typescript with the api?
1 messages · Page 1 of 1 (latest)
its the same as javascript but has more variable type control
i have some functions in ts and i want to import it in js, how do i do that?
import * as myfunctions from "./your_file.ts"
ty
i did import * as kits from "./kitFuncs.ts" and it said [Scripting][error]-Plugin [item text testing - 2.4.8] - [main.js] ran with error: [ReferenceError: Module [kitFuncs.ts.js] not found. Native module error or file not found.]
i am allowed to import ts funcs into a js file right?
idk i never tested, but you should do,
// in the file.ts
export function func():void {}
// in index.js
import * as abcd from "file.ts"
abcd.func() // this will run it
my file name is 'file.d.ts' is that different to 'file.ts'
same error
what error?
i mean the names should match to work
[Scripting][error]-Plugin [item text testing - 2.4.8] - [main.js] ran with error: [ReferenceError: Module [kitFuncs.d.ts.js] not found. Native module error or file not found.]
.d.ts.js what?
it autocorrects for some reason
bro just name it KitFuncs_d.ts
like i didnt type that
i did
import { world, system } from "@minecraft/server"
import * as kits from "kitFuncs.d.ts"```
then i think you cant impoer ts
dang thanks for helping anyway
no problem, also if you want to manage it better create a class