I have a Typescript project with two important files:
app.ts
models.d.ts
The first few lines of app.ts
look like this:
///<reference path="models.d.ts"/>
'use strict';
import * as fs from 'async-file';
import { MyClass } from './models';
The first few lines of the compiled app.js
are:
///<reference path="models.d.ts"/>
'use strict';
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("async-file");
const models_1 = require("./models"); //// ERROR THROWN HERE!!!!!!!!
However, no models.js
is generated because it's just a .d.ts
declaration file. So when I run this, and require
is called to get ./models
, I get the following exception:
Cannot find module './models'
This is Visual Studio Professional 2017 and I don't have a tsconfig.json
file. However, my project compilation settings look like this:
What am I doing wrong? This is killing me.
models.d.ts
implies that there is amodels.js
that already exists in its place in your output directory.You should probably use a
.ts
file if that isn't the case. In other words, rename it frommodels.d.ts
tomodels.ts
.