-
-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate declaration files for js files if allowJs is set to true (#1483
) * Fixes #1260 by generating declaration files for js files if allowJs is set to true. * Fix declarationOutputAllowJs test Update expected test output for 4.7 and stabilize expectation to be OS independent. * Update package.json and CHANGELOG.md for 9.3.1 * Update CHANGELOG.md Co-authored-by: John Reilly <[email protected]> Co-authored-by: Henning Dieterichs <[email protected]> Co-authored-by: John Reilly <[email protected]>
- Loading branch information
1 parent
914cdae
commit b4b0363
Showing
13 changed files
with
194 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import dep = require('./sub/dep'); | ||
|
||
class Test { | ||
private _field?: dep; | ||
} | ||
|
||
export = Test; |
4 changes: 4 additions & 0 deletions
4
test/comparison-tests/declarationOutputAllowJs/expectedOutput-4.7/.output/app.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
declare class Test { | ||
private _field?; | ||
} | ||
export = Test; |
6 changes: 6 additions & 0 deletions
6
test/comparison-tests/declarationOutputAllowJs/expectedOutput-4.7/.output/sub/dep.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export class Test { | ||
/** | ||
* @param {number} x | ||
*/ | ||
doSomething(x: number): number; | ||
} |
57 changes: 57 additions & 0 deletions
57
test/comparison-tests/declarationOutputAllowJs/expectedOutput-4.7/bundle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). | ||
* This devtool is neither made for production nor for readable output files. | ||
* It uses "eval()" calls to create a separate source file in the browser devtools. | ||
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) | ||
* or disable the default devtool with "devtool: false". | ||
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). | ||
*/ | ||
/******/ (() => { // webpackBootstrap | ||
/******/ "use strict"; | ||
/******/ var __webpack_modules__ = ({ | ||
|
||
/***/ "./app.ts": | ||
/*!****************!*\ | ||
!*** ./app.ts ***! | ||
\****************/ | ||
/***/ ((module) => { | ||
|
||
eval("\nvar Test = /** @class */ (function () {\n function Test() {\n }\n return Test;\n}());\nmodule.exports = Test;\n\n\n//# sourceURL=webpack:///./app.ts?"); | ||
|
||
/***/ }) | ||
|
||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ var cachedModule = __webpack_module_cache__[moduleId]; | ||
/******/ if (cachedModule !== undefined) { | ||
/******/ return cachedModule.exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ // no module.id needed | ||
/******/ // no module.loaded needed | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/************************************************************************/ | ||
/******/ | ||
/******/ // startup | ||
/******/ // Load entry module and return exports | ||
/******/ // This entry module is referenced by other modules so it can't be inlined | ||
/******/ var __webpack_exports__ = __webpack_require__("./app.ts"); | ||
/******/ | ||
/******/ })() | ||
; |
12 changes: 12 additions & 0 deletions
12
test/comparison-tests/declarationOutputAllowJs/expectedOutput-4.7/output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
asset bundle.js 2.19 KiB [emitted] (name: main) | ||
asset .output/sub/dep.d.ts 99 bytes [emitted] | ||
asset .output/app.d.ts 59 bytes [emitted] | ||
./app.ts 128 bytes [built] [code generated] [1 error] | ||
|
||
ERROR in app.ts | ||
./app.ts 4:18-21 | ||
[90m[tsl] [39m[1m[31mERROR[39m[22m[1m[31m in [39m[22m[1m[36mapp.ts(4,19)[39m[22m | ||
[1m[31m TS2709: Cannot use namespace 'dep' as a type.[39m[22m | ||
ts-loader-default_609318b4f68865d3 | ||
|
||
webpack compiled with 1 error |
57 changes: 57 additions & 0 deletions
57
test/comparison-tests/declarationOutputAllowJs/expectedOutput-transpile-4.7/bundle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). | ||
* This devtool is neither made for production nor for readable output files. | ||
* It uses "eval()" calls to create a separate source file in the browser devtools. | ||
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) | ||
* or disable the default devtool with "devtool: false". | ||
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). | ||
*/ | ||
/******/ (() => { // webpackBootstrap | ||
/******/ "use strict"; | ||
/******/ var __webpack_modules__ = ({ | ||
|
||
/***/ "./app.ts": | ||
/*!****************!*\ | ||
!*** ./app.ts ***! | ||
\****************/ | ||
/***/ ((module) => { | ||
|
||
eval("\nvar Test = /** @class */ (function () {\n function Test() {\n }\n return Test;\n}());\nmodule.exports = Test;\n\n\n//# sourceURL=webpack:///./app.ts?"); | ||
|
||
/***/ }) | ||
|
||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ var cachedModule = __webpack_module_cache__[moduleId]; | ||
/******/ if (cachedModule !== undefined) { | ||
/******/ return cachedModule.exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ // no module.id needed | ||
/******/ // no module.loaded needed | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/************************************************************************/ | ||
/******/ | ||
/******/ // startup | ||
/******/ // Load entry module and return exports | ||
/******/ // This entry module is referenced by other modules so it can't be inlined | ||
/******/ var __webpack_exports__ = __webpack_require__("./app.ts"); | ||
/******/ | ||
/******/ })() | ||
; |
3 changes: 3 additions & 0 deletions
3
test/comparison-tests/declarationOutputAllowJs/expectedOutput-transpile-4.7/output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
asset bundle.js 2.19 KiB [emitted] (name: main) | ||
./app.ts 128 bytes [built] [code generated] | ||
webpack compiled successfully |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
export class Test { | ||
/** | ||
* @param {number} x | ||
*/ | ||
doSomething(x) { | ||
return x; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
test/comparison-tests/declarationOutputAllowJs/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationDir": ".output", | ||
"allowJs": true | ||
}, | ||
"files": [ | ||
"./app.ts", | ||
"./sub/dep.js" | ||
] | ||
} |
15 changes: 15 additions & 0 deletions
15
test/comparison-tests/declarationOutputAllowJs/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
mode: 'development', | ||
entry: './app.ts', | ||
output: { | ||
filename: 'bundle.js' | ||
}, | ||
resolve: { | ||
extensions: ['.ts', '.js'] | ||
}, | ||
module: { | ||
rules: [ | ||
{ test: /\.ts$/, loader: 'ts-loader' } | ||
] | ||
} | ||
} |