microsoft / microsoft/TypeScript
can't emit import when overwrite declare
Open
Nobody has claimed this yet.
Bug
Domain: Error Messages
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.2.0-dev.201xxxxx
Search Terms:
Code
import hashSum = require('hash-sum');
import shortid = require('shortid');
declare function shortid(): string
declare function hashSum(input): string
export function hashAny(seed?, ...argv): string
{
if (!seed)
{
seed = shortid()
}
else if (typeof seed !== 'string')
{
seed = hashSum(seed)
}
return String(seed)
}
export default hashAny;
Expected behavior:
output js file include
const hashSum = require("hash-sum");
const shortid = require("shortid");
Actual behavior:
miss require
hash-sum,shortid
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function hashAny(seed, ...argv) {
if (!seed) {
seed = shortid();
}
else if (typeof seed !== 'string') {
seed = hashSum(seed);
}
return String(seed);
}
exports.hashAny = hashAny;
exports.default = hashAny;
Playground Link:
Related Issues:
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
No source file or test is named. Reproduce the TypeScript 3.2 behavior using the provided imports and declarations, then trace the compiler's CommonJS import emission for overwritten declarations. Done means the generated JavaScript includes require calls for both hash-sum and shortid while preserving the shown runtime behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100