Skip to content

Allow .ts extension when importing from a private mapping? #61613

@olalonde

Description

@olalonde

🔍 Search Terms

I'm using Node.js new typescript support and have the following in my package.json`:

  "imports": {
    "#root/*": "./src/*"
  },

In a file I'm doing the following import:

import type { QueryResolvers } from "#root/graphql/schema/types.generated.ts";

And I'm getting the following error:

This import uses a '.ts' extension to resolve to an input TypeScript file, but will not be rewritten during emit because it is not a relative path.ts(2877)

As far as I know, the above import will work so there is no need for that error. It would be nice to be able to disable it.

Here's my config:

{
  "compilerOptions": {
    // Base Taken from https://nodejs.org/docs/latest-v23.x/api/typescript.html#type-stripping
    "noEmit": true,
    "target": "esnext",
    "module": "nodenext",
    "rewriteRelativeImportExtensions": true,
    "erasableSyntaxOnly": true,
    "verbatimModuleSyntax": true,
    // custom:
    "strict": true,
    // https://stackoverflow.com/a/53957291
    "noErrorTruncation": true,
    "allowImportingTsExtensions": true
  }
}

✅ Viability Checklist

⭐ Suggestion

See above.

📃 Motivating Example

See above.

💻 Use Cases

See above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions