Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

two lines in an interface cause a build time explosion [strictGenericChecks] #18257

Copy link
Copy link
@emmanueltouzery

Description

@emmanueltouzery
Issue body actions

TypeScript Version: Tested on 2.5.2 and 2.6.0-dev.20170904

Code

The code is there:
https://github.com/emmanueltouzery/prelude.ts/tree/5c33c1eeeea7234506e54331d06590e2feb9b00d

To build it you can just run npm install && tsc. It's about 1800 LOCs of typescript.

On my (old) machine, if I build it as-is with 2.5 or 2.6-dev I get a ~5s build time. If I uncomment in src/IMap.ts lines 29 and 30, however, the build time explodes. On 2.5 I didn't bother waiting but it would be a long, long, long time. On 2.6-dev the speed is much better but the build time still explodes from 5 seconds to 35 seconds.

The two lines are:

     mapValuesStruct<V2>(fn:(v:V)=>V2): IMap<K,V2>;
     mapValues<V2>(fn:(v:V)=>V2&WithEquality): IMap<K,V2>;

And they are implemented in src/HashMap.ts with:

    map<K2,V2>(fn:(k:K&WithEquality, v:V)=>[K2&WithEquality,V2&WithEquality]): HashMap<K2,V2> {
        return this.mapStruct(fn);
    }

    mapValuesStruct<V2>(fn:(v:V)=>V2): HashMap<K,V2> {
        return this.hamt.fold(
            (acc: HashMap<K,V2>, value: V, key: K&WithEquality) =>
                acc.putStruct(key,fn(value)), HashMap.empty());
    }

When I implement the interface, I change the return type to a more specific one, which is as far as I'm aware, legal.

Expected behavior:
Uncommenting these two lines of code shouldn't cause the build time to increase sevenfold. Maybe the code is wrong, but then I should get a compilation error or a warning, not an increased build time.

If I put in the tsconfig.json:
"noStrictGenericChecks": true

then the performance issue goes away completely even with the lines uncommented.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.