brandonroberts / vladivostok-sample

1 stars 0 forks source link

CrisisCenter: monkey-punch typing support #11

Closed wardbell closed 8 years ago

wardbell commented 8 years ago

It's really hard to know if we've got the syntax right without typings support. In fact, many mistakes that typings would have been caught such as #10, #12,

We're stuck in some places because Victor uses features that are only available in TS 2.0 (actually 1.9x) and most editors (VS Code) won't know about those features. See #17 for remediation

I found that the following approach helped a lot:

  1. Monkey punch a fake @angular/router node_module that points to the ./router
  2. Add tsconfig.json
  3. Add typings.json
  4. Update the package.json to pull stuff in.

I've attached the fake @angular/router as a zip file.

@angular/router.zip

The other files follow

Remember to npm install

// tsconfig.json
{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "noEmitOnError": false,
    "module": "commonjs",
    "target": "es5",
    "noImplicitAny": false,
    "outDir": "dist",
    "rootDir": ".",
    "inlineSourceMap": true,
    "inlineSources": true,
    "declaration": true,
    "removeComments": true
  },
  "files": [
    "router/index.d.ts",
    "src/main.ts",
    "typings/index.d.ts"
  ]
}

// typings.json
{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160317120654",
    "jasmine": "registry:dt/jasmine#2.2.0+20160505161446",
    "node": "registry:dt/node#4.0.0+20160509154515"
  }
}

// package.json
{
  "name": "vladivostok-sample",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "start": "lite-server",
    "typings": "typings"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0-rc.1",
    "@angular/compiler": "2.0.0-rc.1",
    "@angular/core": "2.0.0-rc.1",
    "@angular/platform-browser": "2.0.0-rc.1",
    "@angular/platform-browser-dynamic": "2.0.0-rc.1",
    "rxjs": "5.0.0-beta.6"
  },
  "devDependencies": {
    "lite-server": "^2.2.0",
    "typescript": "^1.9.0-dev.20160409",
    "typings": "^1.0.4"
  }
}
brandonroberts commented 8 years ago

Closed via 00a10648a55d93fce5b6597d84f0f66dd4a87b4e