README
@digest/webpack-typescript
@digest/webpack-typescript provides the required
TypeScript Webpack dependencies and enables
typescript in @digest/webpack.
@digest/webpack processes TypeScript files through Webpack
just like ordinary JavaScript. No additional build step is required and all the
same Webpack features work as expected. For TypeScript IDE integration, extend
the included @digest/typescript config by creating a tsconfig.json file in the
root of your project:
"/tsconfig.json"
{
"extends": "node_modules/@digest/typescript/src/tsconfig.json"
}
However, with this default tsconfig.json, TypeScript files are not able to
import JavaScript. The setting noImplicitAny is set to true and that prevents
JavaScript files from being imported within TypeScript files. That said, it is
simple to override the default settings. For example, to import JavaScriptm, set
noImplicitAny to false in your tsconfig.json:
"/tsconfig.json"
{
"extends": "node_modules/@digest/typescript/src/tsconfig.json",
"compilerOptions": {
"noImplicitAny": false
}
}
However it is dangerous to turn off noImplicitAny. Only use if you must
import JavaScript. If so, work towards converting all your code to TypeScript.
It is also possible to import JavaScript using require(), but this will
prevent tree shaking.
At this time, there are several gotcha's with TypeScript such as .css,
.scss, and .json imports, and using Webpack's System API. These
can be resolved in a .d.ts file. Regrettably, it is not possible with the
shared tsconfig.json to include a default global.d.ts file while also
excluding implicit node_modules definitions. You may create a global.d.ts
file in the source directory of your project and add the following helpful
entries:
/* Place inside your /src/global.d.ts */
declare module '*.css';
declare module '*.scss';
declare var System: {
import: any
};
declare module "*.json" {
const value: any;
export default value;
}
declare var BUILD: {
DATE: Date;
}
License
GPLv3