#typify existed class
22 messages · Page 1 of 1 (latest)
as a package?
no as a script. i declare a global class like
now when im doing
const newInstance = new SomeClass()
```it has types but looks not good? dunno
so you just copied over the script from somewhere?
yea
why not just edit the script to give it types then
obfuscated
i don't see how obfuscating a class would prevent you from finding the appropriate methods and typing them
i just dont want to touch the script. i want to keep types away
k, then use a d.ts to give types to the class within the file, not a global class
How to write a high-quality TypeScript Declaration (d.ts) file
check out the module: class section
yeah
k thanks
ops
looks like not my case
im not importing a class like that
the script already imported with <script> tag on react page
so TS knows nothing about this
first of all i need to tell TS that this class exist in global scope and typify it
interface SomeType {
new(): {
// methods
}
}
const MyClass : SomeType
works but looks ... i dont know it doesnt look good
so it is in global scope?
declare global {
class Foo {}
}
```you can use this then
hm not sure if you would need the declare global in a script d.ts
declare class Foo {
a: 1
b: 2
static c: 3
}
I guess