#Abstract Class in .js with JSDoc has no effect?

25 messages · Page 1 of 1 (latest)

plain prismBOT
#
drwarpman#0

Preview:```ts
/**

  • @abstract
    */
    export class Queue {
    constructor() {}
    }

const q = new Queue()```

reef skiff
#

Why doesnt TypeScript read that its an abstract class and error me, or am i doing smth wrong?

ebon stag
reef skiff
#

Thanks.. thats sad though. so no abstract support?

rose magnet
#

I think it's also just a bit more complex in JS - if I write

abstract class Base {
   abstract baseMethod(): string
}

that generates class Base {} in JS - the abstract method goes away completely.

#

It seems like it'd be a lot harder to have that sort of pattern in JS + JSDoc comments: you can't mark a non-existent method as abstract.

reef skiff
#

thats typescript?

#

oh right. i thought abstract classes in TS give no output

#

unless you have non-abstract stuff in it

#

interesting

#

but JS is not getting compiled, i would be satisfied with something as simple as an error message

#

but im still confused by your statement xD

rose magnet
#

My point is how do you write an "abstract class with an abstract method" in JS code?

reef skiff
#

u dont

#

well

rose magnet
#

Then how are you going to do it with JS + doc comments?

reef skiff
#
/**
 * @abstract
 */
class Queue {
    constructor() {
    }

    /**
     * @abstract
     */
    foobar() {

    }


}

😄

rose magnet
#

Yeah, but there's actually a foobar method there, unlike the generated TS.

reef skiff
#

Yea I get that, but thats fine, thats the same as typescript giving types but in the output there aint no types.

rose magnet
#

That seems minor but it seems like it would matter for interop reasons.

reef skiff
#

I just want it in my IDE, to make it error basically

rose magnet
#

It seems like JS+JSDoc abstract would actually work differently at runtime than TS abstract which might be annoying when consuming code and you don't know if it was written in JS or TS.

#

But I dunno, maybe it wouldn't actually matter. Either way, not something TS supports currently.