microsoft / microsoft/TypeScript
Add "sourceMapDir", "declarationMapDir", "inlineDeclarationMap", and "declarationMapInlineSources" compiler options
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Search Terms
TypeScript, Compiler Options, Source Maps, Declaration Files
Suggestion
Currently, there exist the TypeScript compiler options sourceMap, inlineSourceMap, inlineSources, declaration, declarationMap, and declarationDir but there is no way to tell the compiler the folder for the source map files and the declaration map files. The declaration map cannot be part of the declaration file, too, and the source code cannot be inlined into a declaration map.
Therefore, please add the compiler options:
sourceMapDir: the folder of the emitted source map files;declarationMapDir: the folder of the declaration map files;inlineDeclarationMap: the declaration map is put into the declaration file using a comment;declarationMapInlineSources: the source code becomes part of the declaration map similar to the optioninlineSourcesfor generated JavaScript files inlining TypeScript sources.
The options inlineDeclarationMap and declarationMapInlineSources should also be usable together. It is similar to using inlineSourceMap and inlineSources together.
Using Gulp together with gulp-typescript and gulp-sourcemaps there is already the possibility to specify a source map folder and declaration map folder using sourcemaps.write("<folder>", options) but it would be better to have that possibility as part of a TypeScript compiler option.
Use Cases
Of course, these compiler options are not necessary in most cases but they open up more flexibility to the user, and the implemetation should not be very difficult.
At least the option inlineDeclarationMap would reduce the cluttering of files in the declarationDir folder, and declarationMapInlineSources together with inlineDeclarationMap would make it possible to ship a declaration file with the sources as one file.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the existing sourceMap, declarationMap, declarationDir, inlineSourceMap, inlineSources, and declaration options and their compiler-option handling. Trace how emitted source and declaration maps are placed or inlined, then define coverage for each requested option and their combination. Done means the four options work together as described without changing existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100