7rulnik / source-map-js

Consume and generate source maps.
Other
95 stars 14 forks source link

[1.0.2 regression] TypeScript error TS2306: File '…/source-map.d.ts' is not a module #24

Closed andersk closed 2 months ago

andersk commented 7 months ago
$ npm i source-map@npm:source-map-js@1.2.0 typescript

added 2 packages in 2s

$ echo 'import * as SourceMap from "source-map"' > test.ts

$ npx tsc test.ts 
test.ts:1:28 - error TS2306: File '/tmp/node_modules/source-map/source-map.d.ts' is not a module.

1 import * as SourceMap from "source-map"
                             ~~~~~~~~~~~~

Found 1 error in test.ts:1

This worked in 1.0.1 and regressed in 1.0.2. I explained the reason at https://github.com/7rulnik/source-map-js/pull/13#pullrequestreview-1325506171: the declare module syntax is only for stubbing third-party modules. To declare modules in the current package, you should just write a separate .d.ts file for each .js file.