Skip to content

Cannot read property 'getEntryByPath' of undefined #25047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
atrauzzi opened this issue Jun 18, 2018 · 25 comments
Closed

Cannot read property 'getEntryByPath' of undefined #25047

atrauzzi opened this issue Jun 18, 2018 · 25 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue

Comments

@atrauzzi
Copy link

atrauzzi commented Jun 18, 2018

TypeScript Version: 2.9.2
Search Terms: "Cannot read property 'getEntryByPath' of undefined"
Code
I couldn't even begin to guess what code is causing this. It's obviously one of my dependencies, but which? Well -- I guess that's the problem with this error...
Expected behavior: Either my application to work, or for ts to give me better feedback.
Actual behavior: I get an error that doesn't help me identify where the issue is.

Happy to answer any specific questions beyond the basic template. It's a webpack 4 project.

@ghost
Copy link

ghost commented Jun 18, 2018

Try shrinking the project size until you something that can be reproduced. Also, this error shouldn't show up in the command line compiler, so it must have something to do with a tool you're using to compile.

@ghost ghost added the Needs More Info The issue still hasn't been fully clarified label Jun 18, 2018
@atrauzzi
Copy link
Author

I'm using webpack 4 with ts-loader.

I definitely can get it to compile by making a trival console.log module. But obviously there's a huge gulf between the modules my project uses and that.

Is there nothing I can do/use to get better insights?

@ghost
Copy link

ghost commented Jun 18, 2018

I would recommend making a copy of your project, then deleting things until the error disappears. The error probably has to do with webpack's use of TypeScript services rather than the particular content of the code, but maybe the error only reproduces with some particular pattern of imports / file references.

(The error message is not too ambiguous, but that doesn't mean we know why it happened. There is indeed a line hostCache = undefined!; in the code that is fishy, but supposedly we had some reason why hostCache wouldn't be referenced after that.)

Also, try using typescript@next in case this has already been fixed.

@atrauzzi
Copy link
Author

atrauzzi commented Jun 18, 2018

Tried @next before opening issue, didn't help.

So, I decided to go to that chunk of typescript.js and try to get some output:

            function fileExists(fileName) {
                var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
                console.log(fileName, path);
                var entry = hostCache.getEntryByPath(path);
                return entry ?
                    !ts.isString(entry) :
                    (host.fileExists && host.fileExists(fileName));
            }
/Users/atrauzzi/Development/project/node_modules/@material-ui/core/package.json /users/atrauzzi/development/project/node_modules/@material-ui/core/package.json

So, it looks like it's failing when trying to access the package.json for material-ui? This happens several times in a row. Not sure what to make of it or how I could possibly identify who is responsible for causing the error...

  • Is it typescript for...not sure...?
  • Is it ts-loader because they misused typescript somehow?
  • Is it material-ui because they are doing some kind of bad import?

I guess the issue here is that yes, we know there's an error, obviously. But the feedback doesn't narrow any of it down.

@ghost
Copy link

ghost commented Jun 18, 2018

It would be better to just try getting a smaller repro -- right now there are just too many variables in play. For example, if you remove material-ui it might reproduce with some other package in your build.

@ghost
Copy link

ghost commented Jun 18, 2018

If you're seeing compile errors instead of a crash, that probably means the thing you removed was relevant to the error.

@ghost
Copy link

ghost commented Jun 18, 2018

This is a bug tracker -- you appear to have discovered a real bug, but to fix it we'll need a repro. My recommendation was to make a copy of your project and to simplify that so we have a way to reproduce the bug -- not to destroy your original project.

@atrauzzi
Copy link
Author

Heads up, doing a lot of trial and error this evening and it seems to be narrowing down to any time I import WithStyles or withStyles from Material UI. Tomorrow morning I'll try to make a repro repo, but if I can't get it, I'll at the very least do screenshots. I can cause/prevent the error predictably now based on the one module.

@kasperisager
Copy link

I'm hitting this same issue when TypeScript tries to infer the type of a seemingly innocent constant that is assigned the result of a function invocation, with the function residing in a separate module. If I explicitly annotate the constant with a type, which also resides in a separate module, things work. I've however been unable to reproduce this in anything but my own code base, though it might provide others with a lead 😕

@jamalsoueidan
Copy link

It happens to my project too.

@atrauzzi
Copy link
Author

atrauzzi commented Jun 19, 2018

Alright, managed to get a repro going based off of a slice of my project. All build configuration is included as well as the yarn-error.log generated, although that's probably not helpful.


Download repro archive.

To run:

yarn install
yarn hot

Here's the output I'm getting:

image

@michitaro
Copy link

michitaro commented Jun 19, 2018

I'm hitting the same issue too.
Here is my minimal reproducing repository.
https://github.com/michitaro/typescript-issue-25047
{"declaration": false} helps the situation.

This change solves the error in my case.
https://github.com/michitaro/typescript-issue-25047/commit/6f440e2128245e37a1de65b2a79d7399b9719461
VNode is a return type of the function.

@Qwerios
Copy link

Qwerios commented Jun 19, 2018

I hit the same error and through trial and error managed to track it down to my import of redux-saga.

import { call, fork, ForkEffect, put, takeEvery } from 'redux-saga/effects';

ForkEffect was marked grey by VSCode because it wasn't referenced or used directly. It is used implicitly as a return type in the sagas.

Just sharing info to warn people that even if VSCode marks import as unused they might be needed for type completion or indeed compilation.

My project is based on https://github.com/alexjoverm/typescript-library-starter and https://github.com/ezolenko/rollup-plugin-typescript2 was giving me the error during build.

@atrauzzi
Copy link
Author

atrauzzi commented Jun 19, 2018

Yeah, I definitely have had to start doing some arbitrary imports lately to get things compiling.

Setting your typescript version to ~2.8.0 will also dodge this issue, but obviously going down a version is no fun.

@ghost ghost added Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files and removed Needs More Info The issue still hasn't been fully clarified labels Jun 19, 2018
@mhegazy mhegazy added this to the TypeScript 3.0 milestone Jun 19, 2018
@TheSpyder
Copy link

I hit this and tracked it down to a file that, similar to the above examples, with TS2.8 fails to compile giving one of those Default export of the module has or is using private name errors. The type in question is coming from a library in node_modules.

TS2.9 doesn't throw an error compiling it, but the .d.ts file it produced includes types like this:

export declare const fn: (a: string) => import("../../../../../../../node_modules/mylibrary/Type").Type;

Which fails to parse in older tools.

As soon as I import the type, it changes to

import Type from 'mylibrary';
export declare const fn: (a: string) => Type;

which works.

@atrauzzi
Copy link
Author

atrauzzi commented Jun 20, 2018

@TheSpyder - Are you sure it's 2.8.x where it's broken? I downgraded to 2.8.x and the problem went away. It's only on 2.9.x where I encounter this.

@TheSpyder
Copy link

In my case, 2.8 throws an error where 2.9 doesn't but it compiles weirdly :)

The 2.9 output is what's causing an error with rollup for me.

@ghost
Copy link

ghost commented Jun 20, 2018

I've reproduced the bug without webpack:

node_modules/foo/index.d.ts

export function f(): I;
export interface I {
  x: number;
}

tsconfig.json

{
    "compilerOptions": {
        "declaration": true
   }
}

a.ts

import { f } from "foo";
export const x = f();

Just open a.ts in vscode and view the tsserver log.

    TypeError: Cannot read property 'getEntryByPath' of undefined
    at Object.fileExists (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:109416:39)
    at Object.fileExists (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:82018:791)
    at getDirectoryOrExtensionlessFileName (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:84950:26)
    at tryGetModuleNameAsNodeModule (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:84939:35)
    at getGlobalModuleSpecifier (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:84742:20)
    at C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:84725:88
    at Object.mapDefined (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:541:30)
    at Object.getModuleSpecifiers (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:84725:29)
    at getNameOfSymbolAsWritten (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:32752:79)
    at symbolToTypeNode (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:32522:32)
    at typeToTypeNodeHelper (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:31971:27)
    at Object.typeToTypeNode (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:31804:41)
    at Object.createTypeOfDeclaration (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:53617:32)
    at ensureType (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:75521:41)
    at visitDeclarationSubtree (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:75820:88)
    at Object.visitNodes (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:59536:48)
    at transformVariableStatement (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:76090:28)
    at transformTopLevelDeclaration (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:76057:36)
    at visitDeclarationStatements (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:75915:26)
    at Object.visitNodes (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:59536:48)
    at transformRoot (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:75385:33)
    at C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:1349:42
    at transformRoot (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:76420:82)
    at Object.map (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:405:29)
    at Object.transformNodes (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:76407:30)
    at Object.getDeclarationDiagnostics (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:75214:25)
    at C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:82436:27
    at runWithCancellationToken (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:82172:24)
    at getDeclarationDiagnosticsForFileNoCache (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:82433:20)
    at getAndCacheDiagnostics (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:82446:26)
    at getDeclarationDiagnosticsWorker (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:82430:20)
    at getDeclarationDiagnosticsForFile (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:82459:56)
    at getDiagnosticsHelper (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:82134:24)
    at Object.getDeclarationDiagnostics (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:82156:24)
    at Object.getSemanticDiagnostics (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:109519:50)
    at IOSession.Session.semanticCheck (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:116411:52)
    at C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:116450:31
    at MultistepOperation.executeAction (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:115923:25)
    at C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:115904:100
    at IOSession.Session.executeWithRequestId (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:117563:28)
    at Object.executeWithRequestId (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:116289:87)
    at Immediate.<anonymous> (C:\Users\anhans\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:115904:41)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)

@ghost
Copy link

ghost commented Jun 20, 2018

The problem is that getting imports uses moduleSpecifiers.ts as of #24610. That file uses host.fileExists in a few places. The implementation of that in synchronizeHostData calls hostCache.getEntryByPath, but hostCache was cleared earlier.

The line hostCache = undefined!; comes from #3331 -- there might be a performance penalty for removing that.

It looks like the use of hostCache in fileExists in services.ts is just an optimization, so we could fall back to always using host.fileExists if we've already deleted hostCache, but that could be slow.

Another fix would be to have the compiler keep a set of all the files it knows to exist from module resolution, so we don't have to ask a second time.

Opinions? @sheetalkamat @weswigham

@weswigham
Copy link
Member

Graceful fallback to the fs feels like a given - since the hostCache is apparently undefined-able, it should be handled correctly when it is. A thin host cache that only holds resolution results but not contents might be a useful perf optimization, though; we'd have to test to find out.

@sheetalkamat
Copy link
Member

The below change is must i think to fix this. HostCache is suppose to be valid only for duration of the program and thats what we shouldnt change

// services.ts
            function fileExists(fileName: string): boolean {
                const path = toPath(fileName, currentDirectory, getCanonicalFileName);
                const entry = hostCache && hostCache.getEntryByPath(path);
                return entry ?
                    !isString(entry) :
                    (!!host.fileExists && host.fileExists(fileName));
            }

But we could do better in getEmitHost in program by :

