Skip to content

Incorrect extend errors since v2.4 update #17123

@samchon

Description

@samchon

I've been publishing a library compiled by the TypeScript. Since the v2.4 update, my library fails to compile throwing such error:

error TS2415: Class 'MapContainer<Key, T>' incorrectly extends base class 'Container<Pair<Key, T>>'.
error TS2415: Class 'MapIterator<Key, T>' incorrectly extends base class '_ListIteratorBase<Pair<Key, T>>'.
error TS2344: Type 'SetIterator<T>' does not satisfy the constraint '_ListIteratorBase<T>'.
...
...

It was not a problem to extending a class and overriding some methods to return (or get parameter) sub-type of origin. Thus, below example code, there hasn't been any error until the v2.3. However, since the v2.4 update, below code throws incorretly extends base class error.

I want to know that such errors, since v2.4, are by whether:

  1. intended error of TypeScript-compiler; stricter type checking
  2. domain error of mis-update.
namespace std.base
{
    //------------------------------------------------
    // ABSTRACT CLASSES
    //------------------------------------------------
    export abstract class Container<T>
    {
        public abstract begin(): Iterator<T>;
        public abstract end(): Iterator<T>;
        public erase(first: Iterator<T>, last: Iterator<T>): Iterator<T>;
    }
    export abstract class Iterator<T>
    {
        public abstract source(): Container<T>;
        public abstract prev(): Iterator<T>;
        public abstract next(): Iterator<T>;
    }
}

namespace std
{
    //------------------------------------------------
    // DERIVED CLASSES
    //------------------------------------------------
    // DERIVED CONTAINERS
    export class Vector<T> extends base.Container<T>
    {
        public begin(): VectorIterator<T>;
        public end(): VectorIterator<T>;
        public erase(first: VectorIterator<T>, last: VectorIterator<T>): VectorIterator<T>;
    }
    export class List<T> extends base.Container<T>
    {
        public begin(): ListIterator<T>;
        public end(): ListIterator<T>;
        public erase(first: ListIterator<T>, last: ListIterator<T>): ListIterator<T>;
    }

    // DERIVED ITERATORS
    export class VectorIterator<T> extends base.Iterator<T>
    {
        public source(): Vector<T>;
        public prev(): VectorIterator<T>;
        public next(): VectorIterator<T>;
    }
    export class ListIterator<T> extends base.Iterator<T>
    {
        public source(): List<T>;
        public prev(): ListIterator<T>;
        public next(): ListIterator<T>;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions