Last active
March 7, 2019 15:15
-
-
Save AlecTaylor/dce6e857ea6a394ee913 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Within models.ts | |
| # With `Foo` | |
| Cannot find name 'Foo' | |
| # With `Foo.Foo` | |
| Cannot find namespace 'Foo' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <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 | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <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 | |
| })); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "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