// program.ts
function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost {
            return {
                ... some stuff
                fileExists: f => {
                    const path = toPath(f);
                    if (getSourceFileByPath(path)) return true;
                    if (contains(missingFilePaths, path)) return false;
                    return host.fileExists(f);
                },
                ...(host.directoryExists ? { directoryExists: f => host.directoryExists!(f) } : {}),
            };

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jun 25, 2018
fpapado pushed a commit to fpapado/react-lazy-images that referenced this issue Jul 24, 2018
If we set declaration: true, then typescript (specifically rpt2,
Rollup's TS plugin) fails with a cryptic path error. This is
filed under microsoft/TypeScript#25047.

Curiously, this does not happen on master, and I have vaguely
traced it back to unionize and the fact that it does fancy type
exports, which we partially re-export here. We would have to
manually emit a declaration file, which is not hard tbh, but a bit
annoying. Even funnier, webpack has no issue building in storybook,
but that might be because it does not emit declarations anyway.

Steps:
- Get declaration file from master, add to repository, and copy to
dist/ upon build;
- See if massaging our exports fixes it;
- Wait for TS :/
fpapado added a commit to fpapado/react-lazy-images that referenced this issue Aug 5, 2018
* Add utils and delayed loading test in stories

* Intermediate solution

Not sure where the reducer/update function is headed, but we'll
find out, I suppose.

* Finish refactoring

* Make buffering work

It works, but now the intersection logic is not the same. Scrolling
until inView is true, and then up, triggers the promise cancelation.
This is undesirable. We want the image to keep loading as long as
it stays on the screen. Oddly, scrolling past the image, and it
being in view, still lets it load without canceling (as intendeed).
Another difference is that loading only commences once the image is
fully in view, rather than on the margin.

* Document things a bit better

* There was no bug; the placeholder had a 0 height!

* A few more docs

* Name things, expose as props

Added:
- debugActions: logs actions in dev, warns and logs in prod
- debounceDurationMs: whether, and how much to debounce loading,
  0 by default, so no change to v1. Added codepath to make it so.
- Provisional changes.md document with API compatibility
- Various TODOs and cleanup tasks

* Fix passing of debounceDurationMs to cb

* Use debugActions in the story, destructure it

Also add a note to hopefully remember to destructure next time :)

* Pin microbundle and ts versions

* Clean dir before build

* TS BUG: need declaration: false to build correctly

If we set declaration: true, then typescript (specifically rpt2,
Rollup's TS plugin) fails with a cryptic path error. This is
filed under microsoft/TypeScript#25047.

Curiously, this does not happen on master, and I have vaguely
traced it back to unionize and the fact that it does fancy type
exports, which we partially re-export here. We would have to
manually emit a declaration file, which is not hard tbh, but a bit
annoying. Even funnier, webpack has no issue building in storybook,
but that might be because it does not emit declarations anyway.

Steps:
- Get declaration file from master, add to repository, and copy to
dist/ upon build;
- See if massaging our exports fixes it;
- Wait for TS :/

* 1.1.0-rc.1

* Version bump

* Make update static, use Commands

The Elm/JS/Redux/React-Component fusion is complete. The reducer
is now a pure function, because it only describes side-effects,
and does not execute them. The logic is really nice to read there.

* Naming things

* Version bump

* Use TS3.0

* Copy definitions separately

Because of the "path undefined" bug, we have to run `tsc`
separately, to get the definitions and copy them over.

* Do not expose Buffering as a separate state

Expose it under 'Loading' for backwards compatibility

* Improve debounceDurationMs docs

* Add first point to README

* Cancel Promises, clear cache on unmount

* Add docs for debounceDurationMs
@thomasboyt
Copy link

thomasboyt commented Aug 9, 2018

Any chance that this feature could be backported to a 2.9.x release? Just lost two+ hours to this, and it's an absolutely brutal bug that I have to imagine has to be really common. As @Andy-MS's tiny repro shows, anything that fails to import the return type of an implemented interface will just start erroring. In my case, I was seeing no errors in builds, but saw Intellisense in VSCode wasn't updating, and only by enabling TypeScript logging in VSCode did I find this exception and and issue! I wish I had earlier, as because I use a somewhat-complex monorepo setup that I've been changing a lot lately, I initially assumed I had messed something up in my tsconfigs, and I'm pretty shocked to learn it was actually a TypeScript bug this whole time.

I'll likely upgrade to 3.0.0 as soon as VSCode stable channel is updated so maybe this isn't too big of a deal, but I imagine other folks might be stuck on 2.9.x for various reasons.

@atrauzzi
Copy link
Author

atrauzzi commented Aug 9, 2018

@thomasboyt - Any chance you can just jump to 3.x? I did and so far so good....

joshuawilson added a commit to fabric8-ui/fabric8-ui that referenced this issue Sep 24, 2018
This is to get past an error when running the tests. Not sure if this
version is too high for Angular, which is built at 9.2.9.

But v9.2.9 throws

```
TypeError: Cannot read property 'getEntryByPath' of undefined
```

According to microsoft/TypeScript#25047 that
version is the issue. It is fixed in v2.8 and v3. So we have to move or
down.
joshuawilson added a commit to fabric8-ui/fabric8-ui that referenced this issue Sep 27, 2018
This is to get past an error when running the tests. Not sure if this
version is too high for Angular, which is built at 9.2.9.

But v9.2.9 throws

```
TypeError: Cannot read property 'getEntryByPath' of undefined
```

According to microsoft/TypeScript#25047 that
version is the issue. It is fixed in v2.8 and v3. So we have to move or
down.
joshuawilson added a commit to fabric8-ui/fabric8-ui that referenced this issue Sep 27, 2018
This is to get past an error when running the tests. Not sure if this
version is too high for Angular, which is built at 9.2.9.

But v9.2.9 throws

```
TypeError: Cannot read property 'getEntryByPath' of undefined
```

According to microsoft/TypeScript#25047 that
version is the issue. It is fixed in v2.8 and v3. So we have to move or
down.
@trash-80
Copy link

trash-80 commented Oct 3, 2018

Angular 6 is requires <2.10.0, so a backport would be nice.

@pbpraveen1988
Copy link

I would recommend making a copy of your project, then deleting things until the error disappears. The error probably has to do with webpack's use of TypeScript services rather than the particular content of the code, but maybe the error only reproduces with some particular pattern of imports / file references.

(The error message is not too ambiguous, but that doesn't mean we know why it happened. There is indeed a line hostCache = undefined!; in the code that is fishy, but supposedly we had some reason why hostCache wouldn't be referenced after that.)

Also, try using typescript@next in case this has already been fixed.

typescript@next thanks it worked for me

antoni-kam added a commit to antoni-kam/react-lazy-images that referenced this issue Sep 16, 2023
* Add utils and delayed loading test in stories

* Intermediate solution

Not sure where the reducer/update function is headed, but we'll
find out, I suppose.

* Finish refactoring

* Make buffering work

It works, but now the intersection logic is not the same. Scrolling
until inView is true, and then up, triggers the promise cancelation.
This is undesirable. We want the image to keep loading as long as
it stays on the screen. Oddly, scrolling past the image, and it
being in view, still lets it load without canceling (as intendeed).
Another difference is that loading only commences once the image is
fully in view, rather than on the margin.

* Document things a bit better

* There was no bug; the placeholder had a 0 height!

* A few more docs

* Name things, expose as props

Added:
- debugActions: logs actions in dev, warns and logs in prod
- debounceDurationMs: whether, and how much to debounce loading,
  0 by default, so no change to v1. Added codepath to make it so.
- Provisional changes.md document with API compatibility
- Various TODOs and cleanup tasks

* Fix passing of debounceDurationMs to cb

* Use debugActions in the story, destructure it

Also add a note to hopefully remember to destructure next time :)

* Pin microbundle and ts versions

* Clean dir before build

* TS BUG: need declaration: false to build correctly

If we set declaration: true, then typescript (specifically rpt2,
Rollup's TS plugin) fails with a cryptic path error. This is
filed under microsoft/TypeScript#25047.

Curiously, this does not happen on master, and I have vaguely
traced it back to unionize and the fact that it does fancy type
exports, which we partially re-export here. We would have to
manually emit a declaration file, which is not hard tbh, but a bit
annoying. Even funnier, webpack has no issue building in storybook,
but that might be because it does not emit declarations anyway.

Steps:
- Get declaration file from master, add to repository, and copy to
dist/ upon build;
- See if massaging our exports fixes it;
- Wait for TS :/

* 1.1.0-rc.1

* Version bump

* Make update static, use Commands

The Elm/JS/Redux/React-Component fusion is complete. The reducer
is now a pure function, because it only describes side-effects,
and does not execute them. The logic is really nice to read there.

* Naming things

* Version bump

* Use TS3.0

* Copy definitions separately

Because of the "path undefined" bug, we have to run `tsc`
separately, to get the definitions and copy them over.

* Do not expose Buffering as a separate state

Expose it under 'Loading' for backwards compatibility

* Improve debounceDurationMs docs

* Add first point to README

* Cancel Promises, clear cache on unmount

* Add docs for debounceDurationMs
stacksculptor added a commit to stacksculptor/react-lazy-images that referenced this issue May 19, 2024
* Add utils and delayed loading test in stories

* Intermediate solution

Not sure where the reducer/update function is headed, but we'll
find out, I suppose.

* Finish refactoring

* Make buffering work

It works, but now the intersection logic is not the same. Scrolling
until inView is true, and then up, triggers the promise cancelation.
This is undesirable. We want the image to keep loading as long as
it stays on the screen. Oddly, scrolling past the image, and it
being in view, still lets it load without canceling (as intendeed).
Another difference is that loading only commences once the image is
fully in view, rather than on the margin.

* Document things a bit better

* There was no bug; the placeholder had a 0 height!

* A few more docs

* Name things, expose as props

Added:
- debugActions: logs actions in dev, warns and logs in prod
- debounceDurationMs: whether, and how much to debounce loading,
  0 by default, so no change to v1. Added codepath to make it so.
- Provisional changes.md document with API compatibility
- Various TODOs and cleanup tasks

* Fix passing of debounceDurationMs to cb

* Use debugActions in the story, destructure it

Also add a note to hopefully remember to destructure next time :)

* Pin microbundle and ts versions

* Clean dir before build

* TS BUG: need declaration: false to build correctly

If we set declaration: true, then typescript (specifically rpt2,
Rollup's TS plugin) fails with a cryptic path error. This is
filed under microsoft/TypeScript#25047.

Curiously, this does not happen on master, and I have vaguely
traced it back to unionize and the fact that it does fancy type
exports, which we partially re-export here. We would have to
manually emit a declaration file, which is not hard tbh, but a bit
annoying. Even funnier, webpack has no issue building in storybook,
but that might be because it does not emit declarations anyway.

Steps:
- Get declaration file from master, add to repository, and copy to
dist/ upon build;
- See if massaging our exports fixes it;
- Wait for TS :/

* 1.1.0-rc.1

* Version bump

* Make update static, use Commands

The Elm/JS/Redux/React-Component fusion is complete. The reducer
is now a pure function, because it only describes side-effects,
and does not execute them. The logic is really nice to read there.

* Naming things

* Version bump

* Use TS3.0

* Copy definitions separately

Because of the "path undefined" bug, we have to run `tsc`
separately, to get the definitions and copy them over.

* Do not expose Buffering as a separate state

Expose it under 'Loading' for backwards compatibility

* Improve debounceDurationMs docs

* Add first point to README

* Cancel Promises, clear cache on unmount

* Add docs for debounceDurationMs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests