Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

ERROR in awesome-typescript-loader #619

Open
potapovnikita opened this issue Dec 5, 2018 · 6 comments
Open

ERROR in awesome-typescript-loader #619

potapovnikita opened this issue Dec 5, 2018 · 6 comments

Comments

@potapovnikita
Copy link

potapovnikita commented Dec 5, 2018

I'm get a error:
ERROR in ./ClientApp/src/utils/utils.ts
Module build failed: Error: Final loader (./node_modules/awesome-typescript-loader/dist/entry.js) didn't return a Buffer or String

utils.ts:
export function removeRouteParams() {window.history.replaceState({}, document.title, '/');}

If i'm remove window.history, then error is dissapeared

@darklightcode
Copy link

Try adding "dom" lib into the tsconfig.json compilerOptions

{
  "compilerOptions": {
    ...
    "lib": [
      "dom"
    ]
  }
}

or declare the object as any
export function removeRouteParams() {(window.history as any).replaceState({}, document.title, '/');}

@potapovnikita
Copy link
Author

@darklightcode, "dom" is already added. Declare the object does not solve this problem.

I'm think that is a bug of typescript 3.2, because in version 3.1.6. all good.

@agg23
Copy link

agg23 commented Dec 11, 2018

Also can replicate running on Typescript 3.2.2, whereas it works fine on 3.1.6.

@astorije
Copy link
Contributor

Most likely duplicate of #618

@ajaska
Copy link

ajaska commented Jan 30, 2019

For anyone else coming in via Google, had this (It gave the same top level "Buffer or String" error as #618 which may be related, but I confirmed that my issue was around history).

This issue is related to TypeScript itself crashing because of microsoft/TypeScript#28810

For anyone looking for a temporary fix, I'd recommend

(window.history as any).replaceState

Or, if you're like me, and you can't cast to any because you're calling window.history from a Javascript file (and somehow that's crashing TypeScript 🤔), you can be disgusting (like me) and do:

/**
  * put a big comment here about the TypeScript + window.history issue,
  * so other people will judge you less
  */
window["h"+"istory"].replaceState

@delesseps
Copy link

I had similar issues but some of the workarounds above didn't work for me so I used the following

(window as any).history

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants