Skip to content

Request: Compiler option to specify an alternate lib.d.ts #494

Description

The compiler has an option noLib which disables the default inclusion of lib.d.ts during compilation. Unfortunately there is no compiler option to specify a .d.ts file or files to automatically include before compiling each .ts file. Such an option would make it much easier to use an alternate lib.d.ts.

The work around now is to use the noLib option and then to add a line to each source file to manually pull in your alternate lib.d.ts.

Activity

  1. added this to the milestone on Aug 20, 2014
  2. NoelAbrahams commented on Aug 21, 2014

    @NoelAbrahams

    compiler option to specify a .d.ts file or files to automatically include before compiling each .ts file. Such an option would make it much easier to use an alternate lib.d.ts.

    👍

    I believe there is a larger issue here than simply including an alternate lib.d.ts. If we have a mechanism for specifying a directory then it should be possible to add the shared declarations there, for example, node.d.ts etc.

    This would also solve the problem Split official "lib.t.ts" into different files / Special references clauses

    We have a requirement to reduce the number of global variables (properties on window) such as name, length, location etc, because it causes errors to slip through (e.g. renaming a local variable called name will fail to highlight occurrences).

  3. basarat commented on Aug 21, 2014

    @basarat
    Contributor

    Noel Abrahams (@NoelAbrahams) I've been bitten by item :) (not badly though)

  4. NoelAbrahams commented on Aug 21, 2014

    @NoelAbrahams

    Basarat Ali Syed (@basarat), that's an interesting one. It's quite a significant problem. In the old codeplex site it was common for people new to TypeScript to file bugs because they couldn't understand why code like the snippet below would compile;

    var fullName: string;
    
    name = 'John Smith';
  5. mhegazy commented on Aug 21, 2014

    @mhegazy
    Contributor

    Noel Abrahams (@NoelAbrahams) the idea of splitting lib.d.ts is that node.d.ts would take dependency on lib.core.d.ts and not the normal lib, then when you reference node.d.ts you do not get any dom types as you would expect.

    For this issue, we need two things:

    • a command line switch to allow you to specify a specific lib
    • some notion of search paths, so that when you add /// it knows you mean the one in the folder next to the compiler.
  6. modified the milestones: , TypeScript 1.3 on Sep 8, 2014
  7. added
    SuggestionAn idea for TypeScript
    and removed
    BugA bug in TypeScript
    on Apr 21, 2015
  8. modified the milestone: on Apr 22, 2015
  9. mhegazy commented on Feb 20, 2016

    @mhegazy
    Contributor

    this should be covered by the proposal in #6974

  10. added
    DuplicateAn existing issue was already created
    and removed on Feb 20, 2016
  11. locked and limited conversation to collaborators on Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions