Skip to content

Treat new URL('relativePathHere', import.meta.url) as assets.Β #45955

Closed
@Jack-Works

Description

@Jack-Works

Suggestion

When using a file in TypeScript, new URL("./file.png", import.meta.url), TypeScript should copy this file to the output folder, like what it did for importing JSON files.

πŸ” Search Terms

new URL import meta url

βœ… Viability 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, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

πŸ“ƒ Motivating Example

This is useful when writing a library with assets referenced otherwise we need extra steps to copy those files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Out of ScopeThis idea sits outside of the TypeScript language design constraintsSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions