microsoft / microsoft/TypeScript

Allow Typescript to detect when imported html relative paths are incorrect

Open
#23,455 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 2.8.1

Search Terms: html template import

Code

In global.d.ts:

declare module '*.html' {
    const value: string;
    export default value
}

Somewhere else in code:

import templateHtml from './SOME_PATH_THAT_DOESNT_EXIST.html'

Expected behavior:
I expect that Typescript will still attempt to parse the string in 'from' and tell me if it can't find any matching files, as it is a relative path.

Actual behavior:

No error or warning is emitted, so any typos in the path won't have a problem until running the app.

Playground Link:

Related Issues:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the module-resolution and type-checking paths for the ambient '*.html' declaration shown in global.d.ts, using the import example as the reproduction. The work is done when a missing relative HTML path produces a diagnostic while a matching path continues to resolve through the declaration.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.