webpack-dev-server & ts-loader not reloads when interface changed
I'm using webpack@4.16.1, webpack-dev-server@3.1.4 and ts-loader@4.4.2.
I use Interface/index.ts to manage imports, to organize multiple interface imports.
But When I change interface file, webpack-dev-server(or ts-loader, I don`t know) not reload & transpile changed interface file.
Interface/IHelloState.ts
export interface IHelloState
message: string;
Interface.index.ts
export IHelloState from "./IHelloState";
index.tsx
import * as React from "react";
import * as ReactDOM from "react-dom";
import "./index.css";
import IHelloState from "./Interface";
const helloState: IHelloState =
message: "hello!"
;
ReactDOM.render(<div>helloState.message</div>, document.getElementById("root"));
When I change Interface/IHelloState.ts like:
Interface/IHelloState.ts
export interface IHelloState
// message: string;
Nothing happens. Not even "[HMR] Checking for updates on the server..." or "[HMR] Nothing hot updated." shows.
When I change Interface/IHelloState.ts and index.tsx like:
Interface/IHelloState.ts
export interface IHelloState
message: string;
state: boolean;
index.tsx
import * as React from "react";
import * as ReactDOM from "react-dom";
import "./index.css";
import IHelloState from "./Interface";
const helloState: IHelloState =
message: "hello!",
state: true
;
Now and error reports.
[tsl] ERROR in (PATH...)index.tsx(8,5)
TS2322: Type ' message: string; state: boolean; ' is not assignable to type 'IHelloState'.
Object literal may only specify known properties, and 'state' does not exist in type 'IHelloState'.
What should I change?
I run webpack-dev-server with webpack-dev-server --config webpack.dev.config.js --hot.
This is my config file.
webpack.dev.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
module.exports = Object.assign(require("./webpack.base.config"),
entry: [
path.join(__dirname, "src/app/index.tsx"),
"webpack/hot/only-dev-server"
],
output:
path: path.join(__dirname, "build/app"),
filename: "static/js/bundle.[hash].js"
,
module:
rules: [
test: /.jsx?$/,
loader: "babel-loader"
,
test: /.tsx?$/,
loader: "ts-loader",
options:
configFile: "tsconfig.app.json"
,
test: /.css$/,
use: [
"style-loader",
loader: "css-loader",
options:
modules: false
]
,
exclude: [/.tsx?/, /.jsx?$/, /.html$/, /.css$/, /.json$/],
loader: "file-loader",
options:
name: "static/files/[hash].[ext]"
]
,
resolve:
extensions: [".ts", ".tsx", ".js", ".jsx", ".css", ".json"]
,
plugins: [
new HtmlWebpackPlugin(
template: path.join(__dirname, "src/app/index.html")
),
new webpack.HotModuleReplacementPlugin()
],
devServer:
historyApiFallback:
index: "/"
,
target: "electron-renderer",
mode: "development"
);
typescript webpack webpack-dev-server ts-loader
add a comment |
I'm using webpack@4.16.1, webpack-dev-server@3.1.4 and ts-loader@4.4.2.
I use Interface/index.ts to manage imports, to organize multiple interface imports.
But When I change interface file, webpack-dev-server(or ts-loader, I don`t know) not reload & transpile changed interface file.
Interface/IHelloState.ts
export interface IHelloState
message: string;
Interface.index.ts
export IHelloState from "./IHelloState";
index.tsx
import * as React from "react";
import * as ReactDOM from "react-dom";
import "./index.css";
import IHelloState from "./Interface";
const helloState: IHelloState =
message: "hello!"
;
ReactDOM.render(<div>helloState.message</div>, document.getElementById("root"));
When I change Interface/IHelloState.ts like:
Interface/IHelloState.ts
export interface IHelloState
// message: string;
Nothing happens. Not even "[HMR] Checking for updates on the server..." or "[HMR] Nothing hot updated." shows.
When I change Interface/IHelloState.ts and index.tsx like:
Interface/IHelloState.ts
export interface IHelloState
message: string;
state: boolean;
index.tsx
import * as React from "react";
import * as ReactDOM from "react-dom";
import "./index.css";
import IHelloState from "./Interface";
const helloState: IHelloState =
message: "hello!",
state: true
;
Now and error reports.
[tsl] ERROR in (PATH...)index.tsx(8,5)
TS2322: Type ' message: string; state: boolean; ' is not assignable to type 'IHelloState'.
Object literal may only specify known properties, and 'state' does not exist in type 'IHelloState'.
What should I change?
I run webpack-dev-server with webpack-dev-server --config webpack.dev.config.js --hot.
This is my config file.
webpack.dev.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
module.exports = Object.assign(require("./webpack.base.config"),
entry: [
path.join(__dirname, "src/app/index.tsx"),
"webpack/hot/only-dev-server"
],
output:
path: path.join(__dirname, "build/app"),
filename: "static/js/bundle.[hash].js"
,
module:
rules: [
test: /.jsx?$/,
loader: "babel-loader"
,
test: /.tsx?$/,
loader: "ts-loader",
options:
configFile: "tsconfig.app.json"
,
test: /.css$/,
use: [
"style-loader",
loader: "css-loader",
options:
modules: false
]
,
exclude: [/.tsx?/, /.jsx?$/, /.html$/, /.css$/, /.json$/],
loader: "file-loader",
options:
name: "static/files/[hash].[ext]"
]
,
resolve:
extensions: [".ts", ".tsx", ".js", ".jsx", ".css", ".json"]
,
plugins: [
new HtmlWebpackPlugin(
template: path.join(__dirname, "src/app/index.html")
),
new webpack.HotModuleReplacementPlugin()
],
devServer:
historyApiFallback:
index: "/"
,
target: "electron-renderer",
mode: "development"
);
typescript webpack webpack-dev-server ts-loader
But an interface change does not affect the actual code..
– Nurbol Alpysbayev
Nov 15 '18 at 4:21
@Nurbol Alpysbayev Oh, I fixed my example. The problem is, if real object type not matches cached interface(not changed interface), type error occurs. Thank you for your mention.
– kuroneko0441
Nov 15 '18 at 5:06
@J.Lee What change did you have to do to fix this? I am running into the same problem now.
– Shawn
Jan 12 at 4:34
@Shawn I could not find any useful solution. My temporary solution is just restarting the webpack dev server.
– kuroneko0441
Jan 13 at 22:36
@J.Lee Thanks for getting back to me, I didn't have any luck using ts-loader but I switched to awesome-typescript-loader and it seems to be handling this issue now. I haven't tested it too much so I'm not 100% sure but its worth a read on that loader.
– Shawn
Jan 14 at 16:38
add a comment |
I'm using webpack@4.16.1, webpack-dev-server@3.1.4 and ts-loader@4.4.2.
I use Interface/index.ts to manage imports, to organize multiple interface imports.
But When I change interface file, webpack-dev-server(or ts-loader, I don`t know) not reload & transpile changed interface file.
Interface/IHelloState.ts
export interface IHelloState
message: string;
Interface.index.ts
export IHelloState from "./IHelloState";
index.tsx
import * as React from "react";
import * as ReactDOM from "react-dom";
import "./index.css";
import IHelloState from "./Interface";
const helloState: IHelloState =
message: "hello!"
;
ReactDOM.render(<div>helloState.message</div>, document.getElementById("root"));
When I change Interface/IHelloState.ts like:
Interface/IHelloState.ts
export interface IHelloState
// message: string;
Nothing happens. Not even "[HMR] Checking for updates on the server..." or "[HMR] Nothing hot updated." shows.
When I change Interface/IHelloState.ts and index.tsx like:
Interface/IHelloState.ts
export interface IHelloState
message: string;
state: boolean;
index.tsx
import * as React from "react";
import * as ReactDOM from "react-dom";
import "./index.css";
import IHelloState from "./Interface";
const helloState: IHelloState =
message: "hello!",
state: true
;
Now and error reports.
[tsl] ERROR in (PATH...)index.tsx(8,5)
TS2322: Type ' message: string; state: boolean; ' is not assignable to type 'IHelloState'.
Object literal may only specify known properties, and 'state' does not exist in type 'IHelloState'.
What should I change?
I run webpack-dev-server with webpack-dev-server --config webpack.dev.config.js --hot.
This is my config file.
webpack.dev.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
module.exports = Object.assign(require("./webpack.base.config"),
entry: [
path.join(__dirname, "src/app/index.tsx"),
"webpack/hot/only-dev-server"
],
output:
path: path.join(__dirname, "build/app"),
filename: "static/js/bundle.[hash].js"
,
module:
rules: [
test: /.jsx?$/,
loader: "babel-loader"
,
test: /.tsx?$/,
loader: "ts-loader",
options:
configFile: "tsconfig.app.json"
,
test: /.css$/,
use: [
"style-loader",
loader: "css-loader",
options:
modules: false
]
,
exclude: [/.tsx?/, /.jsx?$/, /.html$/, /.css$/, /.json$/],
loader: "file-loader",
options:
name: "static/files/[hash].[ext]"
]
,
resolve:
extensions: [".ts", ".tsx", ".js", ".jsx", ".css", ".json"]
,
plugins: [
new HtmlWebpackPlugin(
template: path.join(__dirname, "src/app/index.html")
),
new webpack.HotModuleReplacementPlugin()
],
devServer:
historyApiFallback:
index: "/"
,
target: "electron-renderer",
mode: "development"
);
typescript webpack webpack-dev-server ts-loader
I'm using webpack@4.16.1, webpack-dev-server@3.1.4 and ts-loader@4.4.2.
I use Interface/index.ts to manage imports, to organize multiple interface imports.
But When I change interface file, webpack-dev-server(or ts-loader, I don`t know) not reload & transpile changed interface file.
Interface/IHelloState.ts
export interface IHelloState
message: string;
Interface.index.ts
export IHelloState from "./IHelloState";
index.tsx
import * as React from "react";
import * as ReactDOM from "react-dom";
import "./index.css";
import IHelloState from "./Interface";
const helloState: IHelloState =
message: "hello!"
;
ReactDOM.render(<div>helloState.message</div>, document.getElementById("root"));
When I change Interface/IHelloState.ts like:
Interface/IHelloState.ts
export interface IHelloState
// message: string;
Nothing happens. Not even "[HMR] Checking for updates on the server..." or "[HMR] Nothing hot updated." shows.
When I change Interface/IHelloState.ts and index.tsx like:
Interface/IHelloState.ts
export interface IHelloState
message: string;
state: boolean;
index.tsx
import * as React from "react";
import * as ReactDOM from "react-dom";
import "./index.css";
import IHelloState from "./Interface";
const helloState: IHelloState =
message: "hello!",
state: true
;
Now and error reports.
[tsl] ERROR in (PATH...)index.tsx(8,5)
TS2322: Type ' message: string; state: boolean; ' is not assignable to type 'IHelloState'.
Object literal may only specify known properties, and 'state' does not exist in type 'IHelloState'.
What should I change?
I run webpack-dev-server with webpack-dev-server --config webpack.dev.config.js --hot.
This is my config file.
webpack.dev.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
module.exports = Object.assign(require("./webpack.base.config"),
entry: [
path.join(__dirname, "src/app/index.tsx"),
"webpack/hot/only-dev-server"
],
output:
path: path.join(__dirname, "build/app"),
filename: "static/js/bundle.[hash].js"
,
module:
rules: [
test: /.jsx?$/,
loader: "babel-loader"
,
test: /.tsx?$/,
loader: "ts-loader",
options:
configFile: "tsconfig.app.json"
,
test: /.css$/,
use: [
"style-loader",
loader: "css-loader",
options:
modules: false
]
,
exclude: [/.tsx?/, /.jsx?$/, /.html$/, /.css$/, /.json$/],
loader: "file-loader",
options:
name: "static/files/[hash].[ext]"
]
,
resolve:
extensions: [".ts", ".tsx", ".js", ".jsx", ".css", ".json"]
,
plugins: [
new HtmlWebpackPlugin(
template: path.join(__dirname, "src/app/index.html")
),
new webpack.HotModuleReplacementPlugin()
],
devServer:
historyApiFallback:
index: "/"
,
target: "electron-renderer",
mode: "development"
);
typescript webpack webpack-dev-server ts-loader
typescript webpack webpack-dev-server ts-loader
edited Nov 15 '18 at 5:04
kuroneko0441
asked Nov 15 '18 at 4:10
kuroneko0441kuroneko0441
214
214
But an interface change does not affect the actual code..
– Nurbol Alpysbayev
Nov 15 '18 at 4:21
@Nurbol Alpysbayev Oh, I fixed my example. The problem is, if real object type not matches cached interface(not changed interface), type error occurs. Thank you for your mention.
– kuroneko0441
Nov 15 '18 at 5:06
@J.Lee What change did you have to do to fix this? I am running into the same problem now.
– Shawn
Jan 12 at 4:34
@Shawn I could not find any useful solution. My temporary solution is just restarting the webpack dev server.
– kuroneko0441
Jan 13 at 22:36
@J.Lee Thanks for getting back to me, I didn't have any luck using ts-loader but I switched to awesome-typescript-loader and it seems to be handling this issue now. I haven't tested it too much so I'm not 100% sure but its worth a read on that loader.
– Shawn
Jan 14 at 16:38
add a comment |
But an interface change does not affect the actual code..
– Nurbol Alpysbayev
Nov 15 '18 at 4:21
@Nurbol Alpysbayev Oh, I fixed my example. The problem is, if real object type not matches cached interface(not changed interface), type error occurs. Thank you for your mention.
– kuroneko0441
Nov 15 '18 at 5:06
@J.Lee What change did you have to do to fix this? I am running into the same problem now.
– Shawn
Jan 12 at 4:34
@Shawn I could not find any useful solution. My temporary solution is just restarting the webpack dev server.
– kuroneko0441
Jan 13 at 22:36
@J.Lee Thanks for getting back to me, I didn't have any luck using ts-loader but I switched to awesome-typescript-loader and it seems to be handling this issue now. I haven't tested it too much so I'm not 100% sure but its worth a read on that loader.
– Shawn
Jan 14 at 16:38
But an interface change does not affect the actual code..
– Nurbol Alpysbayev
Nov 15 '18 at 4:21
But an interface change does not affect the actual code..
– Nurbol Alpysbayev
Nov 15 '18 at 4:21
@Nurbol Alpysbayev Oh, I fixed my example. The problem is, if real object type not matches cached interface(not changed interface), type error occurs. Thank you for your mention.
– kuroneko0441
Nov 15 '18 at 5:06
@Nurbol Alpysbayev Oh, I fixed my example. The problem is, if real object type not matches cached interface(not changed interface), type error occurs. Thank you for your mention.
– kuroneko0441
Nov 15 '18 at 5:06
@J.Lee What change did you have to do to fix this? I am running into the same problem now.
– Shawn
Jan 12 at 4:34
@J.Lee What change did you have to do to fix this? I am running into the same problem now.
– Shawn
Jan 12 at 4:34
@Shawn I could not find any useful solution. My temporary solution is just restarting the webpack dev server.
– kuroneko0441
Jan 13 at 22:36
@Shawn I could not find any useful solution. My temporary solution is just restarting the webpack dev server.
– kuroneko0441
Jan 13 at 22:36
@J.Lee Thanks for getting back to me, I didn't have any luck using ts-loader but I switched to awesome-typescript-loader and it seems to be handling this issue now. I haven't tested it too much so I'm not 100% sure but its worth a read on that loader.
– Shawn
Jan 14 at 16:38
@J.Lee Thanks for getting back to me, I didn't have any luck using ts-loader but I switched to awesome-typescript-loader and it seems to be handling this issue now. I haven't tested it too much so I'm not 100% sure but its worth a read on that loader.
– Shawn
Jan 14 at 16:38
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312320%2fwebpack-dev-server-ts-loader-not-reloads-when-interface-changed%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312320%2fwebpack-dev-server-ts-loader-not-reloads-when-interface-changed%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
But an interface change does not affect the actual code..
– Nurbol Alpysbayev
Nov 15 '18 at 4:21
@Nurbol Alpysbayev Oh, I fixed my example. The problem is, if real object type not matches cached interface(not changed interface), type error occurs. Thank you for your mention.
– kuroneko0441
Nov 15 '18 at 5:06
@J.Lee What change did you have to do to fix this? I am running into the same problem now.
– Shawn
Jan 12 at 4:34
@Shawn I could not find any useful solution. My temporary solution is just restarting the webpack dev server.
– kuroneko0441
Jan 13 at 22:36
@J.Lee Thanks for getting back to me, I didn't have any luck using ts-loader but I switched to awesome-typescript-loader and it seems to be handling this issue now. I haven't tested it too much so I'm not 100% sure but its worth a read on that loader.
– Shawn
Jan 14 at 16:38