Skip to content

Instantly share code, notes, and snippets.

@AlecTaylor
Last active March 7, 2019 15:15
Show Gist options
  • Save AlecTaylor/dce6e857ea6a394ee913 to your computer and use it in GitHub Desktop.
Save AlecTaylor/dce6e857ea6a394ee913 to your computer and use it in GitHub Desktop.
# Within models.ts
# With `Foo`
Cannot find name 'Foo'
# With `Foo.Foo`
Cannot find namespace 'Foo'
/// <reference path='./../../typings/mongoose/mongoose.d.ts' />
// From: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/mongoose/mongoose.d.ts
import * as mongoose from 'mongoose';
// Tried `V0`, `V1`, `V2`, `V3` independently. None worked.
/* V0 */
export interface Foo extends mongoose.Document {
name: string;
}
/* V1 */
declare module Foo {
export interface ServiceInstance extends mongoose.Document {
name: string;
}
}
/* V2 */
declare var Foo: Foo.Foo;
declare module Foo {
export interface Foo extends mongoose.Document {
name: string;
}
}
/* V3 */
declare var Foo: Foo.Foo;
declare module Foo {
export interface Foo extends mongoose.Document {
name: string;
}
}
declare module "models" {
export = Foo
}
}
/// <reference path='./models.d.ts' />
import * as mongoose from 'mongoose';
export function Foo(model): Foo.Foo /* also tried `Foo` */ {
return mongoose.model('Foo', new mongoose.Schema({
name: String
}));
}
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"jsx": "react",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true
},
"filesGlob": [
"**/*.ts",
"**/*.tsx",
"!node_modules/**"
],
"compileOnSave": true,
"buildOnSave": false,
"files": [
"foo/bar/models.d.ts",
"foo/bar/models.ts",
"typings/mongoose/mongoose.d.ts",
"typings/node/node.d.ts"
],
"atom": {
"rewriteTsconfig": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment