I have an older typescript project which uses the /typings/tsd.json method of handling .d.ts files, and which also uses Typescript's module
keyword to compile source into javascript's IIFE module pattern. The module setting in tsconfig.json (commonjs/amd/etc.) is ignored by that keyword.
For a demo, I am adding to this project some newer typescript code which uses the more typical method of import
and export
keywords with a SystemJS module loader, with .d.ts files in /node_modules/@types/.
After some Gulp/SystemJS gymnastics, it all works together at runtime and I'm on track to hit my deadline. But I am having trouble at compile-time in one scenario which I'd like to solve.
When I modify the older code to use a class (a model) from the newer code, I'd like the old code to know about the .d.ts of the new code. So I added to the top of the old code's file /// <reference path="../../newercode/feature4/models/NewerModels.d.ts"/>
. (Alternately, I put the same line in tsd.d.ts but I get the same result.)
The compiler complains my old code "has or is using private name 'NewModel'".
Inside NewerModels.d.ts the import
and export
keywords are still there, while none of the .d.ts files already in /typings/ use those keywords. Those keywords are the culprit for the spurious compiler error.
The legacy project wants ambient .d.ts files, newer code produces non-ambient.
Is there anything I can do about it?
tsd
, migrate to use@types
. You should be able to do that in one shot. – unional@types
should have the same syntax. The original library is still the same CommonJS library (unless that change, then you need to deal with versioning).tsd
gets files from DefinitelyTyped and same as@types
. TS team did a reasonable good job and converting the format. Give it a try to see if it works. – unionalNewModel
exported. Maybe you didn't include it in yourpackage.json/dist
? – unional