Open dborysov opened 6 years ago
That doesn't work due to the bundling process, or at least the way it is configured atm.. Not specific to CRA(-ts), but to every project using typescript
while bundling with webpack
.
However, there are two ways to achieve what you want.
ts-loader
README - but beware, since it requires adding a plugin, you'd have to eject: https://github.com/TypeStrong/ts-loader/blob/master/README.md#declarations-dts
Benefit: Generates a single bundle containing your typings.
Drawback: Requires ejecting; plugin does not seem to be that actively maintained.npx tsc -p tsconfig.json --emitDeclarationOnly
. The declarations will end up in build/dist
(or whatever you changed outDir
to) in hierachical structure.
Benefit: Does not require ejecting, can be done without any additional tools.
Drawback: It's not a bundle, but a collection of files.
Is this a bug report?
Yes
Can you also reproduce the problem with npm 4.x?
Yes
Which terms did you search for in User Guide?
declaration
Environment
npm ls react-scripts-ts
(if you haven’t ejected): 2.13.0node -v
: v8.9.4npm -v
: 5.6.0yarn --version
(if you use Yarn): 1.3.2Then, specify:
Steps to Reproduce
(Write your steps here:)
"declaration": true,
to thepackage.json
and remove"allowJs": true,
ls build/static/js
Expected Behavior
I should see
.d.ts
types declarationsActual Behavior
I don't see
.d.ts
types declarations