Skip to content

Instantly share code, notes, and snippets.

@mastermatt
Created March 8, 2020 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mastermatt/ab2e06dbae4f44769e4366a03e503147 to your computer and use it in GitHub Desktop.
Save mastermatt/ab2e06dbae4f44769e4366a03e503147 to your computer and use it in GitHub Desktop.
Reproduce Error: TS2749: 'Thing' refers to a value, but is being used as a type here.
// generated by tsc
export const Thing: typeof import("./thing");
const Thing = require('./thing');
module.exports = { Thing };
// generated by tsc
export = Thing;
declare class Thing {
/**
* @param {string} name
*/
constructor(name: string);
name: string;
}
class Thing {
/**
* @param {string} name
*/
constructor(name) {
this.name = name;
}
}
module.exports = Thing;
{
"compilerOptions": {
"target": "es2018",
"esModuleInterop": true,
"allowJs": true,
"checkJs": false,
"declaration": true,
"emitDeclarationOnly": true
},
"files": [
"index.js"
]
}
import { Thing } from "jsapp";
export const createThing = (): Thing => { // <- Error: TS2749: 'Thing' refers to a value, but is being used as a type here.
return new Thing('Bob');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment