Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit 9528dd7

Browse files
Enable TS strict mode in all templates and generally clean up TS references
1 parent b8c006a commit 9528dd7

File tree

14 files changed

+27
-38
lines changed

14 files changed

+27
-38
lines changed

templates/AngularSpa/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
{
22
"compilerOptions": {
3+
"module": "es2015",
34
"moduleResolution": "node",
45
"target": "es5",
56
"sourceMap": true,
67
"experimentalDecorators": true,
78
"emitDecoratorMetadata": true,
89
"skipDefaultLibCheck": true,
10+
"skipLibCheck": true, // Workaround for https://github.com/angular/angular/issues/17863. Remove this if you upgrade to a fixed version of Angular.
11+
"strict": true,
912
"lib": [ "es6", "dom" ],
1013
"types": [ "webpack-env" ]
1114
},

templates/AureliaSpa/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"compilerOptions": {
3+
"module": "es2015",
34
"moduleResolution": "node",
45
"target": "es5",
56
"sourceMap": true,
67
"experimentalDecorators": true,
78
"emitDecoratorMetadata": true,
89
"skipDefaultLibCheck": true,
10+
"strict": true,
911
"lib": [ "es2015", "dom" ],
1012
"types": [ "webpack-env" ]
1113
},

templates/KnockoutSpa/ClientApp/boot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import './css/site.css';
22
import 'bootstrap';
33
import * as ko from 'knockout';
4+
import { createBrowserHistory } from 'history';
45
import './webpack-component-loader';
56
import AppRootComponent from './components/app-root/app-root';
6-
import { createBrowserHistory } from 'history';
77
const baseUrl = document.getElementsByTagName('base')[0].getAttribute('href')!;
88
const basename = baseUrl.substring(0, baseUrl.length - 1); // History component needs no trailing slash
99

templates/KnockoutSpa/ClientApp/router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as ko from 'knockout';
22
import * as $ from 'jquery';
33
import * as History from 'history';
4-
import crossroads = require('crossroads');
4+
import * as crossroads from 'crossroads';
55

66
// This module configures crossroads.js, a routing library. If you prefer, you
77
// can use any other routing library (or none at all) as Knockout is designed to
@@ -20,7 +20,7 @@ export class Router {
2020
// Reset and configure Crossroads so it matches routes and updates this.currentRoute
2121
crossroads.removeAllRoutes();
2222
crossroads.resetState();
23-
crossroads.normalizeFn = crossroads.NORM_AS_OBJECT;
23+
(crossroads as any).normalizeFn = crossroads.NORM_AS_OBJECT;
2424
routes.forEach(route => {
2525
crossroads.addRoute(route.url, (requestParams: any) => {
2626
this.currentRoute(ko.utils.extend(requestParams, route.params));

templates/KnockoutSpa/npm-shrinkwrap.json

Lines changed: 3 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/KnockoutSpa/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"@types/history": "^4.6.0",
1010
"@types/jquery": "^2.0.32",
1111
"@types/knockout": "^3.4.41",
12-
"@types/react-router": "^2.0.37",
1312
"@types/signals": "0.0.16",
1413
"@types/webpack-env": "^1.13.0",
1514
"aspnet-webpack": "^2.0.1",

templates/KnockoutSpa/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
22
"compilerOptions": {
3+
"module": "es2015",
34
"moduleResolution": "node",
45
"target": "es5",
56
"sourceMap": true,
67
"skipDefaultLibCheck": true,
8+
"strict": true,
79
"types": ["es6-promise", "webpack-env"]
810
},
911
"exclude": [

templates/ReactReduxSpa/ClientApp/store/WeatherForecasts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const actionCreators = {
6060
// ----------------
6161
// REDUCER - For a given state and action, returns the new state. To support time travel, this must not mutate the old state.
6262

63-
const unloadedState: WeatherForecastsState = { startDateIndex: undefined, forecasts: [], isLoading: false };
63+
const unloadedState: WeatherForecastsState = { forecasts: [], isLoading: false };
6464

6565
export const reducer: Reducer<WeatherForecastsState> = (state: WeatherForecastsState, incomingAction: Action) => {
6666
const action = incomingAction as KnownAction;

templates/ReactReduxSpa/tsconfig.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
{
22
"compilerOptions": {
33
"baseUrl": ".",
4+
"module": "es2015",
45
"moduleResolution": "node",
56
"target": "es5",
67
"jsx": "react",
78
"experimentalDecorators": true,
89
"sourceMap": true,
910
"skipDefaultLibCheck": true,
11+
"strict": true,
1012
"lib": ["es6", "dom"],
11-
"types": [ "webpack-env" ],
12-
"paths": {
13-
// Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions.
14-
// We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them).
15-
"history": ["./node_modules/@types/history/index"],
16-
"redux": ["./node_modules/@types/redux/index"],
17-
"react": ["./node_modules/@types/react/index"]
18-
}
13+
"types": ["webpack-env"]
1914
},
2015
"exclude": [
2116
"bin",

templates/ReactSpa/ClientApp/components/Counter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import * as React from 'react';
2+
import { RouteComponentProps } from 'react-router';
23

34
interface CounterState {
45
currentCount: number;
56
}
67

7-
export class Counter extends React.Component<{}, CounterState> {
8+
export class Counter extends React.Component<RouteComponentProps<{}>, CounterState> {
89
constructor() {
910
super();
1011
this.state = { currentCount: 0 };

templates/ReactSpa/ClientApp/components/FetchData.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import * as React from 'react';
2+
import { RouteComponentProps } from 'react-router';
23
import 'isomorphic-fetch';
34

45
interface FetchDataExampleState {
56
forecasts: WeatherForecast[];
67
loading: boolean;
78
}
89

9-
export class FetchData extends React.Component<{}, FetchDataExampleState> {
10+
export class FetchData extends React.Component<RouteComponentProps<{}>, FetchDataExampleState> {
1011
constructor() {
1112
super();
1213
this.state = { forecasts: [], loading: true };

templates/ReactSpa/ClientApp/components/Home.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
2+
import { RouteComponentProps } from 'react-router';
23

3-
export class Home extends React.Component<{}, {}> {
4+
export class Home extends React.Component<RouteComponentProps<{}>, {}> {
45
public render() {
56
return <div>
67
<h1>Hello, world!</h1>

templates/ReactSpa/tsconfig.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
{
22
"compilerOptions": {
33
"baseUrl": ".",
4+
"module": "es2015",
45
"moduleResolution": "node",
56
"target": "es5",
67
"jsx": "react",
78
"sourceMap": true,
89
"skipDefaultLibCheck": true,
9-
"types": [ "webpack-env" ],
10-
"paths": {
11-
// Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions.
12-
// We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them).
13-
"history": ["./node_modules/@types/history/index"],
14-
"react": ["./node_modules/@types/react/index"]
15-
}
10+
"strict": true,
11+
"types": ["webpack-env"]
1612
},
1713
"exclude": [
1814
"bin",

templates/VueSpa/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"target": "es5",
88
"sourceMap": true,
99
"skipDefaultLibCheck": true,
10+
"strict": true,
1011
"types": ["webpack-env"]
1112
},
1213
"exclude": [

0 commit comments

Comments
 (0)