typescript - Error TS2304 with tsc but not with Webpack, for names in project d.ts files -
problem
if type tsc main-test.ts --noemit
, many ts2304: cannot find name testinfo
error messages displayed. names can't find interfaces declared in d.ts
files have created in project directory, eg testglobals.d.ts
below.
if compile webpack , awesome-typescript-loader (node_modules\.bin\webpack --config wtest.webpack.config.js
), these messages not appear - project compiles successfully.
unfortunately, same errors show on travis ci, though scripts run on ci server compiled webpack. how rid of these errors?
i have tried
adding project source directory typeroots in tsconfig.json
in addition node_modules/@types
.
relevant files
wtest.webpack.config.js
var path = require('path'); var webpack = require('webpack'); var entryobj = { 'test-script': path.join(__dirname, '/test/main-test.ts') }; var manifestfile = '/test/manifest.json'; var outdir = '/dist/test'; var modulerulesinclude = [path.join(__dirname, 'src'), path.join(__dirname, 'test')]; var devtool = 'cheap-source-map'; module.exports = { devtool: devtool, entry: entryobj, resolve: { extensions: ['.js', '.ts', '.tsx'] }, module: { rules: [{ test: /\.tsx?$/, loaders: ['awesome-typescript-loader'], include: modulerulesinclude }] }, // workaround `can't resolve module 'fs'` issue node: { fs: 'empty', module: false } };
tsconfig.json
{ "compileroptions": { "target": "es6", "module": "commonjs", "declaration": false, "noimplicitany": false, "removecomments": true, "experimentaldecorators": true, "nolib": false, "jsx": "react", "outdir": "dist" }, "exclude": [ "node_modules", "static" ] }
testglobals.d.ts
interface testinfo { testname: string; url: string; title: string; author: string; chapterurls: string[]; parser: parserreturner; }
Comments
Post a Comment