Skip to content

feat: use @types instead of typings #1449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,13 @@ ng new sassy-project --style=sass

Simply install your library via `npm install lib-name` and import it in your code.

If the library does not include typings, you can search and install them using `npm run typings` npm script provided:
If the library does not include typings, you can install them using npm:

```bash
npm install moment
npm run typings -- search moment
npm run typings -- install dt~moment --global
npm install @types/moment
```

See https://github.com/typings/typings for more information about the `typings` tool.

### Updating angular-cli

To update `angular-cli` to a new version, you must update both the global package and your project's local package.
Expand Down
8 changes: 7 additions & 1 deletion addon/ng2/blueprints/ng2/files/__path__/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"moduleResolution": "node",
"outDir": "<%= relativeRootPath %>/dist/out-tsc",
"sourceMap": true,
"target": "es5"
"target": "es5",
"typeRoots": [
"../node_modules/@types"
],
"types": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we'll have to have a discussion about this, and I need to talk to a bunch of other people. I'm against having jasmine typings for the whole application. It should be for spec files only. But for that we would need to have 2 tsconfig files (or having different config). This was part of the discussions with the TypeScript team, and a solution does not exist yet. There are things that can be done though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just add the ref to the tests I suppose. But our webpack pipeline can use different tsconfig as well, so we can do that.

"jasmine"
]
}
}
5 changes: 1 addition & 4 deletions addon/ng2/blueprints/ng2/files/__path__/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
// https://github.com/typings/typings
// https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html

/// <reference path="<%= relativeRootPath %>/typings/index.d.ts" />
<% if(!isMobile) { %>
declare var System: any;
<% if(!isMobile) { %>declare var module: { id: string };<% } %>
declare var module: { id: string };
declare var require: any;
<% } %>

5 changes: 4 additions & 1 deletion addon/ng2/blueprints/ng2/files/config/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '..',
Expand All @@ -22,7 +25,7 @@ module.exports = function (config) {
'./src/test.ts': ['angular-cli']
},
angularCliConfig: './angular-cli.json',
reporters: ['progress'],
reporters: ['coverage', 'progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand Down
5 changes: 4 additions & 1 deletion addon/ng2/blueprints/ng2/files/e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"moduleResolution": "node",
"outDir": "../dist/out-tsc-e2e",
"sourceMap": true,
"target": "es5"
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
}
}
1 change: 0 additions & 1 deletion addon/ng2/blueprints/ng2/files/e2e/typings.d.ts

This file was deleted.

16 changes: 7 additions & 9 deletions addon/ng2/blueprints/ng2/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
"angular-cli": {},
"scripts": {
"start": "ng serve",
"postinstall": "typings install",
"lint": "tslint \"<%= sourceDir %>/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"typings": "typings"
"e2e": "protractor"
},
"private": true,
"dependencies": {
Expand All @@ -36,19 +34,19 @@
"angular2-universal-polyfills": "0.4.1",
"preboot": "2.1.2",
"parse5": "1.5.1",<% } %>
"@types/jasmine": "^2.2.30",
"@types/protractor": "^1.5.16",
"angular-cli": "^<%= version %>",
"codelyzer": "0.0.20",
"ember-cli-inject-live-reload": "1.4.0",
"codelyzer": "0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "0.13.22",
"karma-chrome-launcher": "0.2.3",
"karma-coverage": "^1.0.0",
"karma-jasmine": "0.3.8",
"protractor": "3.3.0",
"ts-node": "0.9.1",
"tslint": "3.11.0",
"typescript": "^1.9.0-dev.20160627-1.0",
"typings": "^1.3.1"
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "^2.0.0"
}
}
10 changes: 0 additions & 10 deletions addon/ng2/blueprints/ng2/files/typings.json

This file was deleted.

18 changes: 5 additions & 13 deletions addon/ng2/models/webpack-build-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,14 @@ import * as CopyWebpackPlugin from 'copy-webpack-plugin';
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
import * as webpack from 'webpack';
import { ForkCheckerPlugin } from 'awesome-typescript-loader';
import { LoaderConfig, PathsPlugin } from '../utilities/ts-path-mappings-webpack-plugin';
import { CliConfig } from './config';

export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
const awesomeTypescriptLoaderConfig: LoaderConfig | any = {
useWebpackText: true,
useForkChecker: true,
tsconfig: path.resolve(projectRoot, `./${sourceDir}/tsconfig.json`)
}

return {
devtool: 'inline-source-map',
resolve: {
extensions: ['', '.ts', '.js'],
root: path.resolve(projectRoot, `./${sourceDir}`),
moduleDirectories: ['node_modules'],
plugins: [
new PathsPlugin(awesomeTypescriptLoaderConfig);
]
root: path.resolve(projectRoot, `./${sourceDir}`)
},
context: path.resolve(__dirname, './'),
entry: {
Expand Down Expand Up @@ -49,7 +38,10 @@ export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) {
loaders: [
{
loader: 'awesome-typescript-loader',
query: awesomeTypescriptLoaderConfig
query: {
useForkChecker: true,
tsconfig: path.resolve(projectRoot, `./${sourceDir}/tsconfig.json`)
}
},
{
loader: 'angular2-template-loader'
Expand Down
1 change: 0 additions & 1 deletion addon/ng2/models/webpack-build-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const getWebpackTestConfig = function(projectRoot, sourceDir) {
{
loader: 'awesome-typescript-loader',
query: {
useWebpackText: true,
tsconfig: path.resolve(projectRoot, `./${sourceDir}/tsconfig.json`),
module: 'commonjs',
target: 'es5',
Expand Down
Loading